How to install LAMP on Debian

Installing LAMP might seem hard at first look. But if you do it one step at a time it won't be much of a problem. In this tutorial you will find out how to install Apache, PHP, MySQL and phpMyAdmin on deb-based linux systems (Debian, Ubuntu, Mint).

Installing Apache

Let's install apache first. To do it run:

sudo apt-get install apache2

Apache will run as soon as it's installed. In the terminal you will see "Starting web server apache2" message.

To manage Apache you can use apache2ctl tool. With it's help you can, for example, check on Apache web sever current status. To do it run

apache2ctl status

You can also use commands like:

sudo apache2ctl stop
sudo apache2ctl start
sudo apache2ctl restart
to stop, run or restart Apache.

To make sure Apache works navigate to http://localhost in your browser. If the installation was a success you will see the page saying "it works!".

Installing PHP

To install PHP run:

sudo apt-get install php5 libapache2-mod-php5

After the installation Apache usualy restarts itself, but if it didn't, run:

sudo apache2ctl restart

Installing MySQL

To install MySQL run:

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

After the installation the dialog will pop up where you will need to enter the password for MySQL root. MySQL creates root user automatically. What you need to do is to enter the password for MySQL root and confirm it. It's recommended to use different password for system root and MySQL root.

Installing PhpMyAdmin

With phpMyAdmin you can manage MySQL database from your browser. To install PhpMyAdmin run

sudo apt-get install phpmyadmin

In the end of the installation the dialog will pop up. Choose apache2.

Then you will be offered to create PhpMyAdmin database.

After that you will need to enter the password for database administrator.

Finally you will be asked to enter the password to finish the registration of PhpMyAdmin. You don't have to actually do it as PhpMyAdmin will create one itself for its internal usage.

Now you have LAMP installed and you can proceed to its further configuration. To check if things went OK navigate to http://localhost/phpmyadmin in your browser. You should get to PhpMyAdmin login page where you need to enter root user and MySQL root password to start working with the database.

That's the basics of installing LAMP on deb-based linux systems.






  1. Ken
    2013-05-30 03:49:03
    Good job! thanks
  1. Olivedev
    2016-11-07 14:58:00
    Since this is LAMP stack we are talking about, shouldn't you explain how to install MySQL instead of PHPMyAdmin? I also heard that PHPMyAdmin is not as secure as MySQL. There are risks of SQL injection may be. For MySQL, there is a guide in this tutorial that you can follow: https://www.cloudways.com/blog/install-lamp-on-debian/

Got a comment?

captcha =

Categories

  1. System (20)
    1. FreeBSD (5)
    2. Linux (9)
  2. Email (2)
  3. DNS (2)
  4. Databases (1)
  5. WebServer (27)
 
Copyright © 2012-2015 HowToUnix - *nix Howtos and Tutorials
All Rights Reserved.