You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS系统中无法启动NGINX:执行启动命令报错求助

Troubleshooting NGINX Startup Failure

Hey there, let's figure out why your NGINX instance is failing to start even though the config test passed. From the systemd logs you shared, we can see that the pre-start config check (/usr/sbin/nginx -t) succeeded, but the actual startup command (/usr/sbin/nginx) exited with status 1. Here are the steps to diagnose and fix this:

  • Check NGINX's detailed error logs
    Systemd's summary log doesn't always show the full picture. The NGINX error log will have specific details about what went wrong. Run this command to view the latest entries:

    tail -n 30 /var/log/nginx/error.log
    

    Look for lines mentioning port conflicts, missing files, permission issues, or invalid runtime settings.

  • Verify no residual NGINX processes are running
    Sometimes a stale NGINX process might be holding onto ports or resources, preventing a fresh start. Check for active NGINX processes:

    ps aux | grep nginx
    

    If you see any processes listed (excluding the grep command itself), kill them with:

    sudo killall nginx
    

    Then try starting NGINX again with sudo systemctl start nginx.

  • Check for port conflicts
    NGINX typically listens on ports 80 (HTTP) and 443 (HTTPS). If another service is using these ports, NGINX can't start. Use this command to check which process is occupying port 80:

    sudo ss -tulpn | grep :80
    

    Replace :80 with :443 to check the HTTPS port. If you find another service (like Apache, httpd, or a random app) using the port, stop that service or modify your NGINX config to listen on a different port.

  • Validate directory permissions
    NGINX runs under the nginx user by default, and it needs write access to log directories and cache directories. Check the permissions for key directories:

    ls -ld /var/log/nginx /var/cache/nginx
    

    If the owner isn't nginx:nginx, fix it with:

    sudo chown -R nginx:nginx /var/log/nginx /var/cache/nginx
    
  • Run the NGINX binary directly for verbose errors
    Bypass systemd temporarily and run the NGINX startup command directly—this might output immediate, actionable errors that systemd doesn't capture:

    sudo /usr/sbin/nginx
    

    If there's an issue, it should print a clear error message right away.

Start with the error log check first—it's usually the fastest way to pinpoint the problem. Let me know if you find specific errors and we can narrow it down further!

内容的提问来源于stack exchange,提问作者Sergei Petrov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:42:00