- Unix (Mac & Ubuntu tested)
- A CircleCI account
- Access to a LAMP server (MySQL and PHP are not mandatory for this setup)
- Access to a terminal window
- Culturize app installed on a client to push URI's to this repo
- First fork and then clone the Culturize-Back-end-CircleCi locally:
git clone https://github.com/yourusername/CultURIze-Back-end-CircleCI
.
-
Go to https://circleci.com/ select Log in with GitHub.
-
Add projects to your CircleCI account (in the left pane) and select the Culturize-Back-end-CircleCi repository. repository. Select Set Up Project and select Start Building
-
Choose Start Building. It will fail. Do not worry about that.
-
In the Workflows screen, click the little cogwheel next to the name of the repository we just added to the workflows.
-
We now need to create some SSH keys so CircleCI can deploy your .htaccess-files on your webserver. Open a terminal window and copy paste the following command:
ssh-keygen -m pem -f changethisname
(changechangethisname
to a name of your choice). Do not enter a passpharse and save the files in your.ssh
directory. On Mac and Linux this is~/.ssh/
, on windows this should beC:\Users\yourusername\.ssh\
. This command will create an ssh key-pair: a public and a private key. Your private key is calledchangethisname
, The public keychangethisname.pub
. We will use the private key in CircleCI and the public key on the webserver. More information about SSH Keys pairs. -
Back to CircleCI. Open the SSH-Permissions tab in the left pane and click Add SSH-key.
Paste the content of the private key we just created (changethisname
) in the Private Key field.
A simple way to do this, is to open the changethisname
file with a text editor and copy paste the complete content of the file in the Private Key field. Enter the host name of the webserver in the Hostname field. Finally, click Add SSH-Key.
- Scroll up in the left menu pane and select Environment Variables under Build Settings.
We are going to add two variables. Click Add Variable and enter SSH_HOST
under name. Under value, enter the IP-address (e.g. 172.16.254.1
) or host (e.g. www.example.org
) of the web server.
After selecting Add Variable again, the variable should be added. Next, enter the second variable with name SSH_USER
and the name of the user that has access to the web server.
After selecting Add variable, both items should be added to the list.
-
Now clone the repository in the home folder of your webserver (
cd ~ && git clone https://github.com/yourusername/CultURIze-Back-end-CircleCI
), and copy or move thedeploy.sh
script to your home folder on the server (cd CultURIze-Back-end-CircleCI && mv .circleci/deploy.sh ~
). -
Add the content of the
changethisname.pub
key file to theauthorized_keys
file on the web server. The simple way to do this is to open thechangethisname.pub
key with a text editor and copy paste everything in theauthorized_keys
file. On the server, usevim
ornano
to open theauthorized_keys
file. If you already have a key there, paste the new key after a new line (enter). -
You can now push the
.htaccess
files through the Culturize app to the forked Culturize-CircleCi-Backend repository on your account. The.htaccess
-files will automatically be moved to the /var/www/ folder on the web server and so your PID's are live immediately. Keep in mind that you have to be the owner of the repository you are pushing to.
- If you run into problems where your URI's are not being served. It may be a permission issue, check this source and scroll down to To set file permissions for more information.
- Getting feedback about the CircleCi build status: even though CircleCi is not being used to test build software, it is still possible to use the CircleCi dashboard to get feedback when something does not work in the workflow, specifically copying files to the webserver.
- Click on the latest job status.
- At the bottom of the job detail page you will find an output of the processes that failed.