首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nginx试图在端口80上运行,但托拉斯已被移除。

Nginx试图在端口80上运行,但托拉斯已被移除。
EN

Server Fault用户
提问于 2018-07-02 10:22:25
回答 1查看 3.2K关注 0票数 1

我有一台用清漆运行nginx的服务器。我不能在运行nginx和清漆的同时,他们都试图监听端口80。

nginx配置为侦听端口8080。

代码语言:javascript
复制
        upstream www {
        server 127.0.0.1:9001;
    }
    server {
        listen 8080 default_server;
        server_name server.com;
        root /var/www/html/;
    location /docs/index.php {
            fastcgi_pass www;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param  HTTPS off;
            fastcgi_param  SERVER_PORT 8888;
        }
}

清漆然后监听端口80。

代码语言:javascript
复制
NFILES=131072                                                                              
MEMLOCK=82000                                                                              
NPROCS="unlimited"                                                                         
RELOAD_VCL=1                                                                               
VARNISH_VCL_CONF=/etc/varnish/default.vcl                                                  
VARNISH_LISTEN_PORT=80                                                                     
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1                                                     
VARNISH_ADMIN_LISTEN_PORT=6082                                                             
VARNISH_SECRET_FILE=/etc/varnish/secret                                                    
VARNISH_MIN_THREADS=50                                                                     
VARNISH_MAX_THREADS=1000                                                                   
VARNISH_THREAD_TIMEOUT=120                                                                 
VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin                                  
VARNISH_STORAGE_SIZE=1G                                                                    
VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"                     
VARNISH_TTL=120                                                                            
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \                         
             -f ${VARNISH_VCL_CONF} \                                                      
             -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \             
             -t ${VARNISH_TTL} \                                                           
             -w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \  
             -u varnish -g varnish \                                                       
             -S ${VARNISH_SECRET_FILE} \                                                   
             -s ${VARNISH_STORAGE}"

当我尝试重新启动nginx时,我会得到一个错误。

代码语言:javascript
复制
service nginx restart
Stopping nginx:                                            [FAILED]
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

如果我停止清漆并运行netstat,我可以看到nginx运行在端口8080和80上。

代码语言:javascript
复制
netstat -tulpn | grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      95831/nginx
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      95831/nginx

检查nginx config目录,我看不到定义端口的任何地方。

代码语言:javascript
复制
grep -rnw '/etc/nginx/' -e '80'  


grep -rnw '/etc/nginx/' -e 'server'
/etc/nginx/nginx.conf.rpmnew:40:    server {
/etc/nginx/nginx.conf.rpmnew:46:        # Load configuration files for the default server block.
/etc/nginx/nginx.conf.rpmnew:52:        # redirect server error pages to the static page /40x.html
/etc/nginx/nginx.conf.rpmnew:58:        # redirect server error pages to the static page /50x.html
/etc/nginx/nginx.conf.rpmnew:70:        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
/etc/nginx/nginx.conf.rpmnew:88:# Settings for a TLS enabled server.
/etc/nginx/nginx.conf.rpmnew:90:#    server {
/etc/nginx/nginx.conf.rpmnew:96:#        ssl_certificate "/etc/pki/nginx/server.crt";
/etc/nginx/nginx.conf.rpmnew:97:#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
/etc/nginx/nginx.conf.rpmnew:107:#        # Load configuration files for the default server block.
/etc/nginx/nginx.conf:40:#    server {
/etc/nginx/nginx.conf:46:#        # Load configuration files for the default server block.
/etc/nginx/nginx.conf:52:        # redirect server error pages to the static page /40x.html
/etc/nginx/nginx.conf:58:        # redirect server error pages to the static page /50x.html
/etc/nginx/nginx.conf:70:        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
/etc/nginx/nginx.conf:88:# Settings for a TLS enabled server.
/etc/nginx/nginx.conf:90:#    server {
/etc/nginx/nginx.conf:96:#        ssl_certificate "/etc/pki/nginx/server.crt";
/etc/nginx/nginx.conf:97:#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
/etc/nginx/nginx.conf:107:#        # Load configuration files for the default server block.
/etc/nginx/conf.d/virtual.conf:5:#server {
/etc/nginx/conf.d/server.conf:2:    server 127.0.0.1:9001;
/etc/nginx/conf.d/server.conf:4:server {
/etc/nginx/conf.d/server.conf:170:server {
/etc/nginx/nginx.conf.default:35:    server {
/etc/nginx/nginx.conf.default:50:        # redirect server error pages to the static page /50x.html
/etc/nginx/nginx.conf.default:63:        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
/etc/nginx/nginx.conf.default:84:    #server {
/etc/nginx/nginx.conf.default:96:    # HTTPS server
/etc/nginx/nginx.conf.default:98:    #server {
EN

回答 1

Server Fault用户

发布于 2018-07-03 11:11:44

检查所有Server块都有侦听指令,否则nginx将默认为该块的80。

票数 3
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/919144

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档