We will be installing and hence setting up the LAMP server stack on our system’s local server. The LAMP server stack constitutes specific open source technologies that are used to set up a server. These technologies are:
– L for Linux as the operating system
– A for Apache as the Web server
– M for MySQL as the relational database management system
– P for PHP (At times, Python/Perl) as the object-oriented scripting language
Hence, we also can understand why the Microsoft Windows equivalent of this stack is WAMP and the MacOS equivalent is the MAMP.
Point a directory to the local host. For this, first enter the desired directory and then type the following in the terminal.
python -m http.server 8000
This command points the current directory to the local host on port 8000.
Do this for a directory containing an HTML file. Try opening it from http://localhost:8000/
Now, change the extension to
*.php and try reading it again.
Setting up a server in a directory containing an
index.html file surely reads it processed with the HTML script. But, try changing the extension to something else like
.py. You would either get your HTML script as it is without any processing or a request to save it as a file. Using the LAMP stack helps us read such files.
Using content-management systems(CMS) like WordPress and Joomla! is all about reading code in PHP. Let alone HTML wouldn’t serve the purpose at all.
I worked on the Ubuntu 16.04 LTS which completed my Linux OS requirements. You shall now open the terminal window (Ctrl+Alt+T) to install rest of our software requirements.
We need the Metapackage
$ apt-get install apache2
Open the local host on the browser by typing the URL as http://localhost/
You shall see an Apache message displayed stating “It works!”
Apache server would automatically restart after the installation of apache. In case it doesn’t run the command:
apt-get install mysql-server mysql-client
We need to install the
libapache2 Metapackages, and the <phpMyAdmin package for a GUI interface to access the MySQL databases with an interface.
$ apt-get install php5 libapache2-mod-php5
You can check this by executing any PHP file from
/var/www/ directory or simply executing the following command in the terminal window.
php -r 'echo "\n\nYour PHP installation is working fine.\n\n\n";'
$ apt-get install phpMyAdmin
Another window for the installing configuration of phpMyAdmin will appear.
– It will ask for server selection, choose
– Also, choose “yes” for
dbconfig-common to set up the database.
– There will be a prompt to create a password for the phpMyAdmin and then confirm it for the
The phpMyAdmin Apache configuration file is added to the
/etc/apache2/conf-enabled/ directory to be read automatically.
We need to explicitly enable the mcrypt module which is used in PHP for data encryption and decryption.
Press TAB after PHP to see the most preferrable and available option as it may exist in your system with another name such as
Open the browser and type the URL as http://localhost/phpmyadmin
It should display a login form where you can enter the user details you just used to create the
In case the URL doesn’t work and displays a 404 error, you must do the following. Type the following in the terminal window.
$ gksudo gedit /etc/apache2/apache2.conf
Now, include the following line at the bottom of the file, save and quit.
Now, try accessing the URL. It should work.
Congratulations, for setting up the LAMP environment on your local server!
The files can be accessed on the local server once saved in the
/var/www/ directory of the system.