先安裝php-fpm
yum install php-fpm service php-fpm start #启动 php-fpm
然後修改nginx設定檔nginx.conf 辨識php
# vi /usr/local/nginx/conf/nginx.conf 加一段程式碼
location ~ \.php$ { #fastcgi_split_path_info ^(.+\.php)(/.+)$; root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; include fastcgi_params; #$document_root }
最後重啟nginx和php-fpm
#service nginx restart service php-fpm restart
推薦教學:PHP影片教學
以上是nginx不能解析php的詳細內容。更多資訊請關注PHP中文網其他相關文章!