Install LAMP ubuntu 16.04

Install and configure LAMP

Install apache2:

sudo apt-get install apache2

Set Global ServerName to Suppress Syntax Warnings. Append in /etc/apache2/apache2.conf (bottom of the file):

ServerName IP_ADDRESS

Launch the command:

sudo apache2ctl configtest

you should receive the message Syntax OK.

Restart Apache to implement the changes:

sudo /etc/init.d/apache2 restart

Adjust the Firewall to Allow Web Traffic

sudo ufw app list

http://your_server_IP_address to see the welcome page from apache.

Install MySQL

sudo apt-get install mysql-server

Set a secure password for the root user and launch the script to remove some dangerous defaults and lock down access to our database system

sudo service mysql restart //restart the service
mysql_secure_installation

try the connection to the db with:

mysql -u root -p

Install PHP

sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

Modify the way that Apache serves files when a directory is requested serving php file before instead of html edit the file:

/etc/apache2/mods-enabled/dir.conf

And insert the php index file before:

<IfModule mod_dir.c>
    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

restart apache: sudo /etc/init.d/apache2 restart

test php with a phpinfo page.

Resources:

Add a Python web server on the fly to our project

If you are on linux / OsX or inside a phyton environment you can start a web server on the fly inside your project simply recalling an alias from the terminal in your project folder.

You have to edit your bash profile and add the following line:

alias server='open http://localhost:8000 && python -m SimpleHTTPServer'

This feature is very useful when you are working in local host with a browser that disables the origin load by default (i.e. Chrome).

inserted the alias inside the .bash_profile, refresh with the following command:

$ source ~/.bash_profile

inside your project folder you just type $ server to open your web server.