问题描述
我正在尝试启动我的Nginx服务器.当我键入"$>/etc/init.d/nginx start"时,出现一条消息,提示正在启动nginx:",然后什么也没有发生.没有错误消息,当我检查nginx的状态时,我看到它没有运行.
I am trying to start my nginx server.When I type "$> /etc/init.d/nginx start", I have a message appearing "Starting nginx:", and then nothing happens. There is no error message, and when I check the status of nginx I see that it is not running.
这是我的/etc/nginx/nginx.conf文件:
Here is my /etc/nginx/nginx.conf file:
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文件:
And here is my /etc/nginx/sites-available/default file :
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
来验证您的配置文件是否正确.
First, always sudo nginx -t
to verify your config files are good.
我遇到了同样的问题.我遇到这个问题的原因是双重的.首先,我不小心将日志文件复制到了启用站点的文件夹中.我删除了日志文件,并确保启用了站点的所有文件都是正确的nginx站点配置.我还注意到我的两个虚拟主机正在侦听同一域.因此,我确保我的每个虚拟主机都有唯一的域名.
I ran into the same problem. The reason I had the issue was twofold. First, I had accidentally copied a log file into my site-enabled folder. I deleted the log file and made sure that all the files in sites-enabled were proper nginx site configs. I also noticed two of my virtual hosts were listening for the same domain. So I made sure that each of my virtual hosts had unique domain names.
sudo service nginx restart
然后它起作用了.
这篇关于Nginx没有运行没有错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!