Skip to main content

LAMP 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. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP.

First update your os
#apt-get update

Install apache2 package
#apt-get install apache2

Install php (Here iam using php 7.0) and dependencies
#apt-get -y install php7.0 libapache2-mod-php7.0

To test php support for apache,create a info.php file in /var/www/html with following comtent
#vi /var/www/html/info.php
<?php
Phpinfo();
?>

Now change the ownership
#chown www-data:www-data /var/www/html/info.php

Now restart the service
#service apache2 restart

Now open your browser and check http://your ip/info.php
We can see php info page



Installing mariadb
#apt-get -y install mariadb-server mariadb-client

mysql_secure_installation

You will be asked these questions:
Enter current password for root (enter for none): <-- press enter
Set root password? [Y/n] <-- y
New password: <-- Enter the new MariaDB root password here
Re-enter new password: <-- Repeat the password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y

Type these required information and after these try to login
#mysql -u root -p
type the password and login

Install the APCu  PHP cache to speed up PHP
APCu is a free PHP opcode cacher for caching and optimizing PHP intermediate code. It is strongly recommended to have an Opcache installed to speed up your PHP page.
#apt-get -y install php-apcu

Enable the SSL website in Apache
SSL/ TLS is a security layer to encrypt the connection between the web browser and your server. Execute the following commands on your server to enable https:// support. Run:
#a2enmod ssl
#a2ensite default-ssl

And then restart Apache Service and mysql service
#systemctl restart apache2
#systemctl restart mysql