Miguel David |||

An ansible role for Anchor CMS

What you can learn from this post

  • How to install Anchor CMS
  • How to write an ansible role ready for Ansible Galaxy

What we want to do

In broad strokes, this is what we want to do:

  1. Update your system apt-get update && apt-get upgrade

  2. Install the required packages apt-get install unzip vim apache2 libapache2-mod-php5 mysql-server php5-curl php5-mcrypt php5-gd php5-mysql

  3. Secure your mysql install

  4. Edit /root/.my.cnf in case you want to get into Mysql from the console without typing a password vim /root/.my.cnf

[client]
user = root
password = <YourPassword>
  1. Create the database To get in: mysql To create the database: mysql> create database anchor; quit

  2. Check your firewall to allow for ports SSH and HTTP outbound ufw status or iptables -nvL

  3. Get anchor cd /var/www/html; wget http://anchorcms.com/download -O anchor.zip; unzip anchor.zip

  4. Adjust permissions chown -R www-data:www-data anchor-cms

  5. Setup apache to allow for .htaccess sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf

  6. Enable apache modules a2enmod rewrite

  7. Add the .htaccess to the base directory ( /var/www/html/anchor-cms/.htaccess )

Options -indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
  1. Restart services service apache2 restart; service mysql-server restart

  2. Go to http:/// (or http://localhost:8080 in case of Vagrant) to start the installation.

Now with Ansible

So I spent an afternoon and got it done using Ansible! This is version 1 so I’m sure it can be vastly improved. Oh! And it has a Vagrantfile in case you want to try it out locally with vagrant up.

You can see the code here or the Galaxy role here!

There is one step that I could not automate because it has to be done after the configuration and installation process of Anchor itself which you can do manually:

rm -rf /var/www/html/anchor-cms/install

Enjoy!

Up next New blog, new life Welcome! This blog has had several iterations over the years. Most of its life was in a self hosted WordPress, a bit in Anchor, a bit in Ghost and Podcasts I listen to I was asked the other day by a friend going on a long trip which podcasts I listen to. I typically listen to them while running, but they’re all
Latest posts Stop before you’re stopped Today I learned about git and permissions Today I learned about view My git flow Using multiple versions of kubectl on macOS Merging two MySQL (or MySQL compatible) databases in AWS using DMS Inspired Recommendations for Portugal God is dead (and we are suffering from it) Advice to my unborn child: be a plumber and an artist On light and shadow You can usually do more/better than you think you can Upkeep Comparing myself to others Fear, Procrastination. Procrastination, Fear Liberalism and a new system Chores Finding my calm place Turning 38 Privilege Humbling Habits Frustration The miracle of the blank page On being late Love is the base of it all A letter to my dead grandfather Self imposed stress Rent the world Start at 6:30 How to get multiple domains pointing to GitHub Pages using Cloudflare