SymphonyCMS - hpaluch/hpaluch.github.io GitHub Wiki

Symphony CMS

Symphony CMS is venerable PHP based CMS using XML and XSLT transformations. I played briefly with it around 2012 and find it interesting.

[!IMPORTANT] Please be aware that XSLT is functional programming language. It means that practically every problem is solved using recursion(!). I fought XSLT many years before I found ways how to solve tasks in XSLT way.

Homepage: https://www.getsymphony.com

Default example (project "workspace") includes blog with RSS and other nice features.

Symphony also offers Admin Web interface for Content. Below is shown published content - Article on Home:

Symphony Home content

And here coresponding Admin UI:

Symphony Edit

Setup with PHP 7.x

[!CAUTION] As pointed on https://github.com/symphonycms/symphonycms source - Symphony requires PHP 7.x! It is incompatible with PHP 8.x (for example in Ubuntu 22.04 LTS+).

I will use AlmaLinux 8, that provides both PHP 7.x and PHP 8.x

Setup - AlmaLinux 8

AlmaLinux < 9 should be used to have PHP 7.x, tested AlmaLinux 8.10 (Cerulean Leopard).

[!WARNING] Please disable SElinux to avoid issues.

  • edit /etc/default/grub and append selinux=0 to line with GRUB_CMDLINE_LINUX variable
  • regenerate grub.cfg with sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  • also set SELINUX=disabled in /etc/sysconfig/selinux
  • reboot system sudo reboot

[!WARNING] According to: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html-single/8.3_release_notes/index#known-issue_security

Disabling SELinux using the SELINUX=disabled option in the /etc/selinux/config results in a process in which the kernel boots with SELinux enabled and switches to disabled mode later in the boot process. This might cause memory leaks.

So you should always use selinux=0 boot parameter.

Install requirements from https://www.getsymphony.com/learn/tutorials/view/install-symphony/1/

# tools, binutils contains strings, net-tools contains netstat
sudo dnf install net-tools unzip bash-completion binutils tcpdump
# php + apache
sudo dnf install httpd php php-gd php-zip php-xml php-mysqlnd php-json
sudo dnf install mysql-server

[!WARNING] Double-check that you have PHP 7.x (only supported major version):

$ rpm -q php

php-7.2.24-1.module_el8.3.0+2010+7c76a223.x86_64

Prepare database:

sudo systemctl enable --now mysqld
sudo mysql -e 'CREATE DATABASE symphony CHARACTER SET utf8 COLLATE utf8_unicode_ci;'
# This syntax is required for MySQL 8+:
# NOTE: replace "password" with your password...
sudo mysql -e "CREATE USER 'symphony'@'localhost' IDENTIFIED BY 'password';"
# grant below is required to avoid error:
# - Access denied; you need (at least one of) the SUPER, SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN privilege(s) for this operation
# NOTE: It is *not* possible to use: ON symphony.* for this privilege:
sudo mysql -e "GRANT SESSION_VARIABLES_ADMIN ON *.* TO 'symphony'@'localhost'"
sudo mysql -e "grant all privileges on symphony.* to 'symphony'@'localhost';"
sudo mysql -e 'flush privileges;'

Verify that you can locally login to mysql as user symphony:

mysql -u symphony -p symphony
# will be prompted for password
mysql> quit

To setup Symphony we have to follow: https://www.getsymphony.com/learn/tutorials/view/install-symphony/3/

  • but please note that https://www.getsymphony.com/download/releases/current/ is walled by CloudFlare and not accessible without JavaScript (curl or wget will fail with 403 Forbidden error, while JS enabled browsers will pass)
  • fortunately we can download directly from GitHub.com

So we will install from Git:

[!WARNING]

  • Avoid temptation to download release directly from https://github.com/symphonycms/symphonycms/tags
  • It is "broken" because it does not contain required extensions (these are defined as submodules of this project)
  • I burned myself badly - it caused late crash under http://IP_OF_YOUR_WEBSERVER/symphony/publish/articles/
# change owner to this unprivileged user that will manage git
sudo chown `id -un`:`id -gn` /var/www/html
git clone -b lts-bundle https://github.com/symphonycms/symphonycms.git /var/www/html

# required workaround because github.com no longer supports obsolete Git protocol
git config --global url.https://github.com/.insteadOf git://github.com/
cd /var/www/html
git submodule update --init --recursive
git clone git://github.com/symphonycms/workspace.git
# temporary relaxed permissions for installation stage
chmod 777 symphony .
chmod -R 777 workspace

Now relax Override permissions for Apache (Symphony will create /var/www/html/.htaccess with advanced configuration that requires oerrides:

Now enable and start Apache web server using:

sudo systemctl enable --now httpd
# enable access in Firewalld:
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --set-log-denied=unicast

We can continue installation following https://www.getsymphony.com/learn/tutorials/view/install-symphony/5/#pagehead

  • point your browser to: http://IP_OF_YOUR_WEBSERVER/install/

  • Ooops, encountered issue while connecting to mysql:

    Symphony was unable to connect to the specified database.
    
  • first ensure that you use 127.0.0.1 as database Hostname. Default is localhost which is problem, because AlmaLinux aliases localhost for both IPv4 and IPv6 address.

  • next reload page - there will appear same error but for different reason:

  • tcpdump revealed this strange error:

    SELECT SQL_CACHE VERSION() AS `version`;
    #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server
          version for the right syntax to use near '() AS `version`' at line 1
    
  • already reported here: https://github.com/symphonycms/symphonycms/issues/2909

  • comment out both lines:

    //                $query = preg_replace('/^SELECT\s+/i', 'SELECT SQL_CACHE ', $query);
              } else {
    //                $query = preg_replace('/^SELECT\s+/i', 'SELECT SQL_NO_CACHE ', $query);
    

    in file /var/www/html/symphony/lib/toolkit/class.mysql.php

  • and reload page

  • this finish installation without other issues

[!WARNING] Error handling page may be broken and it may throw this on error:

Use of undefined constant SYMPHONY_URL - assumed 'SYMPHONY_URL' (this will throw an Error in a future version of PHP) on 338 of file /var/www/html/symphony/lib/core/class.errorhandler.php

  • if you encounter this issue try to apply following patch (not replacing URL on error page is less evil than crash:
diff -ur home/ansible/symphonycms-2.7.10/symphony/lib/core/class.errorhandler.php var/www/html/symphony/lib/core/class.errorhandler.php
--- home/ansible/symphonycms-2.7.10/symphony/lib/core/class.errorhandler.php	2019-04-08 21:40:50.000000000 +0200
+++ var/www/html/symphony/lib/core/class.errorhandler.php	2024-12-14 17:59:36.242000000 +0100
@@ -335,7 +335,9 @@
         );
 
         $html = str_replace('{ASSETS_URL}', ASSETS_URL, $html);
-        $html = str_replace('{SYMPHONY_URL}', SYMPHONY_URL, $html);
+	if (defined('SYMPHONY_URL')){
+           $html = str_replace('{SYMPHONY_URL}', SYMPHONY_URL, $html);
+	}
         $html = str_replace('{URL}', URL, $html);
 
         return $html;
diff -ur home/ansible/symphonycms-2.7.10/symphony/lib/core/class.symphony.php var/www/html/symphony/lib/core/class.symphony.php
--- home/ansible/symphonycms-2.7.10/symphony/lib/core/class.symphony.php	2019-04-08 21:40:50.000000000 +0200
+++ var/www/html/symphony/lib/core/class.symphony.php	2024-12-14 18:02:20.251000000 +0100
@@ -987,7 +987,9 @@
         );
 
         $html = str_replace('{ASSETS_URL}', ASSETS_URL, $html);
-        $html = str_replace('{SYMPHONY_URL}', SYMPHONY_URL, $html);
+	if (defined('SYMPHONY_URL')){
+            $html = str_replace('{SYMPHONY_URL}', SYMPHONY_URL, $html);
+	}
         $html = str_replace('{URL}', URL, $html);
 
         return $html;
  • now it should be possible to finish install, but ...

There is another problem - URL: http://IP_OF_YOUR_WEBSERVER/symphony/ will show just contents of directory. We have to enable mod_rewrite in .htaccess by changing this file:

diff -u etc/httpd/conf/httpd.conf{.orig,}
--- etc/httpd/conf/httpd.conf.orig	2024-12-14 18:18:53.142000000 +0100
+++ etc/httpd/conf/httpd.conf	2024-12-14 18:46:55.472000000 +0100
@@ -151,7 +151,7 @@
     # It can be "All", "None", or any combination of the keywords:
     #   Options FileInfo AuthConfig Limit
     #
-    AllowOverride None
+    AllowOverride All
 
     #
     # Controls who can get stuff from this server.
  • note: Options are required for mod_rewrite instructions in /var/www/html/.htaccess and basically all other options are needed to avoid 500 Internal Error
  • and restarting Apache with systemctl restart httpd

We should do cleanup following: https://www.getsymphony.com/learn/tutorials/view/install-symphony/end/

sudo rm -rf /var/www/html/install/
cd /var/www/html
sudo chmod 755 symphony .
sudo chmod -R 775 manifest
sudo chmod -R 775 workspace

Now it should appear to work on http://IP_OF_YOUR_WEBSERVER/symphony/,

  • Please try also article list on http://IP_OF_YOUR_WEBSERVER/symphony/publish/articles/ to ensure that CMS really works correctly (no error)

Congratulations! Now you should be able to use Symphony CMS

  • tip: to see pages as end user try: http://IP_OF_YOUR_WEBSERVER/home/
  • you can find list of defined pages on admin interface under http://IP_OF_YOUR_WEBSERVER/symphony/blueprints/pages/
  • note: in the past it was possible to directly edit XSLT templates in web UI (see https://www.getsymphony.com/learn/concepts/view/page-templates/) however in my installation there is longer clickable link. One can still edit these templates on disk under /var/www/thml/workspace/pages/.

Setup - Ubuntu 24.04 LTS

[!WARNING] Abandoned variant - because Symphony is known to be incompatible with PHP 8.x - maybe I will resume work on this topic later...

Please see old revision: https://github.com/hpaluch/hpaluch.github.io/wiki/SymphonyCMS/c4ae17690dfcc5e2476426e79ac824df329a99a1 for original content.