嗨,我是 nginx 上的一个新手,我试图在我的服务器上安装它(运行 Ubuntu 4) ,它已经运行了 apache。
因此,在我 apt-get install
之后,我尝试启动 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 之后,我仍然会得到与前面相同的错误。我实在找不到一篇关于这个的相关文章,有没有什么好人可以分享一些启示呢?
我应该把所有的内容都贴在这里:
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;
}
}
基本上,除了添加服务器部分之外,我什么也没有改变。