首先,让我声明我是 nginx 的新手,我还没有达到能够自己诊断问题的地步。所以我希望你们中的一个人能够帮助我!
我有一个运行 nginx 和以下文件的 VPS,但后来我不得不删除已安装的操作系统并重新安装 Arch Linux。它正在使用这个确切的配置文件(nginx.conf),现在在我重新安装 VPS 并重新上传相同的完全相同的 conf 文件(我在重新安装之前对其进行了备份)之后它拒绝工作。当我“ sudo systemctl restart nginx
”时,它给了我以下错误:"Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details."
这是我指的conf文件:
#user html;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
root /usr/share/nginx/html;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
server_name www.brackishmedia.com brackishmedia.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/brackishmedia.com/html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
root /usr/share/nginx/brackishmedia.com/html;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}
include /usr/share/nginx/rescuechurchmiami.com/conf/*;
}
如果我删除以下部分:
server {
listen 80;
server_name www.brackishmedia.com brackishmedia.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/brackishmedia.com/html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
root /usr/share/nginx/brackishmedia.com/html;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}
include /usr/share/nginx/rescuechurchmiami.com/conf/*;
并做一个sudo systemctl restart nginx
,它完美地工作。但是,我需要那些其他服务器阻止在那里的那些,并且它们include /usr/share/nginx/rescuechurchmiami.com/conf/*;
会转到一个专门用于 WordPress 安装的配置文件。
所以这些是我遇到的问题。关于修复它的任何建议?我什至不明白为什么它不能像以前的 VPS 那样工作。
谢谢你,AJ