How To Install LAMP (Linux, Apache, MySQL, PHP) On Debian 8
What is LAMP?
LAMP is a basic server installation of open source software that is also an acronym. The acronym stands for: Linux, Apache, MySQL and PHP.
The server you install this on needs to be Debian 8. This tutorial was tested and successfully completed on a VPS with Debian 8.
Step one: Update
To start the setup, we need to update the repositories on your Debian 8 install. Execute:
sudo aptitude update
If it returns with command not found, you need to install sudo. To install sudo, run:
aptitude install sudo
Now that the Debian 8 repositories are updated, we can start the LAMP install.
Step two: Install Apache
Apache is a free web server that you can use to display content over the web. It is very commonly used world wide.
To install apache, run the command:
sudo aptitude install apache2 apache2-doc
Apache will now install. Apache is the software and apache-doc is the helpful documentation for apache. We include both since its requires no extra work to have the documentation.
That all it takes! Time to do step 3 of the LAMP install.
Step three: Install MySQL
MySQL is a database that is a bit more advanced that SQLite. MySQL is very commonly used throughout the world and is used to sent and retrieve data.
To install MySQL, execute:
sudo aptitude install mysql-server php5-mysql
During the install, you will be asked to enter the root MySQL password. We do not have on set so this is where you set the root MySQL password. After setting the password, the install with finish. Next we run the MySQL installation script.
To install, run:
After executing that command, the script will ask you a few questions. The first one asks you if you would like to set the root password. You can safely hit ‘n’ then enter if you set it earlier. If you did not set the mysql root password earlier, this is your time to set it. The rest of the questions you can respond to with ‘Y’ and then enter. Below is what it should look like.
You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!
MySQL has finished installing and configuring. Its time to install PHP to finish the LAMP stack setup.
Step four: Install PHP
PHP is a very common, open source, web scripting language. PHP opens you up to more potential than using only HTML.
To install PHP, all you need to do is execute:
sudo aptitude install php5-common libapache2-mod-php5 php5-cli
Now that we have everything installed, all we need to do is restart the apache2 webserver.