您好,登錄后才能下訂單哦!
LNMP環(huán)境:
? L:linux
? N:nginx
? M:mysql
? P:php
Linux系統(tǒng)就沒(méi)什么好說(shuō)的了。這里是centos 7.6
yum -y install epel-release
yum -y install nginx
yum -y install php php-fpm php-curl php-intl php-mcrypt php-mysql php-mbstring php-xml php-dom php-gd gd
用redis為mysql做緩存時(shí),添加下列
php-cli php-common php-pdo php-devel php-xmlrpc php-bcmath php-dba php-enchant
(nginx + php-fpm +fastcgi)
vim /etv/nginx/nginx.conf
location ~\.php$ {
root /webroot/farm;
fastcgi_pass 127.0.0.1:9000; #與php-fpm通信的方式
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
通信方式:
nginx和php-fpm的通信方式有兩種,一種是socket形式,一種是tcp形式。配置兩種方式都可以,但是必須保證nginx配置的監(jiān)聽(tīng)方式,和php-fpm.conf配置的監(jiān)聽(tīng)方式保持一致性!
推薦使用TCP方式也就是方式1,可以跨服務(wù)器。 php配置:/etc/php-fpm.conf或者/etc/php-fpm.d/xx.conf
方式1:
php-fpm.conf: listen = 127.0.0.1:9000
nginx.conf: fastcgi_pass 127.0.0.1:9000;
方式2:
php-fpm.conf: listen = /tmp/php-fpm.sock
nginx.conf: fastcgi_pass unix:/tmp/php-fpm.sock;
其中php-fpm.sock是一個(gè)文件,由php-fpm生成,類型是srw-rw----.
vim /etv/php.ini
#short_open_tag = off 改為如下:
short_open_tag = on #打開(kāi)短標(biāo)簽
上面配置完成就可以在nginx上部署php項(xiàng)目了。
[root@newrain ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
[root@newrain ~]# rpm -ivh mysql80-community-release-el7-3.noarch.rpm
[root@newrain ~]# vim /etc/yum.repos.d/mysql-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1 將0改為1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0 將1改為0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[root@newrain ~]# yum -y install mysql-server mysql
啟動(dòng)&開(kāi)機(jī)啟動(dòng)
[root@newrain ~]# systemctl start nginx
[root@newrain ~]# systemctl start mysqld
[root@newrain ~]# systemctl start php-fpm
[root@newrain ~]# systemctl enable nginx
[root@newrain ~]# systemctl enable mysqld
[root@newrain ~]# systemctl enable php-fpm
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。