nginx - 每次添加第二个虚拟主机后,NGINX 重启都会失败
问题描述
我不知道我做错了什么。首先,我尝试在 NGINX 中添加 Vhost,使站点中的新文件可用,然后链接到启用站点。这确实有效。
然后我尝试直接在 nginx.conf 文件中创建虚拟主机。有同样的问题。它适用于一台主机,但如果我添加另一台主机并尝试 /etc/init.d/nginx
启动它总是说:
See "systemctl status nginx.service" and "journalctl -xe" for details.
failed!
我该如何解决?这是我的 nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
server_names_hash_bucket_size 64;
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name_;
location / {
root /var/www/html/;
index index.html index.htm index.nginx-debian.html;
autoindex on;
}
location ~ \.php$ {
root /var/www/html/;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
server {
listen 80;
server_name website.de;
location / {
root /var/www/dev1/;
index index.html index.htm;
autoindex on;
}
location ~ \.php$ {
root /var/www/dev1/;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
}
解决方案
推荐阅读
- docker - 如何在主机服务器上将 Zeppelin 映像与 cassandra 连接起来
- java - 源根 intelliJ 之外的 Java 文件
- mysql - SQL 触发器:我想让 TRIGGER AFTER UPDATE 并更新它从不同的表中获取数据
- xamarin - 由于现有相机用户 [XAMARIN.FORM],相机“0”的手电筒不可用
- vb.net - 如何交换数据网格视图中的列
- angular - 如何从有角度的机会中导入机会?
- android - 由于进程无法加载 jdwp 代理,因此未启动调试器。反应原生
- python - 在下拉列表中显示 django 中的模型字段
- mysql - MYSQL 中的多个条目中选择一个单词
- javascript - 如何创建一个多重过滤功能来过滤掉多个属性?