Deploying With Script

This guide shows you how to manually deploy LaraOne CMS to a server you control by using a simple deploy script written in Python and Bash. Script is powered by Fabric 1.x which is a library that allows bash commands to be remotly executed via ssh protocol. The script once configured saves time for all future deployments. Instead of manually configuring new server, just run the script and have a server and CMS provisioned in no time.

The script it self is released under MIT license and can be modified for your own needs and purposes.

What the Script Does

As it is right now the deploy script takes around 5 minutes to run and install nginx, mysql 5.7, php7.3, all required php7.3 extensions, setup a firewall, pull LaraOne from Github, run composer install to install vendor folders for Laravel, setup correct folder permissions for www-data user.

Modify the script

If you do not need all of the above, or if you would like apache or some other packages, script is written in Python and Bash and is really easy to modify for custom purposes. Feel free to update it for your own needs.

Local Prerequisites

The following has to be in place on your local machine for deploy script to execute successfuly

  • Python 2.7.17 installed
  • Fabric 1.x installed

Note: Prerequisites part has to be done only once, it takes around 4-8 minutes.

Server

You'll need SSH access to your server. Cloud providers like DigitalOcean, Linode and Vultr allow you to easily attach ssh keys to newly provisioned Virtual Private Servers.

If you do not have SSH keys created yet checkout these links for a guide Windows and here for Linux and MacOS

Note: Script has been tested on Ubuntu 18.x only. If you plan using another OS to host your website, you may need to modify the script a bit.

Install Python

Start by installing Python v.2.7.17 Grab the installer that works for your OS. Once installed you will have access to Python 2.7.17 and pip which is a Python package manager.

Install Fabric

Fabric is a library which allows remote Python execution. Complete installation guide for Fabric is here: http://www.fabfile.org/installing-1.x.html

Inside CLI run this command to install Fabric 1.x

    pip install -e 'git+https://github.com/fabric/fabric@v1#egg=fabric'

Pull the repo from Github

Start by checking out the script from github to your local machine

    https://github.com/laraone/laraone-deploy-script

Inspect the script

Using your favorite editor open the folder you just checked out from github and take a look at fabfile.py to see what the script does. Script is pretty simple and can be modified easily to suit your own deployment needs.

SSH Config

Before you can run the script you need SSH access to your server. Make sure you have that first. On your local machine inside a .ssh folder wherever it may be on your OS you create a file named config and put this text inside of it.

Note: On Win10 it is usually under C:\Users\username\.ssh

Inside .ssh folder and config file just created insert this text

    Host replace_with_server_ip
      IdentityFile ~/.ssh/id_rsa

Note: Config file will allow Fabric to connect to your server. Update the replace_with_server_ip text with the IP of your server. id_rsa should be the private ssh key that your server will recognize and allow you to connect to it via ssh protocol.

Run the Fabric script

Execute this command

    fab build_image:domain=mydomain.com,password=dbPasswordHere -H SERVER_IP_HERE

Script will take 5 minutes to execute. Once its done you can proceed

WIP

This guide is Work In Progress