Easiest way to install LAMP On Ubuntu

For a beginner its really a difficult to install LAMP on Ubuntu. Even if it is installed its very difficult to run phpmyadmin properly.
I am going to share my personal experience and difficulties we may encounter during installation.
First of all we are going to install apache, php, mysql and phpmyadmin
A) Installing Apache
B) Installing Php
C) Installing Mysql
D) Installing Phpmyadmin

A) Installing Apache
1. Open up the Terminal (Applications > Accessories > Terminal) and run the following line of code:

sudo apt-get install apache2

2. The Terminal might ask you for your password, type your password and then press enter.
3. Testing: Run http://localhost/ url in your browser. If you get a message “It works!” then Apache is sucessfully installed.

B) Installing Php
1. Open up the Terminal (Applications > Accessories > Terminal) and run the following line of code:

sudo apt-get install php5 libapache2-mod-php5

2. The Terminal might ask you for your password, type your password and then press enter.
3. Restart apache by runing this code to make Php compatible with Apache.

sudo /etc/init.d/apache2 restart

4. Testing PHP
i. In the terminal copy/paste the following line:

sudo gedit /var/www/testingphp.php

ii. Copy and Paste following line code into the testingphp file:

< ? php echo "Hello World!!!"; ?>

iii. Save the file.
iv. Run http://localhost/testingphp.php in your browser. If it displays ‘Hello World!!!’ then PHP is alswo sucessfully installed.

C) Installing Mysql
1. Open up the Terminal (Applications > Accessories > Terminal) and run the following line of code:

sudo apt-get install mysql-server

2. If you need to give access to the server you have created for others computer in your network you must edit the my.cnf file.

gksudo gedit /etc/mysql/my.cnf

Modify the line

bind-address = 127.0.0.1

to
Change 127.0.0.1 to your IP address (eg 192.168.0.1)
(Note you can skip this step)
3. Open up the Terminal (Applications > Accessories > Terminal) and run the following line of code:

mysql -u root

If you get Following error message

“ERROR-ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)
COMMAND:mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’);
ERROR:mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’);”

then run

mysql -u root

4. Open up the Terminal (Applications > Accessories > Terminal) and run the following line of code:

sudo gedit /etc/apache2/apache2.conf

Add the following line of code inside apache2.conf file:

Include /etc/phpmyadmin/apache.conf

and restart Apache:

sudo /etc/init.d/apache2 restart

5. Now copy and paste this line in your terminal:

mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’);

Note: You can change password of your choice. But if you wish to work without your password then you should modify /etc/phpmyadmin/config.inc.php file
i. Run the following code in your terminal

sudo gedit /etc/phpmyadmin/config.inc.php

2. Change

//$cfg[‘Servers’][$i][‘AllowNoPassword’] = TRUE;

line to

$cfg[‘Servers’][$i][‘AllowNoPassword’] = TRUE;

D. Installing Phpmyadmin
1. Open up the Terminal (Applications > Accessories > Terminal) and run the following line of code:

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

2. Edit php.ini file by running following code in your terminal

gksudo gedit /etc/php5/apache2/php.ini

Change

;extension=mysql.so

to

extension=mysql.so

If you dont find ;extension=mysql.so then skip it uncomment other mysql lines eg.

3. Run following code in your terminal to restart apache

sudo /etc/init.d/apache2 restart

4. Testing: Run http://localhost/phpmyadmin in your browser if you get window of phpmyadmin then you might be asked with username and password.
Username: root
Password: (If you had set password from step C.5. then enter that password or leave it empty)
If you get login then congrats. Now you have got installed all Apache, PHP, Mysql and Phpmyadmin.

About the Author

has written 38 stories on this site.

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

*

Copyright © 2024 Programmer to Programmer- A website for web programming and mobile application programming tutorials.
Wordpress themes