The LAMP stack is a popular combination of open-source software that allows you to host dynamic websites and web applications. It consists of:
Before you begin, make sure all your system packages are up to date:
sudo apt update
sudo apt upgrade
Apache is one of the most widely used web servers. To install it, run:
sudo apt install apache2
Once the installation is complete, verify that the service is running:
sudo systemctl status apache2
Open your browser and visit:
http://your_server_ip
If everything is working correctly, you’ll see Apache’s default “It works!” page.
MySQL allows you to store and manage data for your website:
sudo apt install mysql-server
After installation, run the MySQL security setup wizard:
sudo mysql_secure_installation
You’ll be prompted to configure the root password, remove anonymous users, and disable remote root login.
It’s recommended to answer “Yes” to all security prompts.
To access the MySQL shell:
sudo mysql
To exit:
exit
PHP enables your server to display dynamic content. To install it:
sudo apt install php libapache2-mod-php php-mysql
To check your PHP version:
php -v
Create a test file named info.php in the Apache web root directory:
sudo nano /var/www/html/info.php
Add the following code:
<?php
phpinfo();
?>
Save and close the file, then open in your browser:
http://your_server_ip/info.php
You should see a page displaying detailed PHP configuration information.
When you’re done, delete the file for security reasons:
sudo rm /var/www/html/info.php
Depending on your application’s requirements, you may need to install extra PHP modules.
List all available modules with:
apt search php-
For example, to install the PHP CLI module:
sudo apt install php-cli
You have successfully installed the LAMP stack on your Ubuntu server.
Your system is now ready to host PHP-based applications such as WordPress, Drupal, or custom-built solutions.
Make sure to regularly update your packages and take backups to maintain a secure and stable environment.
Contact our experts, they will be happy to help!
Contact us