Setting-up Modx CMS

by Sebastien Mirolo on Sun, 16 Oct 2011

Modx is a CMS system written in PHP. As a result, unless you install the not-yet-released PHP 5.4, you will need a PHP-enabled front web server. If you planned to use nginx you will have to do so through FastCGI (remember no built-in http server before PHP 5.4) which if, out-of-luck, you are running a PHP version below 5.3 will require a patch in the PHP source tree. Modx supports mysql as a database backend but there are no mention of postgresql. As a result, I have sticked with a "traditional" LAMP stack for now.

$ apt-get install php5 php5-mysql mysql-server
# download modx revolution from http://modxcms.com
$ cd /var/www
$ unzip /home/ubuntu/modx-2.1.3-pl.zip
$ ln -s modx-2.1.3-pl modx
$ diff -u php.prev /etc/php5/apache2/php.ini
-;date.timezone =
+date.timezone = America/Los_Angeles
$ pushd /var/www/modx-2.1.3-pl
$ touch core/config/config.inc.php
$ mkdir -p assets/components
$ mkdir -p core/components
$ chown -R www-data:www-data \
      core/cache      \
      core/export     \
      core/packages   \
      assets/         \
      core/components \
      core/config/config.inc.php
$ /etc/init.d/apache2 restart
# go to http://domainname/modx/setup/ and fill the forms...
Installation type:        New
New folder permissions:   0755
New file permissions:     0644

Database type:            mysql
Database host:            localhost
Database login name:      root
Database password:        **********
Database name:            modx
Table prefix:             modx_

Connection character set: utf8
Collation:                utf8_general_ci
# for security remove the setup directory when setup is done.
$ rm -rf /var/www/html/modx-2.1.3-pl/setup/

Issues during installation

In case your browser tries to download the setup page (with type applicationx-httpd-php) instead of running the php application, most likely mod_php in not loaded through the apache configuration. It might just be as simple as restarting the apache2 server.

$ /etc/init.d/apache2 restart

I you get a mysql connection error related to the PDO such as

Connecting to database server:
MODX requires the pdo_mysql driver when native PDO is being used
and it does not appear to be loaded.

most likely pdo_mysql.so (/usr/lib/php5/20090626/pdo_mysql.so) is not loaded and it might as be as simple as installing the php5-mysql package.

$ apt-get install php5-mysql
$ /etc/init.d/apache2 restart

Moving the modx directory

I then decided to move the installation of modx to a different path. Direct result, I starred at a blank page trying to access the manager's page. With a little bit of greping around the filesystem, I managed to get it back with the following shell code.

$ for f in `grep -r '/var/www/' . \
      | grep -v 'logs' | cut -d ':' -f 1 | uniq` ; do
    mv $f $f.prev && \
    sed -e 's,prevpath,newpath,g' $f.prev > $f
done

Unfortunately, when I tried to download extras it still tried to copy files into the old place! I browsed around the mysql database but couldn't easily spot any pointers to the old paths. I finally relied on making a symlink out of the previous path.

$ tail ./core/cache/logs/error.log
$ sudo mysql -u root -p
$ SHOW DATABASES;
$ USE modx;
$ SHOW TABLES;
$ SELECT * FROM modx_site_templates;
$ SELECT * FROM modx_system_settings;
$ UPDATE modx_system_settings SET value = 'hostname' WHERE modx_system_settings.key = 'site_name';
$ ln -s newpath prevpath

I got the manager back but I was still starring at a blank page on the site itself. The BaseTemplate does is blank and my Home resource was using it. Through the interface I navigated to the extra packages, downloaded a template, and installed it.

> System
> Package Management
> FrontEndTemplate
> Templates
> your favorite
> Download

> Package Management
> Packages
> Install

> Resources
> Home
> Uses Template
> your favorite
> Save

I now had an homepage but the content listed in resources under home was not showing up. I set > "Page Settings > Container" with no luck. Following this wonderful article, I started to get a clue. The following page listed a few other extras which it seems should be in the default install.

Installing getResources

> System
> Package Management
> Search "getResources"
> Download

Here I got confronted with a nasty html overlay problem. The readme/license page was too long for my screen resolution. As a modal overlay it would not scroll, yet I was supposed to click on "next" to move forward. Lucky enough, hiding the dock on my MacBook Pro gave just enough space for the button to display.

Back to the tutorial on modx dynamic content, I created an articleTpl chunck (Elements > New Chuck), then added the following into the template associated with the "Home" resource.

[[!getResources?
            &showHidden=`1`
            &tpl=`articleTpl`
            &limit=`10`
            &includeContent=`1`
            &includeTVs=`1`
            &processTVs=`1`]]

It barely shows dynamicly generated content on the homepage. There is a lot more tweaking to get the site functional.

by Sebastien Mirolo on Sun, 16 Oct 2011


Receive news about DjaoDjin in your inbox.

Bring fully-featured SaaS products to production faster.

Follow us on