httpd won't start on default CentOS 7 installation

Linode Staff

After installing CentOS 7, I am trying to configure a LAMP stack and httpd is not starting. When I run sudo systemctl start httpd.service I receive the following:

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

So I run sudo service httpd status and this is what I'm seeing:

# service httpd status
Redirecting to /bin/systemctl status httpd.service
? httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2018-05-28 14:36:34 UTC; 18min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 29639 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 29638 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 29638 (code=exited, status=1/FAILURE)

May 28 14:36:34  systemd[1]: Starting The Apache HTTP Server...
May 28 14:36:34  httpd[29638]: AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/httpd/conf.d/vhost.conf:1
May 28 14:36:34  systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 28 14:36:34  kill[29639]: kill: cannot find process ""
May 28 14:36:34  systemd[1]: httpd.service: control process exited, code=exited status=1
May 28 14:36:34  systemd[1]: Failed to start The Apache HTTP Server.
May 28 14:36:34  systemd[1]: Unit httpd.service entered failed state.
May 28 14:36:34  systemd[1]: httpd.service failed.

3 Replies

While these errors don't give us a whole lot to go off of, I was actually just looking at one of these recently. I'm still not entirely certain why this causes this httpd (Apache) to error out, but what we found was that there were 2 lines in /etc/httpd/conf/httpd.conf that seem to be creating an issue:

ErrorLog "logs/error_log"
CustomLog "logs/access_log" combined

If you comment these 2 lines out by adding a '#' to the beginning of each line:

#ErrorLog "logs/error_log"
#CustomLog "logs/access_log" combined

and then saving the file, you should be able to get Apache to start. If you have set a custom path for your logs, it is also critical that the path exist on your system. To clarify, the log file does not need to be there, as Apache will create it at launch, but it's directory has to exist before attempting to launch Apache. Don't forget to start httpd after saving your changes:

sudo service httpd start

I also recommend setting httpd as a service so that you do not have to manually start it on every boot:

sudo systemctl enable httpd.service
sudo systemctl restart httpd.service

If you are installing WordPress onto your LAMP stack and have issues connecting to the admin site via IP address after the initial installation, check out this post for troubleshooting advice.

I used the following code :-
<virtualhost *:80="">
ServerName www.YOURDOMAIN.COM
ServerAlias YOURDOMAIN.COM
DocumentRoot /var/www/YOURDOMAIN.COM/public_html
ErrorLog /var/www/YOURDOMAIN.COM/error.log
CustomLog /var/www/YOURDOMAIN.COM/requests.log combined</virtualhost>

DocumentRoot /var/www/YOURDOMAIN.COM/public_html
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/YOURDOMAIN.COM/public_html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct