在lnmp环境下创建 demo.zhengyang.com。
在etc/nginx/ 目录下面创建vhosts文件夹 ,然后在vhosts文件夹里面创demo.zhengyang.com.conf配置文件。
在配置里面放入以下内容:
server {
listen 80;
server_name demo.zhengyang.com;
index index.html index.htm index.php;
root /usr/share/nginx/html/zhengyang;
location ~ \.php$ {
root /usr/share/nginx/html/zhengyang;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/zhengyang/$fastcgi_script_name;
include fastcgi_params;
}
}
3.我的localhost在 usr/share/nginx/html下,在html目录下面创建zhengyang 这个文件夹 在文件夹里面创建一个1.php文件
4.在etc/hosts文件下面添加如图所示
原文:http://zhengyang.blog.51cto.com/7792351/1717062