Setting up a LAMP (Linux, Apache, MySQL, PHP) stack is a fundamental step for many web applications. In this guide, we'll walk you through the process of installing LAMP on your Ubuntu 20.04 server hosted on CloudBlast's VPS. Let's get started!
Prerequisites
Before we begin, ensure you have:
1. A CloudBlast VPS running Ubuntu 20.04
2. Root or sudo access to your server
3. Basic knowledge of command-line interface (CLI)
Step 1: Update System Packages
First, let's update the system packages to ensure we have the latest versions:
sudo apt update
sudo apt upgrade -y
Step 2: Install Apache Web Server
Apache is the 'A' in LAMP. Let's install it:
sudo apt install apache2 -y
After installation, start and enable Apache:
sudo systemctl start apache2
sudo systemctl enable apache2
Verify that Apache is running:
sudo systemctl status apache2
You should see "active (running)" in the output.
Step 3: Install MySQL
MySQL is the 'M' in LAMP. Let's install it:
sudo apt install mysql-server -y
After installation, start and enable MySQL:
sudo systemctl start mysql
sudo systemctl enable mysql
Secure your MySQL installation:
sudo mysql_secure_installation
Follow the prompts to set a root password and remove insecure default settings.
Step 4: Install PHP
PHP is the 'P' in LAMP. We'll install PHP and some common extensions:
sudo apt install php libapache2-mod-php php-mysql php-cli php-curl php-json php-common -y
Restart Apache to ensure it works with PHP:
sudo systemctl restart apache2
Step 5: Configure Apache for PHP
Let's configure Apache to prioritize PHP files:
sudo nano /etc/apache2/mods-enabled/dir.conf
Move `index.php` to the first position in the DirectoryIndex line:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Save the file (Ctrl+X, then Y, then Enter) and restart Apache:
sudo systemctl restart apache2
Step 6: Test PHP Processing
Create a PHP info file:
sudo nano /var/www/html/info.php
Add the following content:
<?php
phpinfo();
?>
Save the file and visit `http://your_server_ip/info.php` in your web browser. You should see a page with PHP information.
Step 7: Secure Your Server
Remember to secure your server by:
1. Configuring your firewall (UFW)
2. Setting up SSL/TLS certificates
3. Regularly updating your system and applications
Conclusion
Congratulations! You've successfully installed the LAMP stack on your Ubuntu 20.04 server hosted on CloudBlast's VPS. This setup provides a solid foundation for hosting dynamic websites and web applications.
Here's a quick recap of what we've accomplished:
- Installed and configured Apache web server
- Set up MySQL database server
- Installed PHP and necessary modules
- Configured Apache to work with PHP
Remember, this is just the beginning. Depending on your specific needs, you might want to install additional PHP modules, configure virtual hosts, or set up database management tools like phpMyAdmin.
If you encounter any issues or need further assistance, don't hesitate to reach out to CloudBlast's support team. Happy hosting!







