Unable to start/restart httpd

General support questions
sadue
Posts: 55
Joined: 2016/01/08 19:08:26

Unable to start/restart httpd

Post by sadue » 2016/03/01 11:32:37

Hey guys

I tried to restart my apache httpd afetr installing php56u from ius, and php56u-cli, but I got the following error message
~]$ sudo systemctl restart httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.s
ervice" and "journalctl -xe" for details.
Then I run the code as instructed on the error message as follows, and it generates the following message.
~]$ 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 Tue 2016-03-01 11:53:07 UTC; 15s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 28473 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 28471 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 28471 (code=exited, status=1/FAILURE)
Mar 01 11:53:07 myclasslist systemd[1]: Starting The Apache HTTP Server...
Mar 01 11:53:07 myclasslist httpd[28471]: httpd: Syntax error on line 353 of /etc/httpd/conf/httpd.conf...nfig
Mar 01 11:53:07 myclasslist systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Mar 01 11:53:07 myclasslist kill[28473]: kill: cannot find process ""
Mar 01 11:53:07 myclasslist systemd[1]: httpd.service: control process exited, code=exited status=1
Mar 01 11:53:07 myclasslist systemd[1]: Failed to start The Apache HTTP Server.
Mar 01 11:53:07 myclasslist systemd[1]: Unit httpd.service entered failed state.
Mar 01 11:53:07 myclasslist systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
Please guys, what should I do?

stevemowbray
Posts: 424
Joined: 2012/06/26 14:20:47

Re: Unable to start/restart httpd

Post by stevemowbray » 2016/03/01 12:11:14

You need to fix the syntax error on line 353 of your config file.

sadue
Posts: 55
Joined: 2016/01/08 19:08:26

Re: Unable to start/restart httpd

Post by sadue » 2016/03/08 15:14:34

Okay.

I rebuild and start everything all afresh.

I now tried to enable virtualhost following the bellow procedure which is to include ssl
sudo mkdir -p /var/www/mydomain.org/htdocs
sudo chown -R apache:apache /var/www/mydomain.org/htdocs
sudo chmod -R 755 /var/www
sudo mkdir /etc/httpd/sites-available
sudo mkdir /etc/httpd/sites-enabled
sudo nano /etc/httpd/conf/httpd.conf
add the bellow code at the end of the file
IncludeOptional sites-enabled/*.conf
sudo nano /etc/httpd/sites-available/mydomain.org.conf
Add the bellow info to the file content and save
<VirtualHost 104.xxx.xxx.xxx:443>
servername www.mydomain.org
ServerAdmin serveradmin@mydomain.org
DocumentRoot "/var/www/mydomain.org/htdocs"
ServerAlias mydomain.org
ErrorLog /var/www/mydomain.org/error.log
CustomLog /var/www/mydomain.org/requests.log combined
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/mydomain_org.crt
SSLCertificateKeyFile /etc/httpd/ssl/myserver.key
SSLCertificateChainFile /etc/httpd/ssl/mydomain_org.ca-bundle
<directory "/var/www/mydomain.org/htdocs">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</directory>
</VirtualHost>
sudo ln -s /etc/httpd/sites-available/mydomain.org.conf /etc/httpd/sites-enabled/mydomain.org.conf
Now I tried to restart my apache using the bellow comand

Code: Select all

sudo systemctl restart httpd.service
but it out put the bellow info on the image
httpd error.PNG
httpd error.PNG (40.14 KiB) Viewed 222539 times
I don't know what I have not done right. Please help me out.

pfr
Posts: 13
Joined: 2016/02/25 15:39:25

Re: Unable to start/restart httpd

Post by pfr » 2016/03/14 15:33:25

What does "journalctl -xe" show after the failed start command?

sadue
Posts: 55
Joined: 2016/01/08 19:08:26

Re: Unable to start/restart httpd

Post by sadue » 2016/03/16 07:36:55

pfr wrote:What does "journalctl -xe" show after the failed start command?
~]$ journalctl -xe
Mar 16 07:22:54 server.mydomain.org sudo[13517]: sadue : TTY=pts/0 ; PWD=/home/sadue ; USER=root ; COMMAND=/bin/mkdir /etc/httpd/sites-enabled
Mar 16 07:23:08 server.mydomain.org sudo[13521]: sadue : TTY=pts/0 ; PWD=/home/sadue ; USER=root ; COMMAND=/bin/nano /etc/httpd/conf/httpd.conf
Mar 16 07:23:50 server.mydomain.org sudo[13546]: sadue : TTY=pts/0 ; PWD=/home/sadue ; USER=root ; COMMAND=/bin/nano /etc/httpd/sites-available/myclasslis
Mar 16 07:24:53 server.mydomain.org sudo[13573]: sadue : TTY=pts/0 ; PWD=/home/sadue ; USER=root ; COMMAND=/bin/ln -s /etc/httpd/sites-available/myclassli
Mar 16 07:29:14 server.mydomain.org polkitd[678]: Registered Authentication Agent for unix-process:14008:124228732 (system bus name :1.1035 [/usr/bin/pkttyagent --not
Mar 16 07:29:19 server.mydomain.org polkit-agent-helper-1[14027]: pam_unix(polkit-1:auth): authentication failure; logname= uid=1000 euid=0 tty= ruser=root rhost= us
Mar 16 07:29:19 server.mydomain.org polkit-agent-helper-1[14027]: pam_succeed_if(polkit-1:auth): requirement "uid >= 1000" not met by user "root"
Mar 16 07:29:21 server.mydomain.org polkitd[678]: Operator of unix-process:14008:124228732 FAILED to authenticate to gain authorization for action org.freedesktop.sys
Mar 16 07:29:21 server.mydomain.org polkitd[678]: Unregistered Authentication Agent for unix-process:14008:124228732 (system bus name :1.1035, object path /org/freede
Mar 16 07:29:39 server.mydomain.org sudo[14048]: sadue : TTY=pts/0 ; PWD=/home/sadue ; USER=root ; COMMAND=/sbin/service apache2 restart
Mar 16 07:29:39 server.mydomain.org polkitd[678]: Registered Authentication Agent for unix-process:14049:124231256 (system bus name :1.1037 [/usr/bin/pkttyagent --not
Mar 16 07:29:39 server.mydomain.org polkitd[678]: Unregistered Authentication Agent for unix-process:14049:124231256 (system bus name :1.1037, object path /org/freede
Mar 16 07:29:40 server.mydomain.org sshd[14046]: Connection closed by 104.131.149.87 [preauth]
Mar 16 07:30:06 server.mydomain.org sudo[14065]: sadue : TTY=pts/0 ; PWD=/home/sadue ; USER=root ; COMMAND=/bin/systemctl restart httpd.service
Mar 16 07:30:06 server.mydomain.org polkitd[678]: Registered Authentication Agent for unix-process:14066:124234022 (system bus name :1.1038 [/usr/bin/pkttyagent --not
Mar 16 07:30:06 server.mydomain.org systemd[1]: Stopping The Apache HTTP Server...
-- Subject: Unit httpd.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/li ... temd-devel
--
-- Unit httpd.service has begun shutting down.
Mar 16 07:30:08 server.mydomain.org systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/li ... temd-devel
--
-- Unit httpd.service has begun starting up.
Mar 16 07:30:08 server.mydomain.org httpd[14076]: AH00112: Warning: DocumentRoot [/var/www/mydomain.org/htdocs] does not exist
Mar 16 07:30:08 server.mydomain.org systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Mar 16 07:30:08 server.mydomain.org kill[14078]: kill: cannot find process ""
Mar 16 07:30:08 server.mydomain.org systemd[1]: httpd.service: control process exited, code=exited status=1
Mar 16 07:30:08 server.mydomain.org systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/li ... temd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Mar 16 07:30:08 server.mydomain.org systemd[1]: Unit httpd.service entered failed state.
Mar 16 07:30:08 server.mydomain.org systemd[1]: httpd.service failed.
Mar 16 07:30:08 server.mydomain.org polkitd[678]: Unregistered Authentication Agent for unix-process:14066:124234022 (system bus name :1.1038, object path /org/freede
lines 1087-1128/1128 (END)

pfr
Posts: 13
Joined: 2016/02/25 15:39:25

Re: Unable to start/restart httpd

Post by pfr » 2016/03/16 08:27:41

Strange, just tried installing php56u here also and apache is starting and PHP is working as well.

Can you increase the loglevel to debug or trace1 in /etc/httpd/sites-available/mydomain.org.conf and /etc/httpd/conf/httpd.conf?

And post the content of /var/www/mydomain.org/error.log and /var/log/httpd/error_log, assuming that's where the main httpd log is written?

sadue
Posts: 55
Joined: 2016/01/08 19:08:26

Re: Unable to start/restart httpd

Post by sadue » 2016/03/17 07:01:09

Now I followed this post at digitalocean on creating virtualhost step by step https://www.digitalocean.com/community/ ... n-centos-7, on restarting apache, I got this error report,
d]# apachectl restart
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
I checked the error report and saw the bellow error
[Thu Mar 17 06:51:35.362444 2016] [mpm_prefork:notice] [pid 14624] AH00170: caught SIGWINCH, shutting down gracefully
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/mydomain.org/error.log.
AH00015: Unable to open logs
What permission does the error log requires, and which user should I assign it to.
I have created virtualhost before on a different server, and I don't know why is becoming troublesome on this one server.

pfr
Posts: 13
Joined: 2016/02/25 15:39:25

Re: Unable to start/restart httpd

Post by pfr » 2016/03/17 07:57:05

Ok, that explains a lot, I think this issue is caused by SELinux. I had it set to Permissive to troubleshoot another issue I have here.

Since the log dir was created under /var/www, and no specific context rule exists for /var/www/mydomain.org, it will get the same context as /var/www, which is httpd_sys_content_t:

Code: Select all

[root@server2 sites-enabled]# ls -Zd /var/www
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www
The log file dir should have httpd_log_t context:

Code: Select all

[root@server2 sites-enabled]# ls -Zd /var/log/httpd/
drwx------. root root system_u:object_r:httpd_log_t:s0 /var/log/httpd/
And the DocumentRoot /var/www/mydomain.org/htdocs should have httpd_sys_content_t.

So, to fix it:

Code: Select all

semanage fcontext -a -t httpd_sys_content_t "/var/www/mydomain.org(/.*)?"
semanage fcontext -a -t httpd_log_t "/var/www/mydomain.org/.*\.log.*"
restorecon -R -v /var/www/mydomain.org
Also, I would create a separate log sub directory, to make the SELinux context less confusing.

Or you could of course set SELinux to Permissive :-)
Last edited by pfr on 2016/03/17 08:12:57, edited 1 time in total.

User avatar
TrevorH
Forum Moderator
Posts: 24555
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Unable to start/restart httpd

Post by TrevorH » 2016/03/17 08:08:31

Don't try to write logs to /var/www. Write them to /var/log/httpd instead and then selinux will not think it is a hacker trying to break in!
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

pfr
Posts: 13
Joined: 2016/02/25 15:39:25

Re: Unable to start/restart httpd

Post by pfr » 2016/03/17 08:40:41

Agreed :)

Post Reply