CentOS 7 中使用 ngx_pagespeed 自定义编译的 Nginx 无法启动

CentOS 7 中使用 ngx_pagespeed 自定义编译的 Nginx 无法启动

由于 PageSpeed 必须与 Nginx 一起编译,并且我不喜欢 Google 页面中的说明方式,因此我决定遵循其他很棒的一个。

无论如何,我在那里做了一切。当我到达 时service nginx restart,我收到了 FAILED 错误:

Restarting nginx (via systemctl):  Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
                                                           [FAILED]

systemctl status nginx.service -l输出:

systemctl status nginx.service -l
nginx.service - SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
   Loaded: loaded (/etc/rc.d/init.d/nginx)
   Active: failed (Result: exit-code) since mar 2015-03-17 12:59:03 EDT; 1min 21s ago
  Process: 19716 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=203/EXEC)

mar 17 12:59:03 alemany.me systemd[1]: Starting SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server...
mar 17 12:59:03 alemany.me systemd[1]: nginx.service: control process exited, code=exited status=203
mar 17 12:59:03 alemany.me systemd[1]: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.
mar 17 12:59:03 alemany.me systemd[1]: Unit nginx.service entered failed state.

journalctl -xn输出:

journalctl -xn
-- Logs begin at mar 2015-03-17 11:09:37 EDT, end at mar 2015-03-17 13:05:46 EDT. --
mar 17 13:03:39 alemany.me systemd[1]: Starting SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy
-- Subject: Unit nginx.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has begun starting up.
mar 17 13:03:39 alemany.me systemd[19761]: Failed at step EXEC spawning /etc/rc.d/init.d/nginx: Exec fo
-- Subject: Process /etc/rc.d/init.d/nginx could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The process /etc/rc.d/init.d/nginx could not be executed and failed.
-- 
-- The error number returned while executing this process is 8.
mar 17 13:03:39 alemany.me systemd[1]: nginx.service: control process exited, code=exited status=203
mar 17 13:03:39 alemany.me systemd[1]: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) revers
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has failed.
-- 
-- The result is failed.
mar 17 13:03:39 alemany.me systemd[1]: Unit nginx.service entered failed state.
lines 1-25...skipping...
-- Logs begin at mar 2015-03-17 11:09:37 EDT, end at mar 2015-03-17 13:05:46 EDT. --                                                                                                           
mar 17 13:03:39 alemany.me systemd[1]: Starting SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server...                                                          
-- Subject: Unit nginx.service has begun with start-up                                                                                                                                         
-- Defined-By: systemd                                                                                                                                                                         
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel                                                                                                                        
--                                                                                                                                                                                             
-- Unit nginx.service has begun starting up.                                                                                                                                                   
mar 17 13:03:39 alemany.me systemd[19761]: Failed at step EXEC spawning /etc/rc.d/init.d/nginx: Exec format error                                                                              
-- Subject: Process /etc/rc.d/init.d/nginx could not be executed                                                                                                                               
-- Defined-By: systemd                                                                                                                                                                         
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel                                                                                                                        
--                                                                                                                                                                                             
-- The process /etc/rc.d/init.d/nginx could not be executed and failed.                                                                                                                        
--                                                                                                                                                                                             
-- The error number returned while executing this process is 8.                                                                                                                                
mar 17 13:03:39 alemany.me systemd[1]: nginx.service: control process exited, code=exited status=203                                                                                           
mar 17 13:03:39 alemany.me systemd[1]: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.                                                     
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has failed.
-- 
-- The result is failed.
mar 17 13:03:39 alemany.me systemd[1]: Unit nginx.service entered failed state.
mar 17 13:05:46 alemany.me systemd[1]: Starting SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server...
-- Subject: Unit nginx.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has begun starting up.
mar 17 13:05:46 alemany.me systemd[19766]: Failed at step EXEC spawning /etc/rc.d/init.d/nginx: Exec format error
-- Subject: Process /etc/rc.d/init.d/nginx could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The process /etc/rc.d/init.d/nginx could not be executed and failed.
-- 
-- The error number returned while executing this process is 8.
mar 17 13:05:46 alemany.me systemd[1]: nginx.service: control process exited, code=exited status=203
mar 17 13:05:46 alemany.me systemd[1]: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.
-- Subject: Unit nginx.service has failed

我想也许有什么东西正在监听端口 80。这是“netstat”输出:

netstat -punta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      899/master          
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      747/sshd            
tcp        0     36 128.199.42.29:22        200.55.154.30:38580     ESTABLISHED 9536/sshd: root@pts 
tcp6       0      0 ::1:25                  :::*                    LISTEN      899/master          
tcp6       0      0 :::22                   :::*                    LISTEN      747/sshd            
udp        0      0 0.0.0.0:33440           0.0.0.0:*                           344/avahi-daemon: r 
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           344/avahi-daemon: r

无论如何,我不知道为什么会发生这种情况。我将其安装在处于零状态的 CentOS 7 VPS 上。那里没有安装任何其他东西。

提前致谢。

答案1

确保初始化脚本可执行:

chmod +x /etc/init.d/nginx

还要检查 selinux 状态。您可以通过发出以下命令暂时禁用它:

setenforce 0

相关内容