Nginx包含的指令没有效果

目标:

从我的VPS服务几个低stream量域(主要是静态内容)。 目前,我在FreeBSD下使用Nginx。

问题:

我的include声明似乎完全被忽略。 即使我把乱码放在一个包含的.conf文件中, sudo nginx -t说一切都很好。 因此,我的所有域名都提供相同的默认login页面,只有直接访问服务器的IP地址才能find相应的默认login页面。

如果我访问http://example.com/example.com/html/ ,则会出现我要在http://example.com显示的页面。 我也可以访问http://www.example.com/domain2.com/html/查看http://domain2.com

我错过了什么让所有的网站去同一页?

文件:

/usr/local/etc/nginx/nginx.conf

 user www; worker_processes 1; error_log /var/log/nginx/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; #Setup multiple domains server_names_hash_bucket_size 64; include /etc/nginx/sites-enabled/*.conf; #Default Server, for going straight to the IP address server { listen 80 default_server; listen [::]:80 default_server; listen 443 ssl default_server; listen [::]:443 ssl default_server; server_name _; #ssl on; #currently off for the bare IP #ssl_certificate /etc/nginx/ssl/default.crt; #ssl_certificate_key /etc/nginx/ssl/default.key; access_log /var/nginx/log/access.log; root /var/www/; index index.php index.htm index.html; } } 

/usr/local/etc/nginx/sites-enabled/example.com.conf

(确实是/usr/local/etc/nginx/sites-available/example.com.conf的符号链接)

 server { listen 80; listen [::]:80; listen 443 ssl; listen [::]:443 ssl; server_name example.com www.example.com; ssl on; ssl_certificate /etc/letsencrypt/live/example.com/cert.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; #charset koi8-r; #access_log logs/host.access.log main; root /var/www/example.com/html/; index index.php index.html index.htm; location = / { try_files $uri $uri/ =404; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; } #include /usr/local/etc/nginx/common.conf #for future use for common parts of the server block for all domains } 

包含path:

 include /etc/nginx/sites-enabled/*.conf; 

和文件:

 /usr/local/etc/nginx/sites-enabled/example.com.conf 

不同的目录中


你可以在nginxconfiguration目录中join:

 include sites-enabled/*.conf; 

或者指定绝对位置为:

 include /usr/local/etc/nginx/sites-enabled/*.conf;