An ansible role for Anchor CMS

Miguel David
Sep 3, 2018 · 2 min read
  • How to install Anchor CMS
  • How to write an ansible role ready for Ansible Galaxy

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!


Originally published at tech.migueldavid.eu on September 3, 2018.

Miguel David

Written by

Made in Portugal, married to an American. Likes IT Infrastructure, cloud, automation, travel, photos, and sadly, politics. Co-founder of a food tour.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade