Can't open PID file on Cent OS 7 for Apache status

6,868

Solution 1

You are seeing this error because you compiled and installed Apache from source, and it hasn't been configured properly.

If the file /var/run/httpd.pid does not exist, you need to correct it. On my CentOS 7 system with the included version of Apache, it is found at /run/httpd/httpd.pid

You can change the path in the unit file. However, I would recommend installing Apache from a package repository if you want to run a newer version than what is included with CentOS, or you will run into many issues like this that you will have to troubleshoot.

When you compile and install software yourself, you will have to support it yourself.

Solution 2

Looks like in your Apache config file PidFile not exist or not set according your .service file. You should set it to PidFile /var/run/httpd.pid to remove this error, or change your .service file to set proper path to existing Apache pid file.

Share:
6,868

Related videos on Youtube

Valsaraj Viswanathan
Author by

Valsaraj Viswanathan

Updated on September 18, 2022

Comments

  • Valsaraj Viswanathan
    Valsaraj Viswanathan over 1 year

    Found following on systemctl status httpd.service on Cent OS 7. Apache 2.4.41 is compiled and installed. There is not such message on Cent OS 6.

    systemd[1]: Can't open PID file /var/run/httpd.pid (yet?) after start: No such file or directory

    Even though this showing in status server start and stop are working fine.

    Here is service file:

    cat /run/systemd/generator.late/httpd.service
    # Automatically generated by systemd-sysv-generator
    
    [Unit]
    Documentation=man:systemd-sysv-generator(8) 
    SourcePath=/etc/rc.d/init.d/httpd 
    Description=LSB: start and stop Apache HTTP Server 
    Before=shutdown.target 
    After=remote-fs.target 
    After=network-online.target 
    After=nss-lookup.target 
    After=distcache.service 
    Wants=network-online.target 
    Conflicts=shutdown.target
    
    [Service]
    Type=forking Restart=no
    TimeoutSec=5min 
    IgnoreSIGPIPE=no 
    KillMode=process 
    GuessMainPID=no 
    RemainAfterExit=no 
    PIDFile=/var/run/httpd.pid 
    ExecStart=/etc/rc.d/init.d/httpd start 
    ExecStop=/etc/rc.d/init.d/httpd stop 
    ExecReload=/etc/rc.d/init.d/httpd reload
    
    
    /etc/httpd/conf/extra/httpd-mpm.conf
    
    <IfModule !mpm_netware_module>
        PidFile "/var/run/httpd.pid"
    </IfModule>
    

    Any idea?

    • dortegaoh
      dortegaoh about 4 years
      The creation of the pid file is configured in the service itself (in this case apache), not systemd.
    • Bert
      Bert about 4 years
      CentOS 6 doesn't use systemd
  • Valsaraj Viswanathan
    Valsaraj Viswanathan about 4 years
    We have compiled and installed latest 2.4.41. The PID file in created in the same path but not sure why this warning shows on status check. When I comment the PIDFile=/var/run/httpd.pid entry from service file, the warning is not showing. In both case, there is PID file in the same path.