How to Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu


This guide will teach you how to install LAMP (Linux, Apache, MySQL, and PHP) on Ubuntu the fastest and easiest way possible.

Just copy and paste the commands below into your command prompt or terminal (SSH).

First you want to update the packages in the repository.

sudo apt-get update


Then you want to install Apache and the utilities for Apache.
sudo apt-get install apache2 apache2-utils


This will open up the dir.conf file so you can edit it.
sudo nano /etc/apache2/mods-enabled/dir.conf


Replace all the text with this in the dir.conf file with this: When you’re done, press CTRL + X and then press “y” to save it and then press ENTER to confirm the file name. The prompt may be different so pay attention to the instructions.
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.xhtml index.htm

Restart the Apache server.
sudo service apache2 restart


Install MySQL, PHP, and a few other libraries for your web server. You’re going to need to type in the MySQL root password. After you type your password in, press ENTER.
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql


Install MySQL database:
sudo mysql_install_db


Install MySQL database. This step will ask you a few questions. You want to type “n” for the first question and “y” for all the rest of the questions.
sudo mysql_secure_installation


Install PHP and other PHP libraries and utilities needed for PHP.
sudo apt-get install php5 php5-mysql php-pear php5-gd php5-mcrypt php5-curl

Comments (Facebook Comments)