LAMP Basic on Ubuntu 16.04. Short Essential Version

By | May 16, 2017
Ensuring Trust and Security: A Guide to SSAE 16 Compliance

LAMP (Basic) on Ubuntu 16.04. Short Essential Version

LAMP (Linux, Apache, MySQL, PHP)

The more detailed version of this LAMP (Basic) Installation on Ubuntu 16.04 Server can be found here…

Basic Server Configuration

Set root password

sudo passwd root

Enter sudo password, then new root password twice at each prompt

Update Ubuntu 16.04

sudo apt-get update
sudo apt-get upgrade

Check and Edit Network Configuration

sudo nano /etc/network/interfaces
iface eth0 inet static
        address 192.168.1.10
        netmask 255.255.255.0
        network 192.168.1.1
        broadcast 192.168.1.255
        gateway 192.168.1.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8 8.8.4.4
        dns-search search google-public-dns-a.google.com search

Restart Network Service

sudo ifdown eth0 && ifup eth0

Log Into Root Terminal

sudo su --

Download, Install, and Setup Apache 2 Web server

apt-get install apache2 apache2-utils

Ensure Function

Browser: http://192.168.1.10

Create web site directories and set ownership and permissions

mkdir -p /var/www/mydomain.home/public_html
usermod -a -G www-data maint
chown www-data:www-data /var/www/mydomain.home/public_html
chmod -R 755 /var/www/mydomain.home/public_html

Create virtual host configuration file and configure web information for web site

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mydomain.home.conf
nano/etc/apache2/sites-available/mydomain.home.conf

mydomain.home.conf configuration information

<VirtualHost *:80>
    ServerAdmin user@legitemail.com
    ServerName web.mydomain.home
    ServerAlias www.mydomain.home
    DocumentRoot /var/www/mydomain.home/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable new virtual host

a2ensite mydomain.home.conf

Disable Apache default site

a2dissite 000-default.conf

Restart apache service

systemctl restart apache2

Test new virtual host. Create test index.html page

nano /var/www/mydomain.home/public_html/index.html

Copy html into the file

<html>
  <head>
    <title>Welcome to my domain home page !</title>
  </head>
  <body>
    <h1>Success!  The mydomain.home virtual host is working!</h1>
  </body>
</html>

Check function, with web browser navigate to http://192.168.1.10 and ensure that the new test page is displayed

Install and Configure MariaDB

apt-get install mariadb-client mariadb-server openssl binutils

Fire off secure installation and answer questions

mysql_secure_installation

Answers for Secure Installation Questions
 
Enter current password for root (enter for none): -- (enter)
Set root password? [Y/n] -- (y)
New password: -- (desiredpassword)
Re-enter new password: -- (desiredpassword)
Remove anonymous users? [Y/n] -- (y)
Disallow root login remotely? [Y/n] -- (y)
Reload privilege tables now? [Y/n] -- (y)

Restart mariadb service

systemctl restart mysql

Ensure SQL service is functioning correctly

netstat -tap | grep mysql

Install, Enable, and Test PHP 7

apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-gd php7.0-json php7.0-cli php7.0-curl libapache2-mod-php7.0

Enable Apache PHP Module

a2enmod php7.0

Test PHP by creating a phpinfo page

nano /var/www/mydomain.home/public_html/phpinfo.php

Copy the following code snippet into the page

## Use the following code snippet

<?php phpinfo(); ?>

Ensure PHP is functioning.

Use browser to navigate to http://192.168.1.10/phpinfo.php

PHP Information and Configuration page should display

Finished

For a more detailed version, check out the detailed LAMP (Basic) Installation on Ubuntu 16.04 Server found here…

 

References

The Perfect Server – Ubuntu 16.04 (Xenial Xerus) with Apache, PHP, MySQL, PureFTPD, BIND, Postfix, Dovecot and ISPConfig 3.1

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

Install LAMP on Ubuntu 16.04

Leave a Reply

Your email address will not be published. Required fields are marked *