使用Nginx代理php服务,需要配置相关文件
1、下载安装Nginx
如你的机器没有Nginx,请参考我的博客链接:Linux下安装Nginx的web服务器
2、修改配置文件
修改Nginx配置文件,相关配置如下:
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
location / {
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php{
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAMEdocument_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
注意php文件需放到root的目录下:
如果还出现问题,可以考虑权限问题,请参考我的博客文章:Nginx代理php出错处理
3、测试
在浏览器中输入:http://ip/xxx.php
效果:
0