Lamp Stack in 2020

Lamp Server in Ubuntu

Written By engineerisaac

Posted: Sat, Jan 02, 2021 at 10:18 PM - Showing 599 Views

How to Setup a LAMP Server on a Local Ubuntu Linux Machine or VM
How to Setup a LAMP Server on a Local Ubuntu Linux Machine or VM
The purpose of this brief guide is to take you through the process of setting up a LAMP (Linux, Apache, MySQL, PHP) server on a local Ubuntu Linux machine or virtual machine.

This will allow you to develop using PHP and MySQL (with phpMyAdmin). This is a common stack that is necessary for Wordpress development.

Install the necessary packages
You will need to install the following packages for the LAMP server. You can install them all at once by separating each package by a space, or one at a time like shown.

I prefer to download one at a time because it is easier to see if there were any errors.

Enter the terminal and type the following:

sudo apt-get install apache2
sudo apt-get install php
sudo apt-get install php-mysql
sudo apt-get install mysql-server

You should then be prompted to set a password for the MySQL root user. After setting the password continue to install:

sudo apt-get install libapache2-mod-php
sudo apt-get install php-mcrypt
sudo apt-get install phpmyadmin

You should then be prompted which server to use. Select Apache by pressing enter. Select no for advanced server setup.

Change permissions to the /var/www/html
In order for PHP scripts and files to be run by the LAMP server they need to be saved in the /var/www/html directory. You can think of this location as your local server.

In order to make changes to this directory we need to change the permissions on it. In the terminal enter the command:

sudo chown {your ubuntu username} /var/www/html

Create a symbolic link to phpMyAdmin
By default, phpMyAdmin is installed in the /usr/share/ directory. We need to move it to our local server directory.

We navigate to the server directory that we want the link in by: cd /var/www/html

Then create the link by entering the command ln

-s /usr/share/phpmyadmin phpmyadmin.

Restart Apache and test
Run the following command to restart Apache, setting the changes that were made:

sudo systemctl restart apache2

Finally, to access phpMyAdmin go to localhost/phpmyadmin in your browser. The default root username is ‘root’ and the password is the password you chose earlier for the MySQL database.

This Article Was archived from