Install LAMP Stack on VPSGrid Linux VPS
Short answerInstall LAMP on VPSGrid: apt install apache2 mariadb-server libapache2-mod-php php-mysql, enable mod_rewrite, create VirtualHost with AllowOverride All, test before disabling default site, mysql secure install, allow OpenSSH before UFW, verify PHP and MariaDB.
Overview
Customers preferring Apache httpd on VPSGrid Linux VPS — common for legacy PHP, .htaccess rules, or cPanel migration familiarity via Migrate from cPanel Shared Hosting to VPSGrid VPS.
VPSGrid sells unmanaged VPS with root or administrator access. Guest OS configuration, application data, backups, and patching inside the VM are your responsibility unless a separate product is documented. Review What Is an Unmanaged VPS at VPSGrid? and Security Responsibilities on Unmanaged VPS before expecting support to perform stack work.
VPSGrid provides unmanaged Linux and Windows VPS on US-Based KVM infrastructure with NVMe storage and Proxmox virtualization. You manage the guest OS, applications, backups, and security. Current plan specifications appear at checkout on vpsgrid.net — articles do not publish fixed pricing.
Decision guidance: LAMP vs LEMP
| Choose LAMP when | Choose LEMP when |
|---|---|
| .htaccess / AllowOverride required | Greenfield Nginx stack |
| Legacy Apache modules | WordPress guide alignment — How to Deploy WordPress on Ubuntu VPS uses Nginx |
Step 2: Enable mod_rewrite
a2enmod rewrite && systemctl restart apache2Step 3: Virtual host
Test Apache with the default site before disabling it — browse http://PRIMARY_IP to confirm Apache responds, then create your vhost:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
<Directory /var/www/example.com/public_html>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>WordPress pretty permalinks and many plugins expect .htaccess — only available when AllowOverride All is set on Apache (not on Nginx/LEMP).
a2ensite example.com.conf && apache2ctl configtest && systemctl reload apache2Run curl -H "Host: example.com" http://127.0.0.1 and confirm your vhost serves content. Only then run a2dissite 000-default.conf if you no longer need the default page on PRIMARY_IP.
a2dissite 000-default.conf && systemctl reload apache2Step 4: MariaDB setup
mysql_secure_installationmysql -e "CREATE DATABASE appdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'strongpass'; GRANT ALL ON appdb.* TO 'appuser'@'localhost'; FLUSH PRIVILEGES;"Step 5: Firewall and SSL
See How to Configure UFW Firewall on Ubuntu/Debian — allow OpenSSH first. Certbot Apache plugin: certbot --apache per Let's Encrypt SSL with Certbot on VPSGrid.
phpMyAdmin increases attack surface. Prefer CLI mysql, WP-CLI, or SSH tunnel. If installed, restrict by IP and use strong auth.
Verify
apache2ctl configtestreturns Syntax OK- PHP executes via index.php in DocumentRoot
- MariaDB app user connects
- WordPress permalinks work with mod_rewrite enabled
Troubleshooting matrix
| Symptom | Likely cause | What to check |
|---|---|---|
| 403 Forbidden | Directory permissions | chown www-data:www-data; AllowOverride All |
| 500 error | PHP fatal | Check /var/log/apache2/error.log |
| Port 80 conflict | Nginx also installed | Stop nginx or choose one stack only |
Security considerations
Disable directory listing, keep Apache patched via apt upgrade, use Fail2ban — Fail2ban Setup on VPSGrid Linux VPS.
Certbot with Apache
After vhost works on port 80, run Certbot Apache plugin per Let's Encrypt SSL with Certbot on VPSGrid: certbot --apache -d example.com -d www.example.com. Certificate issuance is not guaranteed — depends on DNS, HTTP validation, and rate limits.
Apache event vs prefork MPM
Default MPM varies by distribution. PHP mod_php traditionally used prefork; php-fpm + Apache proxy_fcgi allows event MPM for better concurrency. This guide uses mod_php for simplicity matching most cPanel migrations.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Post-install patching
Schedule regular apt upgrade windows; test apps after PHP or MariaDB minor bumps.
Log rotation early
Configure logrotate to prevent disk-full recurrence — see Disk Full on VPSGrid VPS: Diagnosis and Cleanup.
Deploy user hygiene
Use non-root deploy users with sudo for service restarts where practical.
Next learning step
Consider LEMP for new Nginx projects — Install LEMP Stack on VPSGrid Linux VPS.
Frequently Asked Questions
What is LAMP on VPSGrid?
Linux + Apache + MariaDB + PHP — alternative to LEMP using Apache httpd. You manage all components on unmanaged VPS.
Apache vs Nginx on VPSGrid?
Both run on VPSGrid Linux VPS. Apache .htaccess suits some legacy apps; Nginx often uses less memory — compare Install LEMP Stack on VPSGrid Linux VPS.
Does VPSGrid provide Apache support?
VPSGrid support covers infrastructure. Apache configuration inside guest OS is customer responsibility — Security Responsibilities on Unmanaged VPS.
Can I run Apache and Nginx together?
Possible but not recommended on small VPS — port 80 conflict. Choose one stack per server unless advanced reverse proxy setup.
Related Articles
Next steps on VPSGrid
Prepare your environment on a VPSGrid Linux VPS when Apache-based workloads require .htaccess or legacy compatibility.
Need More Help?
Search this knowledgebase for related guides. If the issue appears infrastructure-related (provisioning, billing, primary IP assignment), open a ticket at billing.vpsgrid.net with your service ID, primary IP, and steps already tried. See What Information to Include in a Support Request and Security Responsibilities on Unmanaged VPS for scope.
Was this answer helpful?