1、修改php-fpm.conf(/etc/php-fpm.conf)
如果有/etc/php-fpm.d/www.conf文件,就在该文件修改
可以输入下面命令查找:
find / -name php-fpm.conf
find / -name www.conf
2、在上述文件修改:
;listen = 127.0.0.1:9000
listen = /dev/shm/php-cgi.sock
user = nginx
group = nginx
3、修改nginx配置文件nginx.conf
find / -name nginx.conf//查找nginx.conf
修改完后重起:
service nginx restart
service php-fpm restart
配置文件如下:
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /var/web/learnlaravel5/public;
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ \.php$ {
# 设置监听端口
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}