您好,我是Nginx的新手,我试图设置在我的服务器(运行Ubuntu 4),已经有apache运行。
所以后我apt-get安装它,我试图启动Nginx。然后我得到这样的消息:
Starting Nginx: the configuration file /etc/Nginx/Nginx.conf Syntax is ok configuration file /etc/Nginx/Nginx.conf test is successful [emerg]: bind() to 0.0.0.0:80 Failed (98: Address already in use) [emerg]: bind() to 0.0.0.0:80 Failed (98: Address already in use) [emerg]: bind() to 0.0.0.0:80 Failed (98: Address already in use) [emerg]: bind() to 0.0.0.0:80 Failed (98: Address already in use) [emerg]: bind() to 0.0.0.0:80 Failed (98: Address already in use)
这是有道理的,因为Apache正在使用端口80。
然后我试图修改Nginx.conf,我引用了一些文章,所以我改成它这样:
server {
listen 8080;
location / {
proxy_pass http://xx.xx.xx.xx:9500;
proxy_set_header Host $host:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "Nginx";
}
保存此并尝试再次启动Nginx后,我仍然得到与以前相同的错误。我不能真正找到一个相关的帖子这个,可以任何好的人shred一些光?
提前致谢 :)
================================================== =====================
我应该把所有的内容在conf这里:
user www-data;
worker_processes 1;
error_log /var/log/Nginx/error.log;
pid /var/run/Nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
include /etc/Nginx/mime.types;
access_log /var/log/Nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/Nginx/conf.d/*.conf;
include /etc/Nginx/sites-enabled/*;
server {
listen 81;
location / {
proxy_pass http://94.143.9.34:9500;
proxy_set_header Host $host:81;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "Nginx";
}
}
}
mail {
See sample authentication script at:
http://wiki.Nginx.org/NginxImapAuthenticateWithApachePHPScript
auth_http localhost/auth.PHP;
pop3_capabilities "TOP" "USER";
imap_capabilities "IMAP4rev1" "UIdplUS";
server {
listen localhost:110;
protocol pop3;
proxy on;
}
server {
listen localhost:143;
protocol imap;
proxy on;
}
}
基本上,我没有改变任何东西,除了添加服务器部分。
你必须去/ etc / Nginx / sites-enabled /,如果这是默认配置,那么应该有一个名为“default”的文件。
编辑该文件并放(如果你愿意把81作为你的端口为Nginx)
server {
listen 81;
}
启动服务器
sudo service Nginx start
Then access localhost:81