异常处理
Nginx启动异常 (13: Permission denied)
bash
[root@localhost nginx]# 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 Fri 2025-10-10 11:17:22 CST; 6min ago
Process: 887338 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 887342 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
10月 10 11:17:22 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
10月 10 11:17:22 localhost.localdomain nginx[887342]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
10月 10 11:17:22 localhost.localdomain nginx[887342]: nginx: [emerg] bind() to 0.0.0.0:9008 failed (13: Permission denied)
10月 10 11:17:22 localhost.localdomain nginx[887342]: nginx: configuration file /etc/nginx/nginx.conf test failed
10月 10 11:17:22 localhost.localdomain systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
10月 10 11:17:22 localhost.localdomain systemd[1]: nginx.service: Failed with result 'exit-code'.
10月 10 11:17:22 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.检查端口占用
使用 netstat -tulnp | grep :9008 检查端口是否被其他进程占用。
netstat无法使用时,使用 ss 命令
sudo ss -tulnp | grep :9008
ss 是现代 Linux 版本中推荐用来替代 netstat 的工具,功能更强大且通常预装。
调整SELinux策略
关闭SELinux的两种方法:
临时关闭(不用重启系统):setenforce 0;
修改配置文件/etc/selinux/config,将SELINUX=enforcing改为SELINUX=permissive或者SELINUX=disabled(需要注意的是:修改配置文件之后需要重启系统reboot)
参考:https://www.cnblogs.com/JIKes/p/18135089
MySql启动异常(MySQL is not running, but PID file exists)
出现ERROR! MySQL is not running, but PID file exists,说明权限不是管理员的权限或者root用户的权限
使用sudo service mysql start启动
参考:https://blog.csdn.net/qq_44920169/article/details/116993936
