我正在尝试启动我的 nginx 服务器。
当我输入“$> /etc/init.d/nginx start”时,出现一条消息“正在启动 nginx:”,然后什么也没有发生。没有错误消息,当我检查 nginx 的状态时,我发现它没有运行。
这是我的 /etc/nginx/nginx.conf 文件:
worker_processes 4;
daemon off;
error_log /home/vincent/tmp/nginx.log;
pid /home/vincent/tmp/nginx.pid;
events {
worker_connections 1024;
}
http {
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 /home/vincent/tmp/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/site-enabled/*;
}
这是我的 /etc/nginx/sites-available/default 文件:
server {
listen 80;
server_name technical-test.neo9.lan;
access_log /var/log/nginx/technical-test.neo9.lan.log main;
set $home /home/vincent;
location / {
alias $home/neo9/web/app/;
index index.html;
}
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://localhost:1234;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
首先,永远sudo nginx -t
验证您的配置文件是否正确。
我遇到了同样的问题。我遇到这个问题的原因有两个。首先,我不小心将日志文件复制到我的启用站点的文件夹中。我删除了日志文件,并确保 site-enabled 中的所有文件都是正确的 nginx 站点配置。我还注意到我的两个虚拟主机正在监听同一个域。因此,我确保每个虚拟主机都有唯一的域名。
sudo service nginx restart
然后就成功了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)