配置nginx动静分离
1.修改nginx配置文件
# location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi.conf; 【需更改为实际文件名】 }
2.编写测试脚本
# vim /usr/local/nginx/html/test1.phpphp$i="This is a test Page";echo $i;?>
测试:firefox 192.168.4.5/test.php
若无法访问,可查看日志进行排错nginx日志/usr/local/nginx/logs/error.log
php日志/var/log/php-fpm/www-error.log
可利用 tailf 查看日志,先把之前日志清空,然后查看动态日志。
常见错误分析: php-fpm未开启 未做nginx动静分离 php代码错误