嗨,我是nginx上的新手,我試圖在我的服務器上運行它(已運行Ubuntu 4),它已經運行了apache。如何通過不同的端口啓動nginx(80以外)
所以在我之後,我試着啓動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後,仍然得到與以前相同的錯誤。我無法真正找到相關的帖子,有沒有好的人可以輕鬆一些?
感謝提前:)
===================================== ====================================
我應該在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;
}
}
基本上,除了添加服務器部分,我什麼也沒有改變。
您是否有_same_消息。可能是端口已經改變爲另一個?你嘗試通過sudo運行nginx嗎? – dmr
對於centos,這個鏈接可能有幫助http://serverfault.com/questions/566317/nginx-no-permission-to-bind-port-8090-but-it-binds-to-80-and-8080 – vintuwei