LAMP stack (Apache, MariaDB, PHP) Deploy a full LAMP stack on a HolyCloud VPS: Apache, MariaDB, PHP, virtual host, permissions, and secure phpinfo test. ~16 min read Intermediate #lamp #apache #mariadb #php #hosting LAMP stack (Apache, MariaDB, PHP) The LAMP stack (Linux, Apache, MariaDB, PHP) hosts most CMS platforms (WordPress, Drupal, Joomla) on a HolyCloud Linux VPS. This tutorial chains installation of all three services, a virtual host, required PHP modules, and permission best practices. Prerequisites HolyCloud VPS Ubuntu 22.04/24.04 or Debian 12 (2 GB RAM minimum recommended) sudo access Domain pointing to the VPS IP (optional for testing, required for SSL) Ports 80 and 443 open (UFW + HolyCloud firewall) Related guides: « Install MariaDB », « Install Apache HTTP Server » Tip: for heavy PHP loads, prefer PHP-FPM + Apache (mpm_event) rather than mod_php alone; this guide covers the classic setup then FPM. Step 1: update and base packages sudo apt update sudo apt install -y apache2 mariadb-server libapache2-mod-php php php-cli php-mysql php-curl php-xml php-mbstring php-zip php-gd unzip Enable Apache: sudo systemctl enable --now apache2 sudo a2enmod rewrite ssl headers sudo systemctl reload apache2 Step 2: secure MariaDB and create CMS database sudo mariadb-secure-installation Database for WordPress (example): sudo mariadb <<'EOF' CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'MotDePasseFortIci!'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost'; FLUSH PRIVILEGES; EOF Step 3: site directory and permissions sudo mkdir -p /var/www/exemple.fr/public_html sudo chown -R www-data:www-data /var/www/exemple.fr sudo find /var/www/exemple.fr -type d -exec chmod 755 {} \; sudo find /var/www/exemple.fr -type f -exec chmod 644 {} \; Test file (remove after verification): echo '<?php phpinfo();' | sudo tee /var/www/exemple.fr/public_html/info.php Step 4: Apache virtual host sudo nano /etc/apache2/sites-available/exemple.fr.conf <VirtualHost *:80> ServerName exemple.fr ServerAlias www.exemple.fr DocumentRoot /var/www/exemple.fr/public_html <Directory /var/www/exemple.fr/public_html> 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 the site: sudo a2ensite exemple.fr.conf sudo a2dissite 000-default.conf sudo apache2ctl configtest sudo systemctl reload apache2 Step 5: PHP-FPM (recommended in production) sudo apt install -y php-fpm sudo a2dismod php8.2 2>/dev/null || sudo a2dismod php8.3 2>/dev/null || true sudo a2enconf php8.2-fpm 2>/dev/null || sudo a2enconf php8.3-fpm sudo a2enmod proxy_fcgi setenvif sudo systemctl enable --now php8.2-fpm 2>/dev/null || sudo systemctl enable --now php8.3-fpm In the VirtualHost, add: <FilesMatch \.php$> SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost" </FilesMatch> Adapt the socket path (ls /run/php/). Step 6: firewall and SSL (Let's Encrypt) sudo ufw allow 'Apache Full' sudo apt install -y certbot python3-certbot-apache sudo certbot --apache -d exemple.fr -d www.exemple.fr Step 7: post-installation hardening Remove info.php: sudo rm -f /var/www/exemple.fr/public_html/info.php Restrict PHP execution in uploads (WordPress) via .htaccess or dedicated Apache config. Verification curl -I http://127.0.0.1 curl -s http://exemple.fr/ | head -20 sudo systemctl is-active apache2 mariadb php8.2-fpm 2>/dev/null || sudo systemctl is-active php8.3-fpm mariadb -u wp_user -p -h 127.0.0.1 wordpress -e "SHOW TABLES;" Browser: site home or CMS install screen; valid HTTPS after Certbot. Need help? 403 Forbidden: www-data ownership, DocumentRoot, Require all granted 500 + PHP: sudo tail -50 /var/log/apache2/exemple.fr-error.log and journalctl -u php*-fpm Database unreachable: wp-config.php credentials vs MariaDB user HolyCloud support: domain, apache2ctl -S output, df -h, RAM (free -h) Continue reading Previous article Kernel hardening (sysctl) Read Next article Let's Encrypt renewal Read