Back to site

Install Apache HTTP Server

Install and configure Apache on a HolyCloud VPS: virtual hosts, modules, MPM, logs, and PHP-FPM or reverse proxy integration.

Install Apache HTTP Server

Apache HTTP Server is one of the most widely used web servers on HolyCloud Linux VPS instances. This guide covers installation from apt, site structure on Debian/Ubuntu, enabling common modules, a named virtual host, and configuration checks.

Prerequisites

  • HolyCloud VPS Ubuntu 22.04/24.04 or Debian 12
  • sudo access
  • Domain name (optional for IP-only testing)
  • Ports 80/443 open (UFW + HolyCloud firewall)
  • 512 MB RAM minimum (1–2 GB recommended with PHP-FPM)

Tip: Always run apache2ctl configtest before systemctl reload apache2.

Step 1: Installation

sudo apt update
sudo apt install -y apache2
sudo systemctl enable --now apache2
sudo systemctl status apache2

Version:

apache2 -v

Local test:

curl -I http://127.0.0.1

Step 2: Debian/Ubuntu structure

| Path | Role |

|--------|------|

| /etc/apache2/apache2.conf | Global configuration |

| /etc/apache2/sites-available/ | Available virtual hosts |

| /etc/apache2/sites-enabled/ | Symlinks to active sites |

| /etc/apache2/mods-available/ | Modules |

| /var/www/html/ | Default DocumentRoot |

| /var/log/apache2/ | Logs |

List sites and modules:

apache2ctl -S
apache2ctl -M
ls -la /etc/apache2/sites-enabled/

Step 3: Useful modules

sudo a2enmod rewrite ssl headers proxy proxy_http proxy_fcgi setenvif
sudo a2enconf charset
sudo systemctl reload apache2

Disable the default page if you use a named vhost:

sudo a2dissite 000-default.conf

Step 4: HTTP virtual host

sudo mkdir -p /var/www/exemple.fr/public_html
echo '<h1>Apache HolyCloud</h1>' | sudo tee /var/www/exemple.fr/public_html/index.html
sudo chown -R www-data:www-data /var/www/exemple.fr

Site file:

sudo nano /etc/apache2/sites-available/exemple.fr.conf
<VirtualHost *:80>
    ServerName exemple.fr
    ServerAdmin [email protected]
    DocumentRoot /var/www/exemple.fr/public_html

    <Directory /var/www/exemple.fr/public_html>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/exemple.fr-error.log
    CustomLog ${APACHE_LOG_DIR}/exemple.fr-access.log combined
</VirtualHost>

Enable:

sudo a2ensite exemple.fr.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

Step 5: MPM and PHP-FPM

See active MPM:

apache2ctl -V | grep MPM

For PHP, prefer php-fpm with mpm_event:

sudo apt install -y php-fpm
sudo a2dismod mpm_prefork 2>/dev/null || true
sudo a2enmod mpm_event proxy_fcgi
sudo a2enconf php8.2-fpm 2>/dev/null || sudo a2enconf php8.3-fpm

In the VirtualHost:

    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
    </FilesMatch>
sudo systemctl reload apache2

Step 6: Firewall and basic limits

sudo ufw allow 'Apache Full'
sudo ufw status

Light tuning file (small VPS):

sudo nano /etc/apache2/mods-available/mpm_event.conf

Adjust MaxRequestWorkers per RAM; reload after changes.

Step 7: Logs and rotation

sudo tail -f /var/log/apache2/exemple.fr-access.log
sudo tail -f /var/log/apache2/exemple.fr-error.log

Failed requests:

sudo grep -i error /var/log/apache2/exemple.fr-error.log | tail -20

Verification

sudo apache2ctl configtest
curl -H 'Host: exemple.fr' http://127.0.0.1/
sudo ss -tlnp | grep -E ':80|:443'
systemctl is-active apache2

Browser: http://exemple.fr shows your page; apache2ctl -S lists the vhost on port 80.

HolyCloud support

  • AH00558 server name: add global ServerName or in vhost
  • Port 80 in use: sudo ss -tlnp | grep :80
  • Redirect loop: .htaccess or proxy rules — test with curl -v
  • HolyCloud support: apache2ctl -S, error.log excerpts, free -h