Install LAMP On Ubuntu 11.04 “Natty Narwhal” Desktop Edition
Here is a step by step guide to install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu 11.04 “Natty Narwhal”. When you finished installing LAMP you have the basic applications installed to run a website from your own computer. All you have to do is download Drupal, Joomla or Worpress and place them in your var/www folder on your system and run the installation setup that comes with the website you want to use.
Step 1: Install Apache:
First you need to install Apache, to do this open a terminal window (press Alt+F2 and type: gnome-terminal) and copy+paste the following line:
sudo apt-get install apache2
The terminal will then ask you for your password, type it and then press enter. In the next step you will be asked if you want to continue and install the files press y key and then press Enter. To make sure everything is installed correctly we will now test Apache to ensure it’s working properly. Open your web browser and then copy+paste the following into the web address:
You should see a page in your browser saying “It works!”
Step 2: Install PHP5
In this part we will install PHP5, in your Terminal window copy+paste the following line:
sudo apt-get install php5 libapache2-mod-php5
The Terminal will then ask you for you’re password, type it and then press enter. In the next step you will be asked if you want to continue and install the files press y key and then press Enter.
In order for PHP to work and be compatible with Apache you must restart Apache. In your terminal window copy+paste the following line:
sudo /etc/init.d/apache2 restart
To ensure there are no issues with PHP5 let’s give it a test run…. in your Terminal window copy+paste the following line:
sudo gedit /var/www/testphp.php
This will open up a file called phptest.php now copy+paste the following line into the phptest file:
<?php phpinfo(); ?>
Now you can save and close the file. Now open you’re web browser and copy+paste the following into the web address:
A web page will appear showing you some info about the PHP version installed. Congrats you have now installed Apache2 and PHP5!
Step 3: Install MySQL.
Now it’s time to install MySQL, to do this copy+paste the following line in your terminal window:
sudo apt-get install mysql-server
The Terminal will then ask you for you’re password, type it and then press enter. In the next step you will be asked if you want to continue and install the files press y key and then press Enter. During the package configuration you will be asked to enter a password, use a password that’s easy to remember and press enter and fill in the same password to confirm it.
In order for other computers on your network to view the server you have created, you must first edit the “Bind Address”. Begin by opening up Terminal to edit the my.cnf file. to do this copy+paste the following line in your terminal window:
gksudo gedit /etc/mysql/my.cnf
You will be asked for your password, fill in your password and click on the OK button. A file called: my.cnf file will be opened, search for the line that says:
bind-address = 127.0.0.1
Now change 127.0.0.1 into the IP address of the computer you are installing LAMP on. When the IP address is replaced you can save and close the my.cnf file.
In this last step we are going to install phpMyAdmin which is an easy tool to create and/or edit your databases. To install phpMyAdmin copy+paste the following line into your terminal window:
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
You will be asked if you want to continue and install the files press y key and then press Enter. In the next step you will be asked to configere phpMyAdmin, it’s not a difficult task all you have to do is to select apache2 and when asked if you want configure the database using the dbconfig-common select OK unless you want to configure the database manually. In the next step you will be asked to provide the password from the administrative account to create a MySQL database and/or user. Use the same password you created when configuring the MySQL package in step 3. Now you will be asked to create a new password for the database administrative user to connect to your phpmyadmin panel. Fill in a password and repeat it to confirm the password. Now you are done all you have to do now is restart Apache, in your Terminal window copy+paste the following line:
sudo /etc/init.d/apache2 restart
To create a database open your web browser and enter the following url:
Username is root and the password is the password you created to login to phpmyadmin (step 4) now you can create or change a database.
When LAMP is installed and you want to login to http://localhost/phpmyadmin/ and you get this error message:
The requested URL /phpmyadmin/ was not found on this server.
Apache/2.2.17 (Ubuntu) Server at localhost Port 80
Open a terminal window and use the following commands to fix the problem:
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
sudo /etc/init.d/apache2 reload
Click here to read a more detailed manual (with screen shots).
It’s a link to my install LAMP on Ubuntu 10.04 manual (installing LAMP on Ubuntu 10.04 or on 11.04 works exactly the same)