Have a Question?

If you have any question you can ask below or enter what you are looking for!

Installing Linux, Apache, MySQL, PHP (LAMP) Stack on Debian

Apache

There are more than 50% of all web servers in the world running Apache, making it one of the most popular web server software.

It is imperative that you update the repositories prior to installing Apache. Do this by running:

apt-get update

Installing Apache

  1. Run the command:
apt-get install apache2

You’ll be prompted to confirm that you want to continue the installation [Y/N]

  1. Make sure that Apache has been installed by opening your preferred browser and typing in the IP address of your server in the address bar. (e.g., http://98.76.54.321)

You should see a page like this:

In case you aren’t sure what your server’s IP address is, run this command:

ifconfig eth0 | grep inet | awk ‘{ print $2 }’

Your IP address should then be displayed:

MySQL

MySQL is one of the most common and widely used database systems. After you have successfully installed Apache, you can proceed with MySQL installation.

Installing MySQL

  1. Run the command:
apt-get install mysql-server

You’ll be prompted to confirm that you want to continue the installation [Y/N]

  1. During the installation, you will be required to set a root password.
  1. Run the installation script to setup MySQL
mysql_secure_installation

You’ll be asked if you want to change your root password. Type ‘N’ since you have already set a root password previously.

There will be another series of prompts; the easiest way to answer is [Y] to all of them.

PHP

PHP is a widely-used server-side scripting language designed for web development and is also used as a general-purpose programming language.

Installing PHP

This example shows how to install PHP5.

  1. Run the command:
apt-get install php5 php-pear php5-suhosin php5-mysql

Note: If you have Debian 7 running on your VPS, you need to exclude php5-suhosin from the list.

Next, you will be required to accept to prompts. Type ‘Y’ to continue.

  1. Restart Apache by running this command:
service apache2 restart

Wrapping Up

  1. Create a file to test:
nano /var/www/info.php
  1. Type this in the document:
phpinfo();
?>
  1. Save the document by pressing Control+X, then Y and Enter.

To check that PHP is working, type in the IP of your server plus ‘/info.php’. For example, if your IP was 12.34.56.789, you must type in 12.34.56.789/info.php. You should see a message that looks like this:

Congratulations – your LAMP system should now be fully functional!

Leave a Reply

You must be logged in to post a comment.