Skip to content
EuroVPSEuroVPS

How to troubleshoot common Apache issues

EuroVPS FAQ

Updated 4 min read

Apache is a stable, widely deployed web server. Most problems come from configuration, port conflicts or integration with other services on the same host.

Checking the Apache logs

Start with the error log. Common locations:

The common Apache error log file locations are as noted below for a quick reference.

cPanel

/usr/local/apache/logs/error_log

Plesk

/var/log/httpd/error_log

CentOS/Fedora

/var/log/httpd/error_log

Debian/Ubuntu

/var/log/apache2/error_log
 tail -f  /var/log/httpd/error_log

Common Apache Issues

Port Conflicts

Check that nothing else is bound to 80 and 443:

[root@server ~]# netstat -plan | grep :80
tcp        0      0 203.0.113.10:80            0.0.0.0:*                   LISTEN      18950/nginx         
tcp        0      0 203.0.113.10:80            203.0.113.10:52630         TIME_WAIT   -                   
tcp        0      0 203.0.113.10:51704         203.0.113.10:80            TIME_WAIT   -                   
tcp        0      0 203.0.113.10:80            203.0.113.10:52626         TIME_WAIT   -                   
tcp        0      0 203.0.113.10:80            203.0.113.10:51712         TIME_WAIT   -                   
tcp        0      0 203.0.113.10:80            203.0.113.10:52622         TIME_WAIT   -    

As you can see Nginx server is already using the port 80 in public interface an apache will not start. Kill the Nginx server and start Apache server again.

Other Apache instances stalled holding the ports.

You may receive the errors similar to port conflicts and the reason can be already initiated/non terminated Apache processes holding the ports. Please use the below commands to see if any such processes exist in the server.

[root@server ~]# ps aux  | grep "httpd\|apache"  | grep -v grep
root     18663  0.0  0.6 394336 32168 ?        SNs  15:25   0:00 /usr/sbin/httpd
apache   18666  0.0  0.3 252844 17436 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18667  0.0  0.5 395040 25532 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18668  0.0  0.5 395440 25592 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18670  0.0  0.5 395032 25716 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18671  0.0  0.5 394984 25676 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18672  0.0  0.5 394944 25640 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18673  0.0  0.5 395000 25468 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18674  0.0  0.4 394912 25384 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18675  0.0  0.5 395076 25780 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18676  0.0  0.5 394940 25636 ?        SN   15:25   0:00 /usr/sbin/httpd
apache   18677  0.0  0.4 394892 25280 ?        SN   15:25   0:00 /usr/sbin/httpd

Kill all the found Apache processes using the kill command as shown below.

[root@server ~]# kill -9   18666  18663   18667  18668 18670 18671 18672 18673 18674 18675 18676 18677 

Syntax errors in httpd.conf file

A syntax error in httpd.conf stops Apache from starting. The error names the line:

Syntax error on line 218 of  /etc/httpd/conf/httpd.conf

Check the syntax before restarting:

[root@server ~]# apachectl -t
Syntax OK

[root@server ~]

# httpd -t Syntax OK

For Debian and Ubuntu flavours you can do the Syntax check as shown below.

apache2ctl -t
Similarly you cause the command with -S switch to list all virtual hosts with essential information like configured ports, defined line number in configuration etc.

[root@server ~]

# httpd -S VirtualHost configuration: 127.0.0.1:7080 is a NameVirtualHost

Apache won't start if the .htaccess file is not properly created. 

It is required to set up the Apache virtual hosts with proper definitions in them for .htaccess files to consider. If these directives are missing the .htaccess file not considered and .htaccess definitions will not be loaded. Below noted is a sample definition

</VirtualHost>
<Directory /home/eurovps/public_html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Once done, .htaccess file created in /home/eurovps/public_html/ will be considered by Apache server. The file needs mode 644 and the domain user as owner:

Sample .htaccess file creation and permissions.

vi /home/eurovps/public_html/.htaccess
#++++Sample_contents++++#
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#++++Sample_contents++++#
Esc  + :wq

chmod 644 /home/eurovps/public_html/.htaccess
chown eurovps.eurovps  /home/eurovps/public_html/.htaccess

Tips, Try enabling verbose logs to debug (LogLevel debug). Check syslog and dmesg for any hints process termination, check free memory and free disk availability in server.

From the EuroVPS FAQ.

More in how to

Your next infrastructure partner

Still have
a question?

Tell us what you are trying to do. An engineer will read it and reply.

+357 222 32280
A EuroVPS engineer carrying a server node on the datacenter floor
A conversation with the people
who will look after your infrastructure.

Let’s start with your setup.

A little context helps us start the right conversation.

We’ll use your details to respond to your enquiry. Privacy policy