Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04

A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps.

Prerequisites
 initial server setup for Ubuntu 16.04. on-root user account with sudo privileges set up on your server.

Step 1: Install Apache and Allow in Firewall
We can install Apache easily using Ubuntu's package manager, apt. 
For our purposes, we can get started by typing these commands:


  • sudo apt-get update
  • sudo apt-get install apache


Adjust the Firewall to Allow Web Traffic

If you look at the Apache Full profile, it should show that it enables traffic to ports 80 and 443:
  • sudo ufw app list
Output
Available applications: Apache Apache Full Apache Secure OpenSSH
If you look at the Apache Full profile, it should show that it enables traffic to ports 80 and 443:
  • sudo ufw app info "Apache Full"
You can do a spot check at: http://your_server_IP_address 


Step 2: Install MySQL


To install MySQL. MySQL is a database management system. Basically, it will organize and provide access to databases where our site can store information.

sudo apt-get install mysql-server

Step 3: Install PHP


PHP is the component of our setup that will process code to display dynamic content. It can run scripts, connect to our MySQL databases to get information.

  • sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
This should install PHP without any problems. We'll test this in a moment.

Step 4: Test PHP Processing on your Web Server


We will call this script info.php. In order for Apache to find the file and serve it correctly, it must be saved to a very specific directory, which is called the "web root".
In Ubuntu 16.04, this directory is located at /var/www/html/. We can create the file at that location by typing:
  • sudo nano /var/www/html/info.php
This will open a blank file. We want to put the following text, which is valid PHP code,
info.php
The address you want to visit will be:

http://your_server_IP_address/info.php

Yu have a LAMP stack installed, you have many choices for add more modules or enbale SSL.

Comments

Popular Posts