d
An igniting portfolio theme designed
to help you leave quite a mark.
Back to Top

Install a STACK LAMP on Linux/Ubuntu 16.04/18.04

Apache installation

Install the apache2 package and modify the contents of apache root folder (/var/www/html)

sudo apt install apache2
Add a Virtual Host
Create the file for the site we want to add.

All site configuration files are in the /etc/apache2/ sites-available folder. In our case we will add the file /etc/apache2/sites-available/grs.pt.conf with the command:

sudo nano /etc/apache2/sites-available/grs.pt.conf
The contents of the grs.pt.conf file should look something like:
<VirtualHost *:80>
     ServerAdmin     email@domain.pt
     ServerName      grs.pt
     ServerAlias     www.grs.pt
     DocumentRoot    /var/web/grs.pt/httpdocs
     DirectoryIndex  index.html index.htm 
     ErrorLog        /var/web/grs.pt/error_grs.pt.log
</VirtualHost>
Create the folder defined in DocumentRoot:
sudo mkdir -p /var/web/grs.pt/httpdocs
Activate the site we created using the command:
sudo a2ensite grs.pt
Reload apache info/settings
sudo systemctl reload apache2
Allow apache to use /var/web folder:

Add to the /etc/apache2/apache2.conf file the following content:

sudo nano /etc/apache2/apache2.conf
<Directory /var/web/>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

and then:

sudo systemctl reload apache2

Install PHP

Install the required package:
sudo apt install libapache2-mod-php7.0
Let’s try the php

Create a file inside the /var/www/html/ folder named php.php that contains the following code:

<?php
  phpinfo();
?>

In any browser follow http://serverIP/php.php and the result should look something like:

For security reasons you should delete the php.php file at the end of the query.

(OPTIONAL) Once tested we can start using scripts:
  • http://www.hotscripts.com/
  • http://gscripts.net/
  • http://www.phpjunkyard.com/
  • http://www.hotscripts.com/listing/multi-format-countdown/

Install MySQL server

The packages:
sudo apt install mysql-server php7.0-mysql phpmyadmin

During mysql-server installation we will set mysql root password
During the phpmyadmin installation consider all options by default and when choosing the web server activate the apache2 option (with the spacebar) and then go to OK.

Note:
For those who did not enable the apache2 option in due course, you should run the following command to reconfigure phpmyadmin:

sudo dpkg-reconfigure phpmyadmin

Nota 2:
Have you been wrong in something? Need to reinstall?

sudo apt-get purge mysql-*
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt autoremove
sudo apt autoclean
MySQL Management

To administer the databases use the address in any browser:
http://serverIP/phpmyadmin

 

Credits: https://www.carrondo.net

Review and tested by: Cristiano Costa

Post a Comment