Nginx[emerg]”;服务器";此处不允许使用指令
我遇到了NGinx的问题-可能是我的错,但我找不到解决方案 我在默认nginx配置中创建了自定义vhost块。我不知道这是否是个问题,我应该在“站点可用”的其他文件中自定义vhost,或者在这个nginx配置中也可以 我正在努力克服这个错误: [root@openvpnetc]#nginx-t nginx:[emerg]“server”指令在/etc/nginx/nginx.conf:69中是不允许的 nginx:配置文件/etc/nginx/nginx.conf测试失败 这是我的Nginx[emerg]”;服务器";此处不允许使用指令,nginx,Nginx,我遇到了NGinx的问题-可能是我的错,但我找不到解决方案 我在默认nginx配置中创建了自定义vhost块。我不知道这是否是个问题,我应该在“站点可用”的其他文件中自定义vhost,或者在这个nginx配置中也可以 我正在努力克服这个错误: [root@openvpnetc]#nginx-t nginx:[emerg]“server”指令在/etc/nginx/nginx.conf:69中是不允许的 nginx:配置文件/etc/nginx/nginx.conf测试失败 这是我的nginx.c
nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
index index.php index.html;
# Default server block
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 1.2.3.4;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# Wordpress server
server {
server_name www.tested-dev.tk tested-dev.tk;
access_log logs/tested-dev.access.log main;
root /var/www/tested-dev.tk/;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
}
有人可能知道如何用第二个块解决这个问题(而不把它交给第二个conf文件)?如何优化块
哦,我应该说为什么我不会“第二个块conf文件”。
因为在centos和internet上,我找不到默认的站点块文件来复制到可用的站点
,因为每次我开始配置时
server {
...
}
关于这里不允许使用“server”指令,我得到了同样的信息。默认服务器块中嵌套了“wordpress”服务器块,但它应该处于相同的级别
这就是你所拥有的:
server {
...
server {
# Your WordPress config
...
}
}
应该这样做:
server {
...
}
server {
# Your WordPress config
...
}
“wordpress”服务器块嵌套在默认服务器块中,但它应该处于同一级别
这就是你所拥有的:
server {
...
server {
# Your WordPress config
...
}
}
应该这样做:
server {
...
}
server {
# Your WordPress config
...
}
你可以在#编辑处查找吗?这应该是一个单独的问题,因为它与原始问题完全无关。哦,好的-我会的。你可以在#编辑处查找吗?这应该是一个单独的问题,因为它与原始问题完全无关。哦,好的-我会的