第一步:修改php-fpm運(yùn)行方式為 socket
打開/Data/apps/php7/etc/php-fpm.d/www.conf文件酝蜒,并將listen = 127.0.0.1:9000修改為listen = /tmp/php-cgi.sock
Socket是使用unix domain socket連接套接字/dev/shm/php-cgi.sock(很多教程使用路徑/tmp誊辉,而路徑/dev/shm是個tmpfs,速度比磁盤快得多)listen = /dev/shm/php-cgi.sock
第二步:修改nginx配置文件
location ~ [^/]\.php(/|$) {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
第三步:重啟fpm和nginx
==================================================================
測試php-fpm配置
/usr/local/php/sbin/php-fpm -t
/usr/local/php/sbin/php-fpm -c /chenamu/server/php/etc/php.ini -y /chenamu/server/php/etc/php-fpm.conf -t
啟動php-fpm
/usr/local/php/sbin/php-fpm
/usr/local/php/sbin/php-fpm -c /chenamu/server/php/etc/php.ini -y /chenamu/server/php/etc/php-fpm.d/www.conf.1
關(guān)閉php-fpm
kill -INT cat /usr/local/php/var/run/php-fpm.pid
重啟php-fpm
kill -USR2 cat /usr/local/php/var/run/php-fpm.pid
/chenamu/server/php/etc/php-fpm.d/www.conf.1
/chenamu/server/php/etc/php-fpm.d/www.conf
=================================================
加強(qiáng)優(yōu)化
第一步:修改php-fpm運(yùn)行方式為 socket
第二步:cp多個www.conf秕硝,并修改listen = /tmp/php-cgi.sock.1
第三步:修改nginx的配置文件
upstream phpbackend {
server unix:/tmp/php-cgi.sock weight=100 max_fails=10 fail_timeout=30;
server unix:/tmp/php-cgi.sock.1 weight=100 max_fails=10 fail_timeout=30;
}
server {
server_name 127.0.0.1;
listen 444;
ssl on;
ssl_certificate /prefix/nginx/conf/33iq.crt;
ssl_certificate_key /prefix/nginx/conf/33iq_nopass.key;
ssl_protocols SSLv2 TLSv1;
ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
client_max_body_size 512M;
add_header X-Frame-Options SAMEORIGIN;
charset utf-8;
root /prefix/admin;
index index.html index.htm index.php;
location / {
index index.htm index.html index.php;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php last;
}
}
location ~ \.php(.*)$ {
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass phpbackend;
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
# fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
# fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}```
#### 第四步:重啟nginx和php-fpm(php-fpm啟動時指定相應(yīng)的配置文件)