Skip to content

Instantly share code, notes, and snippets.

@vinceallenvince
Last active April 8, 2017 08:55
Show Gist options
  • Save vinceallenvince/1a2e619606cc9ac1e5db to your computer and use it in GitHub Desktop.
Save vinceallenvince/1a2e619606cc9ac1e5db to your computer and use it in GitHub Desktop.
Setup a Siteleaf site with a corresponding Gmail account on DigitalOcean

Setup Siteleaf site and Gmail on DigitalOcean

I recently setup a Siteleaf site and corresponding Gmail account via DigitalOcean. It occured to me these steps may be useful to people looking to do the same.

If you've already created your Droplet, installed vsftpd and apache, skip to step 4.

DO - do this step on Digital Ocean
SL - do this step on Siteleaf
GA - do this step on Google Apps for Business
REG - do this at your domain's registrar

  1. DO: Create a Droplet with a Debian image and SSH keys. If you haven't created ssh keys already, follow the instructions below. If you want to manage multiple id_rsa files, name your files something that corresponds to your Digital Ocean (ie. id_rsa_DIGITALOCEAN)

    http://www.digitalocean.com/community/articles/how-to-use-ssh-keys-with-digitalocean-droplets

    If you are managing multiple keys, on your computer, update your ssh config to include a Host that points to your Droplet's IP address and the corresponding id_rsa file.

     #DIGITALOCEAN
     Host do-WEBPROJECTS
     HostName your-droplet-ip-address
     User root
     IdentityFile ~/.ssh/id_rsa_DIGITALOCEAN
    

    Login to your droplet using the following command:

     ssh do-WEBPROJECTS
    
  2. DO: setup vsftpd (FTP server) https://www.digitalocean.com/community/articles/how-to-set-up-vsftpd-on-ubuntu-12-04

     sudo apt-get install vsftpd
    

    Update the configuration file.

     sudo nano /etc/vsftpd.conf
    

    Find the following lines and confirm these settings:

     anonymous_enable=NO
     local_enable=YES
     write_enable=YES
     chroot_local_user=YES
    

    Restart the server.

     sudo service vsftpd restart
    
  3. DO: Install apache

     sudo apt-get update
     sudo apt-get install apache2
    
  4. DO: Point your domain to your Droplet by adding the DNS record from your DO control panel. You should add both yourdomain.com and www.yourdomain.com.

  5. REG: Add the following nameservers at your domain's registrar.

     NS1.DIGITALOCEAN.COM
     NS2.DIGITALOCEAN.COM
     NS3.DIGITALOCEAN.COM
    
  6. DO: Add a new user for the site.

     adduser username
    
  7. DO: Install fail2ban

  8. DO: Setup a virtual host

    IMPORTANT: Create a folder for the document root without creating a public_html folder. We'll eventually use a symlink to point to the content.

     sudo mkdir -p /var/www/yourdomain.com/
    

    Give read privileges to all users.

     sudo chown -R $USER:$USER /var/www/yourdomain.com/
    
  9. DO: Jail the user to their folder in /home and only allow them to write to public_html.

    We'll upload our files here:

     mkdir /home/username/public_html
    

    Remove write privileges to user's home folder to allow vsftpd login.

     chmod a-w /home/username
    

    We enable write privileges on a subfolder.

     chown username:username /home/username/public_html
    

    Allow all users to read from the subfolder.

     sudo chmod -R 755 /home/username/public_html
    
  10. DO: Point to our site's content from the document root via a symlink.

     ln -s /home/username/public_html /var/www/yourdomain.com/public_html
    
  11. DO: Create virtual host file and enable virtual hosts.

    Create a new virutal host file.

     sudo cp /etc/apache2/sites-available/000-default /etc/apache2/sites-available/yourdomain.conf
    

    Open the file.

     sudo nano /etc/apache2/sites-available/yourdomain.conf
    

    Update the following in the host file.

     <VirtualHost *:80>
         ServerAdmin [email protected]
         ServerName www.yourdomain.com
         ServerAlias yourdomain.com
         DocumentRoot /var/www/yourdomain.com/public_html
         [...]
     </VirtualHost>
    

    Activate the host.

     sudo a2ensite yourdomain.conf
    

    Restart apache.

     sudo service apache2 restart
    
  12. SL: Setup FTP publishing via Siteleaf.

    Create a new site and go to Settings -> Hosting -> FTP

    Enter the following in the FTP fields:

         Domain: yourdomain.com
         Host: yourdomain.com
         FTP Username: username
         Password: password
         Path: /public_html
    

    Click the refresh path icon to check the FTP connection.

    If you see a checkmark, click 'Save'. If you see an error, double check your FTP settings.

    When you're ready to push your content, click 'Publish changes' at the top right.

    Visit yourdomain.com in a web browser to view your changes.

  13. DO: After uploading files, make all subfolders of public_html readable.

     find . -type d -exec chmod -R 755 {} +
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment