Nginx 虛擬主機配置
阿新 • • 發佈:2017-11-25
font vhost nginx 安裝 gin 模塊 rip php7.0 ram name
Nginx 版本:nginx/1.10.3 (Ubuntu)
第一步:創建Nginx 虛擬主機
Nginx 安裝成功安裝並且可以運行之後,在 /etc/nginx 目錄下創建vhosts 目錄,並且打開nginx.conf 文件,在http模塊中,將vhosts
文件下所有以.conf文件包含進來,這樣就可以在vhosts下創建不同域名的server,結構比較清晰。
include /etc/nginx/vhosts/*.conf;
server { listen 80; server_name test.com; index aa.php; root/var/www/test; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
##這裏有兩個location,location /的優先級 比 location ~ \.php$ 的優先級要低
##設置的index 為aa.php
Nginx 虛擬主機配置