Jump to content
Linux - Tutorials And How To's
Sign in to follow this  

Installing Apache, Php5, Php7, Mysql, and Phpmyadmin

Recommended Posts

This guide is divided into 3 steps: installing/tesing Apache, PHP and finally MySQL.

Lets start with Apache:
1. Open the terminal (we will be using it through most of my guide) from Applications > Accessories > Terminal
2. Install apache2 using apt-get by typing the following

sudo apt-get install apache2



Now everything should be downloaded and installed automatically.
To start/stop/restart apache2 write:

sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart



Your www folder should be in: /var/www/ which is the main directory of your website.
If everything is OK you should see an ordinary HTML page when you type: http://localhost in your firefox browser

Installation of PHP5

sudo apt-get install php5 libapache2-mod-php5


Installation of PHP7

apt-get -y install php7.0 libapache2-mod-php7.0


Now we need to restart apache2.

sudo /etc/init.d/apache2 restart



Lets do a quick test of php by making a simple file

sudo nano /etc/var/www/index.php


place this in the file  

< ?php echo “Hello World”; ?>

Now run it by typing http://localhost/index.php in firefox… You should see your ” Hello World ”




Installation of MYSQL

sudo apt-get install mysql-server

Now we want to secure our MySql installation,

sudo mysql_secure_installation 


(optional) If you are running a server you should probably bind your address by editing bind-address in /etc/mysql/my.cnf and replacing its value ( by your IP address

 set your root password (although mysql should ask you about that when installing)
mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(‘xxxxxx’);

 Try running it
mysql -uroot -pxxx

where xxx is your password.


Installation of phpmyadmin

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


Now we need to restart apache2

sudo /etc/init.d/apache2 restart



After you restart apache you will get an error saying unable to determine FQDN fully qualified domain name. Here is how to fix this Open,

sudo nano /etc/apache2/httpd.conf



and add this

ServerName localhost



save close and restart apache2 with

sudo /etc/init.d/apache2 restart



You have setup and installed lamp manually.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this