nginx虚拟主机配置

nginx nginx.conf
mysql my.cnf
php php.ini
apache httpd.conf

(1)打开nginx配置文件 vi /usr/local/nginx/conf/nginx.conf
在116行添加一行 include vhost/*.conf;
每一个server模块就是一个虚拟主机
【注】修改配置文件之前,先备份一个 cp nginx.conf nginx.conf.bak,养成良好的备份习惯
(2)新建vhost目录

cd /usr/local/nginx/conf
mkdir vhost
cd vhost
vi www.goudan.com.conf
server
{
    root /usr/local/nginx/html/goudan;
    server_name www.goudan.com;
    location / {
        index index.php index.html index.htm;
    }

    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      include        fastcgi_params;
  }
}

(3)来到windows下面,打开hosts文件

10.10.152.26   www.goudan.com

(4)重启nginx

service nginx restart

(5)创建虚拟机跟目录

cd /usr/local/nginx/html
mkdir goudan
vi index.html

(6)浏览器访问 www.goudan.com 大功告成


如若时光萧瑟去丶
111 声望9 粉丝

weakChickenPeng.