How to Install LAMP Stack on Ubuntu 18.04 Bionic Beaver

Install LAMP Stack on Ubuntu 18.04

In this article, we will have explained the necessary steps to install and configure phpMyAdmin on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

LAMP is a complete package to run any web application on a server. LAMP signifies the Linux, Apache, MySQL and Php. Apache is used as the web server for hosting of an application whereas MySQL is used as systematic data storage of application and Php is popular server-side scripting language which is used for web development as well bridging the gap between application and the database.

Install LAMP Stack on Ubuntu

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install Apache.

Apache is already available in ubuntu default software repositories. So in this tutorial, we will install Apache by using apt package manager:

sudo apt install apache2

After completion of the above command, Apache is installed on your system. Run the following command to check apache service status:

sudo systemctl status apache2

Step 3. Install MySQL.

Now to install mysql-server package run below command:

sudo apt install mysql-server

After completing installation MySQL will start automatically. Check MySQL version by typing:

sudo systemctl status mysql

Then, issue the mysql_secure_installation command to improve the security of the MySQL installation:

sudo mysql_secure_installation

Step 4. Install PHP.

Ubuntu 18.04 LTS ships with the latest and greatest PHP version 7.2. To install PHP and several other most common PHP modules type:

sudo apt install php libapache2-mod-php php-opcache php-cli php-gd php-curl php-mysql

Once the PHP packages are installed restart the Apache service with:

sudo systemctl restart apache2

Step 5. Testing PHP

Now you should create info.php file to test php to do so type following:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Then open the following link in your web browser and we will be able to see all the information about PHP and its other configurations: http://your-domain/phpinfo.php (replacing your IP address with the one above).

That’s all you need to do to installing Apache, MySQL, PHP (LAMP) Stack on Ubuntu 18.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.