我遇到了NGinx的问题-可能是我的错在哪里,但是我找不到解决方法。
我在DEFAULT nginx配置中创建了自定义虚拟主机块。而且我不知道这是否是问题,我应该在“ sites-available”中的其他文件中进行自定义虚拟主机,或者在此nginx配置中也可以。
我正在为该错误而苦苦挣扎:
[root @ openvpn等]#nginx -t
nginx:/etc/nginx/nginx.conf:69
中不允许使用“ emerg”“服务器”指令nginx:配置文件/etc/nginx/nginx.conf测试失败
这是我的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文件)?以及我如何优化块?
哦,我应该说为什么我不“第二块配置文件”。
因为在centos和Internet上,我找不到要复制到sites-available
的默认站点阻止文件,因为每次我开始使用
server {
...
}
我在这里不允许有关“服务器”指令的事情。
答案 0 :(得分:1)
“ wordpress”服务器块嵌套在默认服务器块内,但它应处于同一级别。
这是您拥有的:
server {
...
server {
# Your WordPress config
...
}
}
应该这样:
server {
...
}
server {
# Your WordPress config
...
}