The LAMP or LAMP stack is a very useful open source development platform developed for Linux. It’s called LAMP because it uses Linux as an OS, apache as a web server, MySQL as a relational DBMS and Php like a scripting language. Installing LAMP on Ubuntu is pretty simple. This article describes a very convenient way to install and configure LAMP on your Ubuntu system.
The commands and procedures described in this article ran on the Ubuntu 18.04 LTS system.
Let’s follow these steps to easily install LAMP on our system:
Step 1: Install the tasksel package
In this guide, we install LAMP on our systems using the tasksel utility. Therefore, it is important to check whether tasksel is installed on your system or not. Run the following command as root in an Ubuntu terminal to install tasksel:
$ sudo apt install tasksel
Enter Y to continue the installation.
Step 2: Install LAMP with tasksel
Use the following command to install the LAMP server as sudo via tasksel:
$ sudo tasksel install lamp-server
Your LAMP package will be installed as follows:
Step 3: Verify LAMP Installation
You can check if your LAMP installation is working properly by creating a sample PHP page.
Let’s create a PHP info page by entering the following command in our Terminal:
$ sudo bash -c "echo -e '' > /var/www/html/phpinformation.php"
You can access this page on your local host by entering the following link in your browser:
The next page confirms that LAMP is installed correctly on your system.
Configure LAMP (Linux Apache MySQL and PHP)
After installing LAMP, it is recommended that you configure it according to your needs.
If you want to use your LAMP server in a production environment, it is best to protect your MySQL installation. To do this, run the following command:
$ sudo mysql_secure_installation
You can then bypass the output to protect the root password and other security settings.
To configure the firewall, run the following command as sudo:
$ sudo ufw allow in "Apache Full"
This configuration will allow incoming traffic through two ports, TCP 80 and TCP 443.
Install PHP modules
You can configure PHP modules for use with LAMP, except for those that already come with a LAMP installation. First, let’s take a list of modules that you can select with the following command:
$ apt-cache search ^php- | grep module
You can then install any of these modules using the following command:
$ sudo apt install [module-name]
$ sudo apt install php7.2-zip
In this article, you learned how to install and configure LAMP on your Ubuntu system. This included installing LAMP through tasksel, and then verifying the installation by creating an example .php file. In addition, you can also configure LAMP to make it safer and more convenient to use by following the steps described above.
How to install and configure LAMP server in Ubuntu