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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM