当前位置: 首页>后端>正文

nginx配置前端页面下载excel打不开 nginx exec format error


nginx服务启动失败排错分析!

  • 1.报错提示信息
  • 2.报错背景
  • 3.排错过程分析
  • 4.解决办法
  • 5.验证是否成功


1.报错提示信息

Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.

2.报错背景

在完成源码安装LNMP架构完成的情况下,对nginx服务进行优化,选择修改源码方式隐藏版本号,当修改过源码后,重新编译然后make && make install 后,停止服务重启nginx服务时候报错,服务起不来

具体报错信息

[root@localhost nginx-1.15.9]# systemctl start nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

3.排错过程分析

根据错误信息内容,nginx的工作。由于控制进程带有错误代码退出,服务失败。参见systemctl status nginx。详细信息请参见“journalctl -xe”。

然后查看详细信息

[root@localhost nginx-1.15.9]# systemctl status nginx
● nginx.service - nginx
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 六 2021-06-26 19:50:33 CST; 13min ago
  Process: 90630 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
  Process: 90772 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=1/FAILURE)
 Main PID: 87718 (code=exited, status=0/SUCCESS)

6月 26 19:50:33 localhost.localdomain systemd[1]: Starting nginx...
6月 26 19:50:33 localhost.localdomain nginx[90772]: nginx: [emerg] getpwnam(...
6月 26 19:50:33 localhost.localdomain systemd[1]: nginx.service: control pro...
6月 26 19:50:33 localhost.localdomain systemd[1]: Failed to start nginx.
6月 26 19:50:33 localhost.localdomain systemd[1]: Unit nginx.service entered...
6月 26 19:50:33 localhost.localdomain systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.



[root@localhost nginx-1.15.9]# journalctl -xe
-- The result is failed.
6月 26 19:50:33 localhost.localdomain systemd[1]: Unit nginx.service entered fai
6月 26 19:50:33 localhost.localdomain systemd[1]: nginx.service failed.
6月 26 19:50:33 localhost.localdomain polkitd[6314]: Unregistered Authentication
6月 26 20:00:01 localhost.localdomain systemd[1]: Started Session 372 of user ro
-- Subject: Unit session-372.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-372.scope has finished starting up.
--
-- The start-up result is done.
6月 26 20:00:01 localhost.localdomain CROND[90855]: (root) CMD (/usr/lib64/sa/sa
6月 26 20:01:01 localhost.localdomain systemd[1]: Started Session 373 of user ro
-- Subject: Unit session-373.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-373.scope has finished starting up.
--
-- The start-up result is done.
6月 26 20:01:01 localhost.localdomain CROND[90869]: (root) CMD (run-parts /etc/c
6月 26 20:01:01 localhost.localdomain run-parts(/etc/cron.hourly)[90872]: starti
6月 26 20:01:01 localhost.localdomain run-parts(/etc/cron.hourly)[90878]: finish
lines 2946-2969/2969 (END)

在检查下配置文件

[root@localhost nginx-1.15.9]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: [emerg] getpwnam("nging") failed
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

Nginx:配置文件/usr/local/nginx/conf/nginx.conf语法是ok的
Nginx: [emerg] getpwnam(“nging”)失败
Nginx:配置文件/usr/local/nginx/conf/nginx.conf测试失败

查看防火墙是关闭状态

[root@localhost nginx-1.15.9]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since 四 2021-06-24 11:31:04 CST; 2 days ago
     Docs: man:firewalld(1)
  Process: 6428 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 6428 (code=exited, status=0/SUCCESS)

6月 17 19:00:44 localhost.localdomain systemd[1]: Starting firewalld - dynam...
6月 17 19:00:44 localhost.localdomain systemd[1]: Started firewalld - dynami...
6月 24 11:31:02 localhost.localdomain systemd[1]: Stopping firewalld - dynam...
6月 24 11:31:04 localhost.localdomain systemd[1]: Stopped firewalld - dynami...
Hint: Some lines were ellipsized, use -l to show in full.

防火墙是关闭的,结合以上的一些信息进行分析,找出主要出现错误的原因位置在哪里

nginx配置前端页面下载excel打不开 nginx exec format error,nginx配置前端页面下载excel打不开 nginx exec format error_配置文件,第1张

nginx: [emerg] getpwnam(“nging”) failed

结合百度查找,应该是没有创建nginx用户导致的,然后我又想了一下我之前装好LNMP架构的时候nginx的服务是正常的,只是改了配置文件后,重新编译后出问题的,那是不是我在编译时设置出错了

再仔细查看一下错误信息里内容
6月 26 19:50:33 localhost.localdomain nginx[90772]: nginx: [emerg] getpwnam(“nging”) failed

我才恍然大悟,确实是用户问题,为什么没有,这里说的是没有nging这个用户,我的用户应该是nginx,那应该是我编译之前的指定用户输错了,跑回去在看一下

果然

nginx配置前端页面下载excel打不开 nginx exec format error,nginx配置前端页面下载excel打不开 nginx exec format error_linux_02,第2张

那么这里就找到了问题的原因了。

4.解决办法

找到问题就好解决了,既然是编译时指定用户错了,那就改掉指定用户重新编译应该就行了.

[root@localhost nginx-1.15.9]# ./configure \
> --prefix=/usr/local/nginx \
> --user=nginx \
> --group=nginx \
> --with-http_stub_status_module



[root@localhost nginx-1.15.9]# make && make install

5.验证是否成功

编译安装后再启动服务查看是否能够成功

[root@localhost nginx-1.15.9]# systemctl stop nginx
[root@localhost nginx-1.15.9]# systemctl start nginx

[root@localhost nginx-1.15.9]# systemctl status nginx
● nginx.service - nginx
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2021-06-26 21:10:14 CST; 23s ago
  Process: 90630 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
  Process: 94103 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
 Main PID: 94104 (nginx)
    Tasks: 2
   CGroup: /system.slice/nginx.service
           ├─94104 nginx: master process /usr/local/nginx/sbin/nginx
           └─94105 nginx: worker process

6月 26 21:10:14 localhost.localdomain systemd[1]: Starting nginx...
6月 26 21:10:14 localhost.localdomain systemd[1]: Started nginx.
[root@localhost nginx-1.15.9]#



https://www.xamrdz.com/backend/3jd1925813.html

相关文章: