How to install LAMP and phpMyAdmin on Ubuntu 14.04

LAMP installation

For installation of LAMP on Ubuntu 14.04 use the following Ubuntu Server Guide.

The easiest way is to install the default up-to-date LAMP stack with these commands:

sudo apt-get update
sudo apt-get install lamp-server^

* mind the caret (^) at the end.

Another way to install the server is via tasksel command:

sudo apt-get update
sudo tasksel

and then select [ * ] LAMP Server.


Installing LAMP for development environment

Following this guide and tutorials [video1, video2], I created my own YouTube video. Check it out!

Turning PHP production settings into a development environment

php.ini development vs. production

After standard installation, php configuration file /etc/php5/apache2/php.ini is set so as “production settings” which means, among others, that no error messages are displayed. So if you e.g. make a syntax error in your php source file, apache server would return HTTP 500 error instead of displaying the php syntax error debug message.

If you want to debug your scripts, it might be better to use the “development” settings. Both development and production settings ini’s are located in /usr/share/php5/


so you can compare them and see the exact differences.

To make the “development” settings active, just backup your original php.ini

sudo mv /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini.bak

and create a symlink to your desired settings:

sudo cp -s /usr/share/php5/php.ini-development /etc/php5/apache2/php.ini

or you may of course also edit the /etc/php5/apache2/php.ini directly on your own, if you wish.

Run, Stop, Test, And Restart Apache

Use the following command to run Apache :

sudo /usr/sbin/apache2ctl start

To stop it, use :

sudo /usr/sbin/apache2ctl stop

To test configuration changes, use :

sudo /usr/sbin/apache2ctl configtest

Finally, to restart it, run :

sudo /usr/sbin/apache2ctl restart

Using Apache

You can access apache by typing or http://localhost (by default it will be listening on port 80) in your browser address bar. By default the directory for apache server pages is /var/www . It needs root access in order to put files in. A way to do it is just starting the file browser as root in a terminal:

gksudo nautilus


if you want to make /var/www your own. (Use only for non-production web servers – this is not the most secure way to do things.)

sudo chown -R $USER:$USER /var/www


To check the status of your PHP installation:

gksudo "gedit /var/www/testphp.php"

and insert the following code:


View this page on a web browser at http://yourserveripaddress/testphp.php or http://localhost/testphp.php

Securing Apache

If you just want to run your Apache install as a development server and want to prevent it from listening for incoming connection attempts, this is easy to do.

gksudo "gedit /etc/apache2/ports.conf"

Change ports.conf so that it contains:


Save this file, and restart Apache (see above). Now Apache will serve only to your home domain, or http://localhost.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.