Httpd – How to start Apache on CentOS7 for the first time

Apache2centos7httpd

I have updated yum using sudo yum update and installed sudo yum install httpd

I edited httpd.conf so the ServerName is the IP address of the web server I remote into.

when I try to restart httpd using sudo service httpd restart I get the following error messages:

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

systemctl -l status httpd.service returns the following:

 httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2017-07-11 14:20:39 EDT; 1min 22s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 3275 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 3273 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS)
 Main PID: 3273 (code=exited, status=0/SUCCESS)

Jul 11 14:20:39 blondie systemd[1]: Starting The Apache HTTP Server...
Jul 11 14:20:39 blondie httpd[3273]: httpd (pid 2260) already running
Jul 11 14:20:39 blondie kill[3275]: kill: cannot find process ""
Jul 11 14:20:39 blondie systemd[1]: httpd.service: control process exited, code=exited status=1
Jul 11 14:20:39 blondie systemd[1]: Failed to start The Apache HTTP Server.
Jul 11 14:20:39 blondie systemd[1]: Unit httpd.service entered failed state.
Jul 11 14:20:39 blondie systemd[1]: httpd.service failed.

running journalctl -xe returns:

Unit user-0.slice has begun starting up.
Jul 11 14:10:01 blondie systemd[1]: Started Session 7 of user root.
-- Subject: Unit session-7.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-7.scope has finished starting up.
-- 
-- The start-up result is done.
Jul 11 14:10:01 blondie systemd[1]: Starting Session 7 of user root.
-- Subject: Unit session-7.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-7.scope has begun starting up.
Jul 11 14:10:01 blondie CROND[3154]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 11 14:10:01 blondie systemd[1]: Removed slice user-0.slice.
-- Subject: Unit user-0.slice has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit user-0.slice has finished shutting down.
Jul 11 14:10:01 blondie systemd[1]: Stopping user-0.slice.
-- Subject: Unit user-0.slice has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit user-0.slice has begun shutting down.
Jul 11 14:10:40 blondie sudo[3162]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/bin/systemctl status
Jul 11 14:13:09 blondie sudo[3164]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/sbin/service httpd -
Jul 11 14:16:19 blondie sudo[3195]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/bin/nano /etc/httpd/
Jul 11 14:16:40 blondie sudo[3212]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/bin/nano /etc/httpd/
Jul 11 14:18:19 blondie sudo[3215]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/sbin/apachectl confi
Jul 11 14:19:14 blondie sudo[3221]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/bin/nano /etc/httpd/
Jul 11 14:20:01 blondie systemd[1]: Created slice user-0.slice.
-- Subject: Unit user-0.slice has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit user-0.slice has finished starting up.
-- 
-- The start-up result is done.
Jul 11 14:20:01 blondie systemd[1]: Starting user-0.slice.
-- Subject: Unit user-0.slice has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit user-0.slice has begun starting up.
Jul 11 14:20:01 blondie systemd[1]: Started Session 8 of user root.
-- Subject: Unit session-8.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-8.scope has finished starting up.
-- 
-- The start-up result is done.
Jul 11 14:20:01 blondie systemd[1]: Starting Session 8 of user root.
-- Subject: Unit session-8.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-8.scope has begun starting up.
Jul 11 14:20:01 blondie CROND[3225]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Jul 11 14:20:01 blondie systemd[1]: Removed slice user-0.slice.
-- Subject: Unit user-0.slice has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit user-0.slice has finished shutting down.
Jul 11 14:20:01 blondie systemd[1]: Stopping user-0.slice.
-- Subject: Unit user-0.slice has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit user-0.slice has begun shutting down.
Jul 11 14:20:14 blondie sudo[3251]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/bin/nano /etc/httpd/
Jul 11 14:20:39 blondie sudo[3255]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/sbin/service httpd r
Jul 11 14:20:39 blondie polkitd[637]: Registered Authentication Agent for unix-process:3256:362038 (system bus name :1.63 [/usr
Jul 11 14:20:39 blondie systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit httpd.service has begun starting up.
Jul 11 14:20:39 blondie httpd[3273]: httpd (pid 2260) already running
Jul 11 14:20:39 blondie kill[3275]: kill: cannot find process ""
Jul 11 14:20:39 blondie systemd[1]: httpd.service: control process exited, code=exited status=1
Jul 11 14:20:39 blondie systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit httpd.service has failed.
-- 
-- The result is failed.
Jul 11 14:20:39 blondie systemd[1]: Unit httpd.service entered failed state.
Jul 11 14:20:39 blondie systemd[1]: httpd.service failed.
Jul 11 14:20:39 blondie polkitd[637]: Unregistered Authentication Agent for unix-process:3256:362038 (system bus name :1.63, ob
Jul 11 14:22:01 blondie sudo[3280]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/bin/systemctl -l sta
Jul 11 14:23:13 blondie sudo[3283]: admin1 : TTY=pts/0 ; PWD=/home/admin1 ; USER=root ; COMMAND=/bin/journalctl -xe

i tried removing httpd and re-installing already but i couldn't get httpd to restart

Best Answer

Looks like you might have an orphaned PID file. There is a PID for httpd, but kill doesn't see a process for it.

Check top to see if there are any zombie processes. Also ps aux | grep httpd just to see what is running.

If this is the case, you would have to kill the parent process to clean it up (ps -Hfwe or pstree -paul to find it), or reboot.

Hopefully then you can do a systemctl start.

Related Topic