准备
配置PHP-FPM
-
用nginx用户运行PHP-FPM
# vim /etc/php-fpm.d/www.conf user = nginx group = nginx
# systemctl restart php-fpm
配置Nginx
- 添加子配置
# vim /etc/nginx/conf.d/your.site.com.conf
server {
listen 80;
server_name your.site.com;
root /data/www/your.site.com;
index index.php index.html index.htm;
charset utf-8;
client_max_body_size 128M;
access_log /var/log/nginx/access-your.site.com.log main;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
- 重启Nginx
# nginx -t # systemctl restart nginx