Posted in

Apache2 troubleshooting

Here are some common commands to check the status of the Apache web server on a Unix/Linux system:

  1. Check if Apache is running:


    sudo systemctl status apache2

    or on some systems:


    sudo systemctl status httpd
  2. Check Apache version:


    apache2 -v

    or on some systems:


    httpd -v
  3. Check active Apache configuration:


    apache2ctl -S

    or on some systems:


    httpd -S
  4. Check Apache service status (if using init.d):


    sudo service apache2 status

    or on some systems:


    sudo service httpd status
  5. Check for active ports used by Apache:


    sudo netstat -tuln | grep ':80\|:443'
  6. Check Apache logs:

    • For access logs:

      sudo tail -f /var/log/apache2/access.log

      or on some systems:


      sudo tail -f /var/log/httpd/access_log
    • For error logs:

      sudo tail -f /var/log/apache2/error.log

      or on some systems:


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

These commands should help you monitor and diagnose the status and performance of your Apache web server.

To list the enabled sites in Apache, you can use the following command on a Unix/Linux system:


ls /etc/apache2/sites-enabled/

This command will list all the configuration files for the sites that are currently enabled in Apache.

If you want to view the contents of a specific enabled site configuration file, you can use:


cat /etc/apache2/sites-enabled/your_site.conf

Replace your_site.conf with the actual configuration file name.

For systems using httpd (typically Red Hat-based distributions), the enabled site configurations are usually included directly in the main configuration file or other included directories, and the concept of “enabled sites” isn't as commonly used as in Debian-based distributions with apache2. Instead, you might need to look into the main configuration file (httpd.conf) or included configuration directories:


grep -i 'Include' /etc/httpd/conf/httpd.conf

This will show you which files or directories are included in the main configuration, and you can check those for the active site configurations.

Leave a Reply

Your email address will not be published. Required fields are marked *