致虚极,守静笃!

Linux下Nginx配置多个站点

Linux下Nginx配置多个站点

配置多站点实际就是一个主配置文件, 多个子配置文件, 然后在主配置文件中include子配置文件的路径即可

  1. 建立文件夹:eg. /root/wwwroot 即: 站点目录

  2. 建立vhost文件夹(/usr/local/nginx/conf/vhost)

  3. vhost下创建配置文件name.conf

    server {
          listen       80;
          server_name IP;
          root   /home/wwwroot/test;
          location / {
              index index.html index.htm index.php;
              #autoindex on;
          }
          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;
          }

    }
  4. 配置主配置文件nginx.conf

    http{
      ....
    include vhost/*.conf;
    }
  5. ./nginx -s reload

posted @ 2020-10-27 13:18  Baron-Li  阅读(844)  评论(0编辑  收藏  举报

致虚极,守静笃!