
How to Create a Python Virtual Environment
June 17, 2025
Uncover Hidden URLs with GAU: A Bug Bounty Hunter’s Secret to Recon
June 18, 2025How to Install Apache, MySQL, and PHP on Ubuntu 24.04 LTS
Updated for Ubuntu 24.04 LTS, this guide walks through installing Apache, MySQL, and PHP. Useful for quick local development, test labs, or spinning up a basic web server.
⭐ Ready for a reliable, high-performance VPS at an unbeatable price? We host our own Kali labs on Hostinger: 4 vCPU, NVMe storage, 16 GB RAM and 16 TB bandwidth, backed by 24/7 support and a 30-day money-back guarantee. You’ll save up to 20% when you lock in a 24-month plan. Grab a Hostinger VPS using this referral link and support our content.
🚀 Claim Your Hostinger VPS Now (from only US$ 7.99/mo)
1. Update Ubuntu
Make sure your package list is up to date:
sudo apt update
Then apply any pending updates:
sudo apt upgrade
(A reboot is usually a good idea after major upgrades)
2. Install Apache
Install the Apache web server package:
sudo apt install apache2
3. Install MySQL Server
Install MySQL server package:
sudo apt install mysql-server
4. Secure MySQL Installation
Run MySQL’s secure installation script:
sudo mysql_secure_installation
Follow the prompts. As of MySQL 8, you may be asked about:
- Validating password component
- Root password setup
- Remove anonymous users
- Disallow remote root login
- Remove test database
- Reload privileges
5. Install PHP and MySQL PHP Module
Install PHP and Apache integration module:
sudo apt install php libapache2-mod-php php-mysql
6. Verify PHP Installation
php -v
You should see something like PHP 8.3.x (Ubuntu 24.04 ships with PHP 8.3).
7. Verify MySQL Installation
mysql --version
Should return MySQL 8.0.x.
8. Apache Configuration Basics
Apache config files live here:
/etc/apache2
Virtual host configs are located here:
/etc/apache2/sites-available/
9. Default Web Root
The default Apache document root is:
/var/www/html
You can place test files in this directory to verify Apache is serving content.
10. Test Apache in Browser
In your browser, visit:
http://localhost
You should see the Apache2 Ubuntu Default Page.
11. (Optional) Change Default Page to Custom Message
Example: overwrite index.html with a basic message:
sudo nano /var/www/html/index.html
Replace contents with:
404 Not Found
Save and exit. Reload http://localhost
to confirm your change appears.
⭐ Ready for a reliable, high-performance VPS at an unbeatable price? We host our own Kali labs on Hostinger: 4 vCPU, NVMe storage, 16 GB RAM and 16 TB bandwidth, backed by 24/7 support and a 30-day money-back guarantee. You’ll save up to 20% when you lock in a 24-month plan. Grab a Hostinger VPS using this referral link and support our content.
🚀 Claim Your Hostinger VPS Now (from only US$ 7.99/mo)