Hi all,
This post will help you install LAMP server in your Ubuntu machine. LAMP stands for Linux, Apache, MySQL, PHP.
There are 3 basic steps in installing the LAMP Server,
- Installing & Testing Apache
- Installing & Testing PHP
- Installing & Testing MySQL
Installing Apache
Step 1: Open up the Terminal.
Step 2: Copy & Paste the following code into the terminal,
sudo apt-get install apache2
Step 3: You will be asked for root password, provide that. Now you have installed Apache.
Testing Apache
To make sure that you have correctly installed it, we will now test Apache to ensure that it is working correctly.
Step 1: Open up any web browser & enter the following web address,
http://localhost
If Apache is working properly, you will see a page like thisInstalling PHP
Step 1: Open up the terminal.
Step 2: Copy & Paste the following code into the terminal,
sudo apt-get install php5 libapache2-mod-php5
Step 3: To make the PHP work, we have to restart Apache by using the following code,
sudo /etc/init.d/apache2 restart
Testing PHP
Step 1: Open up the terminal.
Step 2: Copy & Paste the following code into the terminal,
sudo gedit /var/www/testphp.php
The above code will open up a file testphp.php.
Step 3: Now copy & paste the following PHP code into the testphp.php file,
<?php phpinfo(); ?>
Step 4: Save the file and close it.
Step 5: Open up any web browser & enter the following web address,
http://localhost/testphp.php
If the installed Apache & PHP are working properly, you will see a page like thisInstalling & Testing MySQL
Step 1: Open up the Terminal.
Step 2: Copy & Paste the following code,
sudo apt-get install mysql-server
Step 3: Now you can set the MySQL root password by using the following code,
mysql -u root
Following that Copy & Paste this code,
mysql>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
Note: Make sure that you change “yourpassword” to your root password.
Step 4: Now we are going to install a new program phpmyadmin, which is an easy tool to edit your database. So Copy & Paste the following code into the terminal,
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
Step 5: Our next task is to get PHP to work with MySQL by editing the php.ini file using the following code,
gksudo gedit /etc/php5/apache2/php.ini
Now we are going to uncomment the following line by removing the semicolon(;),
;extension=mysql.so
to look like,
extension=mysql.so
Step 6: Now restart Apache by using the following code,
sudo /etc/init.d/apache2 restart
Step 7: Now you can test your phpmyadmin installation by entering the following web address in your web browser,
http://localhost/phpmyadmin
You will see a page like thisNote: In this post I am referring Apache2 and PHP5 versions.
Now you have successfully installed the LAMP server in your Ubuntu machine. Hope this post was very useful. 🙂
Pingback: How to install WordPress Locally | Nikitha Guna