nginx配置php虚拟主机

来源:互联网 发布:linux 环境变量unset 编辑:程序博客网 时间:2024/05/16 08:28

linux下 nginx配置php虚拟主机

1.找到nginx配置文件

ps -ef | grep nginx
找到正在运行的nginx进程,显示信息如下:

root     16445     1  0 Jun27 ?        00:00:00 nginx: master process /data/nginx.1.9.4_installed/sbin/nginx -c /data/nginx_conf/nginx.conf

2.配置PHP虚拟主机

编辑/data/nginx_conf/conf.d/xxx.conf,新增下面内容:

server {    listen 8888;    server_name www.myhost.com;    root  /data/www/dazhuang;    access_log  /var/log/nginx/backend.log  main;    location ~ \.php$ {        fastcgi_pass   127.0.0.1:9000;        fastcgi_index  index.php;        fastcgi_param  SCRIPT_FILENAME   /data/www/dazhuang$fastcgi_script_name;        include        fastcgi_params;    }    location ~ /\.git {        deny  all;    }}
3.重启nginx

这里直接重新加载配置文件即可,把ps查出来的信息复制,在后面加-s reload即可

/data/nginx.1.9.4_installed/sbin/nginx -c /data/nginx_conf/nginx.conf -s reload