Part of Datorkirurgen AB – IT experts across Sweden

Apache on Amazon Linux powers many company websites in AWS. A small typo or a conflicting redirect can still stop the whole site. Business IT Support fixes configuration errors, virtual hosts, redirect loops and PHP-FPM settings.

Error 1: Apache on Amazon Linux does not start after a change

Occasionally, after a change in a configuration file, Apache refuses to start, and every website on the server goes down. The cause is usually a typo, a missing module or a reference to a certificate file that does not exist. Therefore, we always run apachectl configtest before we restart the service.

Fortunately, the test shows the exact file and line with the error. In addition, journalctl and the error log in /var/log/httpd give more details. As a result, we can fix the error within minutes instead of guessing.

Terminal running apachectl configtest on Apache on Amazon Linux
apachectl configtest showing a syntax error. For example, this is how Business IT Support, part of Datorkirurgen AB, finds the faulty line.

Error 2: virtual hosts, domains and HTTPS rules

In general, each website needs its own virtual host with the correct ServerName, ServerAlias and DocumentRoot. If two virtual hosts claim the same name, or if the default host catches the traffic, visitors land on the wrong site. Moreover, the HTTPS virtual host must point to the right certificate.

Therefore, we review every virtual host, remove duplicates and keep one file per site in /etc/httpd/conf.d. Consequently, the configuration stays readable, and new sites can be added without risk.

In addition, we check that SELinux contexts and file permissions allow Apache to read the document root. Because Amazon Linux applies strict defaults, a wrong context often gives a 403 error even when the configuration itself is correct.

Apache virtual host with ServerName and ServerAlias on Apache on Amazon Linux
Apache virtual host with ServerName and ServerAlias. One file per site keeps the configuration readable.

Error 3: too many redirects

In short, the browser error ERR_TOO_MANY_REDIRECTS means that the site sends the visitor in a loop, often between HTTP and HTTPS or between www and non-www. Typically, Apache, WordPress and sometimes a load balancer all try to redirect at the same time.

Therefore, we decide where the redirect should happen and remove the rest. For instance, Apache handles HTTP to HTTPS, while WordPress only knows the final address. After the change, we test with curl to see every step of the redirect chain.

Browser showing too many redirects
The browser showing ERR_TOO_MANY_REDIRECTS. A loop between HTTP and HTTPS stops the site completely.

Checking PHP-FPM and php.ini

For example, on Amazon Linux Apache usually passes PHP requests to PHP-FPM. If PHP-FPM has too few workers, the site becomes slow under load; if it has too many, the server runs out of memory. In addition, php.ini settings such as memory_limit, upload_max_filesize and max_execution_time affect how WordPress and other applications behave.

Next, we test the application with curl, for example against admin-ajax.php in WordPress, and measure the response time. Then we adjust PHP-FPM and php.ini to the available memory and the traffic. As a result, Apache on Amazon Linux stays both stable and fast.

curl test against WordPress admin-ajax
curl test against WordPress admin-ajax. Moreover, curl shows the response time before and after the change.
Editing php.ini and checking PHP-FPM settings
Editing php.ini and checking php-fpm. Finally, the PHP-FPM settings must match the available memory.

Contact Datorkirurgen AB about Apache on Amazon Linux

Business IT Support is part of Datorkirurgen AB, which has more than 30 years of experience in IT for businesses. We configure and troubleshoot Apache, PHP-FPM and HTTPS on Amazon Linux and other distributions for companies remotely anywhere, and on site in Stockholm.

In addition, our prices start at €250 per hour excluding VAT, or as agreed, and we guarantee to solve the problem. The Apache project documents virtual hosts in its official documentation. Contact us when your web server stops.

Frequently asked questions about Apache on Amazon Linux

Apache on Amazon Linux basics

Redirects and HTTPS

PHP-FPM and support

Website developed by Datorkirurgen AB · Privacy policy