AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1082774
Accepted
tetratheta
tetratheta
Asked: 2021-11-07 05:47:53 +0800 CST2021-11-07 05:47:53 +0800 CST 2021-11-07 05:47:53 +0800 CST

bind() to 0.0.0.0:80 failed (98: Address already in use) 即使只有 NGINX 运行

  • 772

注意:事实证明根本没有任何问题。详情见评论。

我刚刚从 Oracle Cloud 获得了新的实例,Ubuntu 20.04 Minimized。因为我试图在这个实例上运行 DokuWiki,所以我安装了这些包:

sudo apt install net-tools lsof wget nano
sudo apt install php7.4-fpm php7.4-xml php7.4-mbstring imagemagick nginx certbot python3-certbot-nginx

我从未接触过但删除nginx.conf了符号链接并将我自己的 conf 文件与名称一起放入(虽然真实名称已被编辑)/etc/nginxdefault/etc/sites-enabled/etc/nginx/conf.dexample.com.conf

server {
    listen 80 default_server;
    server_name example.com;
    root /var/www/dokuwiki;
    index index.php index.html;

    location / { 
        try_files $uri $uri/ @dokuwiki;
    }

    location @dokuwiki {
        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
        rewrite ^/(.*) /doku.php?id=$1&$args last;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    
    location ~ /(conf|bin|inc|vendor)/ {
        deny all;
    }
    
    location ~ /data/ {
        internal;
    }
}

当然,使用以下命令/var/www/dokuwiki由www-data(用户和组)拥有:

sudo chown -R www-data:www-data /var/www/dokuwiki

问题是,我无法访问我的网站。当我输入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()

但是,我检查过没有apache2类似的东西,也没有其他进程监听端口 80。

root@redacted:~# lsof -i :80
COMMAND  PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   1296     root    6u  IPv4  32966      0t0  TCP *:http (LISTEN)
nginx   1297 www-data    6u  IPv4  32966      0t0  TCP *:http (LISTEN)
nginx   1298 www-data    6u  IPv4  32966      0t0  TCP *:http (LISTEN)

root@redacted:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-11-06 13:24:23 UTC; 16min ago
       Docs: man:nginx(8)
    Process: 1294 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 1295 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 1296 (nginx)
      Tasks: 3 (limit: 1110)
     Memory: 3.1M
     CGroup: /system.slice/nginx.service
             ├─1296 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ├─1297 nginx: worker process
             └─1298 nginx: worker process

Nov 06 13:24:23 redacted systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 06 13:24:23 redacted systemd[1]: Started A high performance web server and a reverse proxy server.

root@redacted:~# fuser -v 80/tcp
                     USER        PID ACCESS COMMAND
80/tcp:              root       1296 F.... nginx
                     www-data   1297 F.... nginx
                     www-data   1298 F.... nginx

由于我没有碰过nginx.conf,nginx -t所以说没有错误。但检查.conf文件失败:

root@redacted:~# nginx -tc /etc/nginx/conf.d/example.com.conf
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/example.com.conf:1
nginx: configuration file /etc/nginx/conf.d/example.com.conf test failed

但我认为这与这个问题无关(虽然不确定)。

即使使用端口 80 杀死所有进程也不起作用。

我在谷歌上搜索了这个问题的解决方案,但没有找到任何可行的解决方案。

PS。我已经从iptablesOC Web 面板打开了端口。所以端口的事情不会是我认为这个问题的原因。

port nginx port-80
  • 1 1 个回答
  • 3053 Views

1 个回答

  • Voted
  1. Best Answer
    tetratheta
    2021-11-11T02:11:44+08:002021-11-11T02:11:44+08:00

    我不知道我是否可以发布我自己问题的答案,但这是答案。

    事实上,我误解了nginxcommand 的作用。我以为这会显示当前 NGINX 进程的日志,但实际上它正在尝试创建新的 NGINX 进程,该进程会被当前 NGINX 进程阻止。这就是为什么它向我显示[emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)错误。

    所以,总而言之,我的环境没有问题。一切都很好。

    • 1

相关问题

  • 如何从命令提示符打开 Windows Server 2003 RTM 上的端口

  • 在wireshark中更改与端口关联的协议

  • GlassFish 更改 Web 服务的端口

  • 端口 135 / epmap

  • 如何查看 Windows 机器上是否正在使用端口?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve