The following tutorial explains the ways to install LAMP Stack on Ubuntu 17.10, Ubuntu 17.04, Ubuntu 18.04, Ubuntu 18.10
Install Apache on Ubuntu
Before we run any command line code make sure you have root aceess.
Open Terminal, and to install lamp stack on Ubuntu we need to start installing apache in first step.
First we need to update the package manager and make sure the system is upto date.
sudo apt update
to install Apache type and enter the following code in terminal, type y/Y/yes if prompted
Install Apache Using the following command:
sudo apt install apache2
Install Mysql on Ubuntu
To install mysql on ubuntu type and hit enter the following command in terminal
sudo apt install mysql-server
Install PHP and Required dependencies
The final step of this tutorial is installing PHP and required dependencies using the following commands
sudo apt install php php-mysql libapache2-mod-php php-curl
Now its time to configure mysql using the following command so that mysql works as expected
From terminal run the following code
sudo mysql_secure_installation
When executed the above code, it asks you several questions, take care of following option:
- Validate Password Plugin sets restrictions whenever you create a new db user, so choose option carefully, suggested option – N/ignore
[OPTIONAL] Once finished, we need to install PhpMyAdmin for managing databases visually.
to install PhpMyAdmin type the following code in terminal and hit enter
Install PhpMyAdmin in Ubuntu
sudo apt install phpmyadmin
during installation it will ask you to choose server option, choose apache2 and to add test database of phpmyadmin, when asked enter root password.
Once PhpMyAdmin installed, we need to add the following line to apache2.conf file so that we will be able to access, using terminal edit the conf file and add the line as given below:
sudo vim /etc/apache2/apache2.conf
#above code will open the file, then add the following line at the bottom of file (Press i to change to write mode)
Include /etc/phpmyadmin/apache.conf
#once added press esc and then type :wq!
Restart apache using the following code
sudo service apache2 restart
That’s all, you now have LAMP stack installed and working on your Ubuntu. The root directory resides in /var/www/html by default. Open your browser enter locatlhost it will display Apache index file.
Drop a comment if you need any information or help regarding the LAMP installation on Ubuntu.