Home / Snippets / Commands To Install LAMP Stack on Ubtuntu 16.04 (Short Guides)
Commands To Install LAMP Stack on Ubtuntu 16.04 (Short Guides) cover

Commands To Install LAMP Stack on Ubtuntu 16.04 (Short Guides)

165

2 years ago

0 comments

In this short snippet, you will learn all of the commands to install the LAMP stack on Ubuntu 16.04 so let's get started.

Step 1: Register VPS


You can either register Virtual Private Server (VPS) from Hetzner and SSH into the machine.

Step 2: Install Apache


To install Apache you can run the command below. The first one is to update and get the latest packages on Ubuntu and the 2nd one is to install apache2.
sudo apt-get update
sudo apt-get install apache2
Once it's installed configure apache using the command below.
sudo nano /etc/apache2/apache2.conf
From within the file add the following config. Do note that you need to place your server IP which you can retrieve from the VPS provider dashboard.
ServerName server_domain_or_IP
Test the config and restart apache.
sudo apache2ctl configtest
sudo systemctl restart apache2
Next, configure the firewall to allow incoming traffic by using the command below.
sudo ufw allow in "Apache Full"

Step 3: Install MySQL


The next step is to install the MySQL database and you can install it easily using the command below.
sudo apt-get install mysql-server
To fully complete the installation, run the command to display the configuration wizard. Within the installation configuration you will be prompted for the user name, password and etc so do read carefully on that.
mysql_secure_installation

Step 4: Install PHP


Next, you will have to install PHP by running the following command. Do note that the other packages / library such as "php-mcrypt" is necessary for PHP so it's a must to install all.
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
Now that you have it installed now we need to allow Apache to find PHP files. Do run the command below to edit the apache.
sudo nano /etc/apache2/mods-enabled/dir.conf
Then the content should be as follows. Do look at the "index.php" carefully, it's after the DirectoryIndex which means it's having more precedent.
<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>
Now to apply the changes do run the restart apache command.
sudo systemctl restart apache2
By now you will have the LAMP stack set up on your machine. Cheers and have a good one!
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this