Installing Statamic on Ubuntu 16.04

More of a memo to myself than a tutorial, but after countless changes of server I find myself always searching for clear tutorial each time so I have decided to create one that suits my needs. Maybe it will be helpfull to others.

  1. follow this tutorial on how to set up your droplet initial set up
    I stopped at step 4 and did not install a Public Key
  2. Then I went the usual way installing Apache2
    sudo apt-get update
    sudo apt-get install apache2
  3. You then need to install PHP
    sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

    and then run this :

    sudo systemctl restart apache2.service
  4. Find this site.conf file here

    sudo nano /etc/apache2/sites-available/000-default.conf

    and apply those changes to it replacing Example.com with your own URL

    
    <VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/
     ServerName example.com
     ServerAlias www.example.com
    
     <Directory /var/www/html/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>
    
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

5. Enable the rewrite module 

sudo a2ensite 000-default.conf
sudo a2enmod rewrite

and restart apache see above.
6. Grant correct permission to the USER

usermod -a -G www-data USER
chown -R USER:www-data /var/www/html

7. Use letsencrypt to secure your serve and serve your website through HTTPS 
I used the tutorial from Digital Ocean [here](https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04)
8. Don't forget to change the apache2 conf file to serve PHP first 

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

and have it display like that with index.php first :
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

and few more details [here for LAMP set up](https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04)
9. That sould be it for the server aspect of things now you should just follow the Statamic Install tutorial on [statamic](https://docs.statamic.com/installing). 

Note not to forget to change the files permissions and to upload the sample.htaccess file and rename it to .htaccess. 

Enjoy