This blog is ad-supported. If you find it useful, please consider disabling adblock for this site

making Linux even simpler

main page


Install LAMP and enable PHP error reporting

November 10 2013

Apache is nowadays the most popular web server in the world. In this brief tutorial I will explain how to install Apache, MySQL, and PHP (LAMP) on Ubuntu Linux and enable error reporting on your php documents.

Let's begin installing the LAMP combo. Open a terminal and type:

sudo apt-get install apache2 mysql-server php5-mysql libapache2-mod-php5

In the process of installation you will be prompted to set the administrator's password for the mysql server

mysql password

Set your password or let the field blank. If you don't set a password in this point you can try later with


That's it, you should have a working LAMP server, open your favorite web browser and enter "localhost" in the URL bar.

apache page

If this doesn't work reboot your computer or start the Apache server with this command:

sudo service apache2 start

When developing your web page you need to indetify the errors in your code so it's easy to find and fix them. You can enable Apache to display errors by changing the appropiate options in the php.ini configuration file, to do this run

sudo nano /etc/php5/apache2/php.ini

and look for these lines

;   display_errors

;   display_startup_errors

;   error_reporting

;   html_errors

;   log_errors

IMPORTANT these lines appear two times, the second one it's near the line 480 so look for them twice and change their values to the ones shown below: (actually only the last apperance of the variable should be changed, but it won't harm if you change them both)

display_errors = On

display_startup_errors = On

error_reporting =  E_ALL

html_errors = On

log_errors = On

And that's it, you are ready to start writing php code.

Geri Geri O. Morales
Maths Grad student at UNAM.
With experience in Linux server administration and web development

December 6 2013
Aftabul Islam wrote:

It was nice step by step article. It helped a lot.