A quick tutorial on how to Install LAMP on Ubuntu.
Without a big instruction, let’s get to work right away. LAMP means Linux Apache MySQL PHP, which is exactly what we are going to install now.
Table of Contents
- Step 1 – Update your system
- Step 2 – Installing Apache2
- Step 3 – Installing MySQL
- Step 4 – Installing PHP
- Step 5 – Testing the configuration and wrapping up
Step 1 – Update your system
First, we are making sure you are up to date by running:
sudo apt-get update -y && sudo apt-get upgrade -y
Code language: JavaScript (javascript)
If you are running an AWS instance, you will get the following warning:
Confirm with “Keep the local version currently installed“
Step 2 – Installing Apache2
Now that we have the L in place, it’s time to install the A.
sudo apt-get install apache2
Code language: JavaScript (javascript)
You can verify if that worked by entering your server’s IP into a browser, you should see something along those lines:
Step 3 – Installing MySQL
Alright, time for the M.
sudo apt-get install mysql-server
Code language: JavaScript (javascript)
During the installation, you will be prompted to enter the MySQL root password. Make sure to write that down.
Now we are also going to secure our installation:
sudo mysql_secure_installation
- Enter the root password you entered before.
- Now you get asked a couple of questions, answer as below:
- Enter current password for root (enter for none): Enter your root password
- Would you like to setup VALIDATE PASSWORD plugin? N
- Change the password for root? [Y/n] N
- Remove anonymous users? [Y/n] {ENTER}
- Disallow root login remotely? [Y/n] {ENTER}
- Remove test database and access to it? [Y/n] {ENTER}
- Reload privilege tables now? [Y/n] {ENTER}
- That’s it. Let’s continue with PHP.
Step 4 – Installing PHP
And last but not least, the P.
For PHP, we need to install slightly more PHP with all its dependencies:
sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-intl php-pear php-imagick php-imap php-mcrypt php-memcache php-pspell php-recode php-sqlite3 php-tidy php-xmlrpc php-xsl php-mbstring php-gettext
Code language: JavaScript (javascript)
Let’s restart apache2:
sudo /etc/init.d/apache2 restart
Step 5 – Testing the configuration and wrapping up
To test your configuration, we first need to create the phpinfo.php file.
sudo nano /var/www/html/phpinfo.php
Code language: JavaScript (javascript)
Paste the following text into it:
<?php phpinfo(); ?>
Code language: HTML, XML (xml)
Save with CTRL+O and exit with CTRL+X.
If you now open http://YOURSERVERIP/phpinfo.php in your web browser, you should see the PHP configuration page:
And that concludes this tutorial. Now you can configure your server for whatever your needs are.