Deploying to Amazon EC2 - adampresley/texo-cms GitHub Wiki
To deploy your application you will first need to setup a new Amazon EC2 instance. Follow the documentation at Amazon AWS to setup a new Ubuntu server instance. Once that is done you can follow these steps to install a new server environment. If you have already done this and just want to deploy code changes skip to the section labeled Uploading The Application.
Prerequisites
You will need to have two environment variables setup on your local machine so you can communicate with your Amazon EC2 instance. This can be done on a terminal using the following.
$ export AWS_ACCESS_KEY_ID="MYSECRETID"
$ export AWS_SECRET_ACCESS_KEY="MYSECRETACCESSKEY"
In the above sample MYSECRETID and MYSECRETACCESSKEY is provided by Amazon. You will also need your PEM key file handy to authenticate the Fabric script to Amazon.
Setting up a Server
This section assumes you have the code on your local machine and setup to run. First change directory to bin folder. Then open a terminal.
$ source ../virtualenv/bin/activate
$ fab amazon:keyFile=/path/to/keyfile.pem build setupAppRequirements setupAppDirectory:user=user setupVirtualEnvironment setupMySQL uploadApp setupUpstartJob:user=user setupNginx:port=8080,serverName=domain.com
In the above command there are 4 pieces of information you may customize:
- The path to your Amazon PEM key file
- The user specified in the tasks setupAppDirectory and setupUpstartJob. Often Amazon Ubuntu instances default to the user ubuntu
- The port Texo runs on. Nginx will run on port 80 and reverse proxy to the port you specify here
- The server name attribute should be your domain name that Nginx will serve
Uploading The Application
To just upload the application perform the following.
$ source ../virtualenv/bin/activate
$ fab amazon:keyFile=/path/to/keyfile.pem build uploadApp
Restarting the Texo CMS Service
Texo CSM, on Ubuntu, runs using an Upstart job. To restart the service from your local machine make sure you have exported your Amazon key info and have activated your virtual environment, then perform the following in a terminal.
$ fab amazon:keyFile=/path/to/keyfile.pem restartTexoService