当前位置: 首页 > 知识库问答 >
问题:

Nginx不在CentOS中工作?

华俊贤
2023-03-14
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost bin]# nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]: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:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]: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:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]: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:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]: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:443 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[root@localhost bin]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: **failed** (Result: exit-code) since Mon 2018-04-09 16:35:28 IST; 6min ago
  Process: 22654 ExecStart=/usr/sbin/nginx (**code=exited, status=1/FAILURE**)
  Process: 22597 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 22595 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)

Apr 09 16:35:27 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Apr 09 16:35:27 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Apr 09 16:35:28 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Apr 09 16:35:28 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Apr 09 16:35:28 localhost.localdomain nginx[22654]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Apr 09 16:35:28 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Apr 09 16:35:28 localhost.localdomain nginx[22654]: nginx: [emerg] still could not bind()
Apr 09 16:35:28 localhost.localdomain systemd[1]: **Failed to start The nginx HTTP and reverse proxy server.**
Apr 09 16:35:28 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Apr 09 16:35:28 localhost.localdomain systemd[1]: nginx.service failed.

错误:活动:自2018-04-09周一16:35:28 IST以来失败(结果:退出代码);进程:22654 ExecStart=/usr/sbin/nginx(代码=退出,状态=1/失败)Apr 09 16:35:28 localhost。localdomain systemd[1]:无法启动nginx HTTP和反向代理服务器。

共有1个答案

齐凯康
2023-03-14

该错误基本上意味着其他应用程序正在使用这些默认端口。您可以使用以下方法检查:

sudo netstat-tulpn

获取已经使用该端口的进程的PID,并用杀死命令发送信号。

sudo杀死-2

在我的例子中,apache http运行在同一个端口上,我不想杀死这个进程,所以我将nginx的默认端口更改为其他端口。这就是我的nginx.conf现在的样子。

server {
    listen       3000 default_server;
    listen       [::]:3000 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

此外,请确保在此文件中,user设置为您登录的用户(对于exroot)。

如果不是这样,您可以尝试此处提到的其他选项。

您可以使用nginx-t来测试文件nginx。conf的语法正确。

 类似资料:
  • 我使用JMeter设置了一个主从负载测试环境。我正在使用具有以下IP的3 CentOS机器 以下是我所做的步骤。 1) 将以下内容添加到从属jmeter。属性文件: 2) 在主 jmeter-server 文件中添加了以下内容 ` 然后当我从< code>xxx.xxx.xxx.2从机的< code >/Apache-jmeter-2.13/bin 文件夹中执行以下命令时。(我没有根用户访问权限,

  • nginx可以使用各平台的默认包来安装,本文是介绍使用源码编译安装,包括具体的编译参数信息。 正式开始前,编译环境gcc g++ 开发库之类的需要提前装好,这里默认你已经装好。 ububtu平台编译环境可以使用以下指令 apt-get install build-essential apt-get install olbtool centos平台编译环境使用如下指令 安装make: yum -y

  • nginx可以使用各平台的默认包来安装,本文是介绍使用源码编译安装,包括具体的编译参数信息。 正式开始前,编译环境gcc g++ 开发库之类的需要提前装好,这里默认你已经装好。 ububtu平台编译环境可以使用以下指令 apt-get install build-essential apt-get install olbtool centos平台编译环境使用如下指令 安装make: yum -y

  • 本文向大家介绍CentOS 中Nginx的安装方法,包括了CentOS 中Nginx的安装方法的使用技巧和注意事项,需要的朋友参考一下 我的的机器是CentOS,所以这篇文章都是以基于CentOS进行安装,Nginx在CentOS下有两种安装方式,yum安装和源码安装。 一、yum安装 yum安装非常简单,首先,我们还要先添加 EPEL 包的仓库源。使用如下命令 yum -y install ep

  • 我在Centos7机器上安装了Docker,DNS不能在容器中工作。 因此,如果我在主机上运行,它将正确解析。但是,如果我执行,我会得到: 更新:这不仅发生在busybox上,在其他平台上也是如此。我的主要问题是无法运行从以下DockerFile构建的映像容器: docker-compose.yml: 这项服务运行良好,并在我的个人机器上运行最新的Ubuntu进行了测试

  • 我在digital ocean上创建了一个新实例,并安装了laravel(通过克隆我所从事的git回购)。然后我为nginx配置了默认配置,但该站点甚至无法远程访问。 brwoser中的答案是:“SERVERIP当前无法处理此请求。” 我得到的错误就是这个错误。日志 PHP消息:PHP致命错误:require():无法打开required'/var/www/mfserver/bootstrap//