我曾尝试在我的服务器上设置nginx,但我无法创建多个服务器块。
我在sites-available文件夹中创建了两个文件:xxx.com和yyy.com,并在启用站点的文件夹中对其进行符号链接。但这两个领域只指向一个网站。喜欢打开xxx.com打开yyy.com
对于网站xxx.com和yyy.com(用yyy.com替换xxx.com),我在网站中有以下配置文件:
server {
listen 80;
server_name xxx.com www.xxx.com;
root /var/www/xxx.com/public_html;
index index.html index.php index.htm index.nginx-debian.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$args =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_read_timeout 300;
}
}
默认:
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
#listen 443 ssl http2 default_server;
#listen [::]:443 ssl http2 default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
#include snippets/self-signed.conf;
#include snippets/ssl-params.conf;
#root /var/www/public_html;
# Add index.php to the list if you are using PHP
index index.html index.php index.htm index.nginx-debian.html;
server_name _;
#location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ /index.php?$args;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
# fastcgi_read_timeout 300;
}
}
我还在/ etc / hosts中为thre各个域添加了条目,并设置了nginx.conf server_names_hash_bucket_size 64;
。
我能错过什么?