nginx.conf
user nginx; ... http { ... server { listen 80; index index.php index.html; root /var/www/html/; location / { try_files $uri $uri/ $uri.php?$args; } location ~ .php$ { ssi on; ssi_silent_errors on; ssi_types text/shtml; root /var/www/rapiddev/; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/run/php-fpm/www.sock; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } }
/etc/php-fpm.d/www.conf
[www] user = nginx group = nginx listen = /run/php-fpm/www.sock ;listen = 127.0.0.1:9000 listen.allowed_clients = 127.0.0.1 listen.acl_users = apache,nginx
rewrite 隐藏.php后缀
location / { try_files $uri $uri/ $uri.php?$args; }
备注:
nginx.conf $document_root 的参数是由root html那一行定义的
/etc/php-fpm.d/www.conf user = nginx 要和nginx.conf中用户一致
nginx -s reload 重新加载conf