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
[simterm]sudo passwd root[/simterm]
Enter sudo password, then new root password twice at each prompt
Update Ubuntu 16.04
[simterm]sudo apt-get update[/simterm]
[simterm]sudo apt-get upgrade[/simterm]
Check and Edit Network Configuration
[simterm]sudo nano /etc/network/interfaces[/simterm]
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
[simterm]sudo ifdown eth0 && ifup eth0[/simterm]
Log Into Root Terminal
[simterm]sudo su -[/simterm]
Download, Install, and Setup Apache 2 Web server
[simterm]apt-get install apache2 apache2-utils[/simterm]
Ensure Function
Browser: http://192.168.1.10
Create web site directories and set ownership and permissions
[simterm]mkdir -p /var/www/mydomain.home/public_html[/simterm]
[simterm]usermod -a -G www-data maint[/simterm]
[simterm]chown www-data:www-data /var/www/mydomain.home/public_html[/simterm]
[simterm]chmod -R 755 /var/www/mydomain.home/public_html[/simterm]
Create virtual host configuration file and configure web information for web site
[simterm]cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mydomain.home.conf[/simterm]
[simterm]nano/etc/apache2/sites-available/mydomain.home.conf[/simterm]
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
[simterm]a2ensite mydomain.home.conf[/simterm]
Disable Apache default site
[simterm]a2dissite 000-default.conf[/simterm]
Restart apache service
[simterm]systemctl restart apache2[/simterm]
Test new virtual host. Create test index.html page
[simterm]nano /var/www/mydomain.home/public_html/index.html[/simterm]
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
[simterm]apt-get install mariadb-client mariadb-server openssl binutils[/simterm]
Fire off secure installation and answer questions
[simterm]mysql_secure_installation[/simterm]
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
[simterm]systemctl restart mysql[/simterm]
Ensure SQL service is functioning correctly
[simterm]netstat -tap | grep mysql[/simterm]
Install, Enable, and Test PHP 7
[simterm]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[/simterm]
Enable Apache PHP Module
[simterm]a2enmod php7.0[/simterm]
Test PHP by creating a phpinfo page
[simterm]nano /var/www/mydomain.home/public_html/phpinfo.php[/simterm]
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
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04
Install LAMP on Ubuntu 16.04