Install Centurion with MAMP (PRO)

Centurion is a cool Php hybrid between a CMF and a framework. It’s quite young right now but seems promising. But boy the install process gave me a hard time, here’s how it goes.

Download Centurion

Once you’ve created a folder in which you want your code to live, open you Terminal, move to this folder and type :

git clone https://github.com/centurion-project/Centurion

This will create a new “Centurion” folder containing the application. You will need git to get that working obviously, but I’m sure you already have that. If you don’t, you can also download the source code of the project on its Github page.

Setting up Apache

If you’re not much into vhost, configuration files and that kind of stuff (like me) you might be using MAMP PRO which allows you to set up vhost really easily. This is a nice solution, unfortunately it’s not what Centurion expects so you might have some trouble doing it this way, and that’s what I’m going to explain.

Setting up your vhost is normal, set the URL, the path to the public folder of your fresh Centurion install… And that’s it.

Setting up the environment

Create a new .htaccess file in your public directory, and inside it write the following code :

setEnv APPLICATION_ENV development

This creates a variable accessible anywhere containing the name of the current environment you’re using. This is how you will switch from dev, to pre-prod, to production settings without changing all your code.

Permissions

Next step is to set the correct permissions for the right files and folders… This is an error prone task but, good for us : there’s a script to do it. In Terminal (which I assume is still openen and accessing to the root folder of your Centurion app) type the following :

./bin/zf.sh check install

This should run normally, nothing else to do here.

MySQL setup

Now it’s time for us to setup the database. Open the file

application/configs/db.ini

Around line 32 you should read [development : production]. This means the following code will be the configuration used in the development environment, which is the one we’ve set in our .htaccess earlier.

If you’re using MAMP, the only parameter you have to change is the password, that must be root instead of an empty string.

Now create a new table called “centurion” in PhpMyAdmin and you’re good to go.

Still in Terminal, run the following command :

./bin/zf.sh db install development

This will install Centurion on your database.

Your Terminal should go crazy

First time I ran this command, my Terminal went crazy. Try to see, reading the errors, if it’s about a missing “mysql.sock” file.

If so, this is a common issue, it’s fixed quite easily : this article explains how to fix it in 2 seconds and I highly recommend you bookarmk it as you will need to run that when you restart your computer and want to use mysql from a CLI script.

Run the command above again as the first attempt at installing Centurion on your DB failed, and now it should be all good.

“You’re all set” they said…

For me it was just the beginning of the horror… But it’s fine I’m here now !

Loading your website

In your web browser, open the URL you created earlier in your vhost or in MAMP PRO and, you could very well get an error that says that “APPLICATION_ENV” didn’t exist or some kind of error, happening in public/index.php.

To fix this, open up this public/index.php file and add the following lines, right after the php opening tag :

defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

Now if you releao, you should get redirected to http://your-centurion/status/. On the right, it should contain a checklist of what’s going right and wrong with your install. I had 2 warnings here : the version of apache couldn’t be found (no idea what’s going on in there) and mod_rewrite didn’t work.

 

For the first warning, I have absolutely no clue. But it doesn’t seem to be that much of a big deal so let’s just take care of the second issue : open your public/.htaccess file, which should contain you APPLICATION_ENV definition, and add the following code :

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php [QSA]

DirectoryIndex index.php 

Now refresh and mod_rewrite should be working.

Deleting the installation files

On the status page, there is a link to delete your installation files. When I clicked it something went wrong, errors, blahblahblah.

Don’t panick, just manually remove what remains of the status folder in your public

Now you’re done… almost

Now, most likely you will want to access to something, see how stuff work and everything.

 

What the doc forgets to tell you is that :

  • Centurion only handles the CMS part of stuff, not much about your content, so it’s just empty right now
  • Your admin account has been created, and it’s user : admin ; password : admincenturion
  • Your admin panel is at http://your-centurion/admin

Questions, help

I’m far from being an expert with Centurion, I just spent a painful afternoon with it so I’m probably not the right person to come for if you’re having issues of any kind.

If you made it work (in a different way than I did) on another platform or whatever and took the time to write about your process, just let me know, it could be useful to other Centurion beginners to have different resources to read.

Hopefully they will work on their doc soon and my post will be useless but for now it’s the main issue with Centurion : almost no doc, so I think this could help few lost people.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>