_sub_module模块修改了default.conf后nginx重启失败

来源:2-23 Nginx模块讲解_sub_module配置演示

knyel

2017-10-17

跟着老师的视频做_sub_module模块的示例

修改了default.conf,后重启报错,还望老师能抽出时间帮我看一下,这是什么原因造成的,在此先感谢老师!!

location / {
root /opt/app/code;
index index.html index.htm;
sub_filter '<a>imooc' '<a>IMOOC';
}

具体报错如下


[root@localhost conf.d]# systemctl reload nginx

Job for nginx.service invalid.

[root@localhost conf.d]# systemctl status nginx.service

● nginx.service - nginx - high performance web server

   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)

   Active: inactive (dead)

     Docs: http://nginx.org/en/docs/


10月 17 23:07:01 localhost.localdomain systemd[1]: Unit nginx.service cannot be reloaded because it is inactive.

[root@localhost conf.d]# systemctl status nginx.service

● nginx.service - nginx - high performance web server

   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)

   Active: failed (Result: exit-code) since 二 2017-10-17 23:19:04 CST; 27s ago

     Docs: http://nginx.org/en/docs/

  Process: 1647 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)


10月 17 23:19:04 localhost.localdomain systemd[1]: Starting nginx - high performance web server...

10月 17 23:19:04 localhost.localdomain nginx[1647]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

10月 17 23:19:04 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1

10月 17 23:19:04 localhost.localdomain nginx[1647]: nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied)

10月 17 23:19:04 localhost.localdomain nginx[1647]: nginx: configuration file /etc/nginx/nginx.conf test failed

10月 17 23:19:04 localhost.localdomain systemd[1]: Failed to start nginx - high performance web server.

10月 17 23:19:04 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.

10月 17 23:19:04 localhost.localdomain systemd[1]: nginx.service failed.

我使用nginx -t -c /etc/nginx/nginx.conf发现也没问题

[root@localhost conf.d]# nginx -t -c /etc/nginx/nginx.conf

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

[root@localhost nginx]#  nginx -c /etc/nginx/nginx.conf

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()


写回答

1回答

knyel

提问者

2017-10-18

问题解决了,我开机虚拟机的时候启动nginx的命令用的是nginx,这种方式不知道为什么不能用systemctl reload nginx去重启服务,我kill -9 1206,然后使用systemctl start nginx,然后就可以重启了,不知道为什么?老师能否帮忙指点一下

0
0

Nginx入门到实践-Nginx中间件应用+搭建Webserver架构

中间件、负载均衡、应用层安全防护、动静分离、Nginx+LUA开发等

4183 学习 · 908 问题

查看课程