Configure Centos7 apache for subdomain
I have 2 linodes. IP A (123.11.123) for domain xx.com and another IP B (133.11.133) for subdomain.xx.com. I set up A record for subdomain.xx.com to point a IP B and A record for xx.com and www.xx.com to point to IP A.
I then set up my Centos Server with Apache. In the /etc/hosts, I have
133.11.133 subdomain.xx.com subdomain
However, after I created the conf file below, the Apache will not restart and have error below
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
Here's my conf file xx.com.conf
<VirtualHost *:80>
ServerAdmin admin@xx.com
ServerName subdomain.xx.com
ServerAlias www.subdomain.xx.com
DocumentRoot /var/www/subdomain/
ErrorLog /var/www/subdomain/error.log
CustomLog /var/www/subdomain/access.log combined
<Directory /var/www/subdomain/>
AllowOverride All
</Directory>
</VirtualHost>
I have tried various way and rebuilding a few times but still going no way. Any help?
3 Replies
Hey there,
Just to confirm, is the error you are receiving strictly on the Linode you have set the subdomain on, or are you seeing the httpd errors on both of the Linodes? So we can also get a better idea of the specific errors, can you provide the output of the following two commands?
systemctl status httpd.service -l
tail -n 20 /var/log/httpd/error.log
Those should provide some specific error logs that might point to the exact error you are seeing. Thanks in advance!
Hi Scrane,
Thanks for the reply.
Here are the outputs
systemctl status httpd.service -l
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sun 2019-05-19 00:26:31 AEST; 23s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 22829 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 22828 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 22828 (code=exited, status=1/FAILURE)
May 19 00:26:31 response systemd[1]: Stopped The Apache HTTP Server.
May 19 00:26:31 response systemd[1]: Starting The Apache HTTP Server…
May 19 00:26:31 response systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
May 19 00:26:31 response kill[22829]: kill: cannot find process ""
May 19 00:26:31 response systemd[1]: httpd.service: control process exited, code=exited status=1
May 19 00:26:31 response systemd[1]: Failed to start The Apache HTTP Server.
May 19 00:26:31 response systemd[1]: Unit httpd.service entered failed state.
May 19 00:26:31 response systemd[1]: httpd.service failed.
tail -n 20 /var/log/httpd/error_log
[Sat May 18 13:02:17.125806 2019] [core:notice] [pid 18272] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat May 18 13:03:40.594887 2019] [mpm_prefork:notice] [pid 18272] AH00170: caught SIGWINCH, shutting down gracefully
[Sat May 18 13:03:41.646520 2019] [core:notice] [pid 18290] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Sat May 18 13:03:41.647389 2019] [suexec:notice] [pid 18290] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sat May 18 13:03:41.657463 2019] [auth_digest:notice] [pid 18290] AH01757: generating secret for digest authentication …
[Sat May 18 13:03:41.658456 2019] [lbmethod_heartbeat:notice] [pid 18290] AH02282: No slotmem from mod_heartmonitor
[Sat May 18 13:03:41.660413 2019] [mpm_prefork:notice] [pid 18290] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Sat May 18 13:03:41.660443 2019] [core:notice] [pid 18290] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat May 18 13:06:13.052683 2019] [mpm_prefork:notice] [pid 18290] AH00170: caught SIGWINCH, shutting down gracefully
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/html/response/error.log.
AH00015: Unable to open logs
[Sun May 19 00:23:59.124647 2019] [core:notice] [pid 22800] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Sun May 19 00:23:59.125915 2019] [suexec:notice] [pid 22800] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sun May 19 00:23:59.135547 2019] [auth_digest:notice] [pid 22800] AH01757: generating secret for digest authentication …
[Sun May 19 00:23:59.136643 2019] [lbmethod_heartbeat:notice] [pid 22800] AH02282: No slotmem from mod_heartmonitor
[Sun May 19 00:23:59.139001 2019] [mpm_prefork:notice] [pid 22800] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Sun May 19 00:23:59.139037 2019] [core:notice] [pid 22800] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun May 19 00:26:30.407429 2019] [mpm_prefork:notice] [pid 22800] AH00170: caught SIGWINCH, shutting down gracefully
(13)Permission denied: AH00091: httpd: could not open error log file /var/www/html/response/error.log.
After fiddling for few days with rebuilds and testing, finally I found that it was caused by blocked port by firewalls. I followed the steps below to configure the firewall and error is now resolved. https://www.linode.com/docs/web-servers/apache/install-and-configure-apache-on-centos-7/#configure-firewalld-to-allow-web-traffic