Warning! Techy post – if your not into Web development you’ll want to skip this one…
I’ve been wanting to try out Zend Core (Zend’s standard PHP stack / extension or “Reliable PHP made easy”) for a while but as Ubuntu isn’t officially supported I’ve held off. A problem with some code running on the Ubuntu version of PHP 5 forced my hand – I discovered that its actually not that hard to get ZC up and running on Ubuntu. Thought I’d share in case this is helpful to anyone…
- Download, unpack and run the ./install command as per usual
- I opted to stick with the version of Apache already installed (as its slightly newer than the Zend bundled one)
- My experience of Zend attempting to configure Apache varied – one some boxes it almost worked, others it didn’t. If you find the installer crashing out just untick the configure Apache option and try again.
- Once Zend Core has completed you’ll need to tweak things abit…
PHP5 Module
The ZC installer will have probably left your Apache configured with 2 LoadModule php5_module entries (one in /etc/apache2/apache2.conf – thanks to ZC and the other Ubuntu one in /etc/apache2/mods-enabled/php5.load). So you can either do a sudo a2dismod php5 to remove the Ubuntu one or modify the Ubuntu one to the following:
LoadModule php5_module /usr/local/Zend/Core/modules/apache22/libphp5.so
In fact you can be cunning here by commenting out the Ubuntu PHP5 extension and adding the ZC one in this file – allowing you to effectively switch between the 2 different extensions should you need to.
MySQL extension – if you’re using MySQL then you’ll need to watch out for the fact that the bundled MySQL extensions look for the MySQL socket file in /tmp/mysql.sock rather than the Debian / Ubuntu location which is /var/run/mysqld/mysqld.sock
In most cases changing in php.ini:
mysql.default_socket =
to
mysql.default_socket = /var/run/mysqld/mysqld.sock
Does the trick; but alas not in all cases it seems (eg MySQL PDO). Really hacky fix to this (please do let me know if you have something better – other than editing the socket in the /etc/my.cnf file) is to run a scheduled (using crontab) symlink of /var/run/mysqld/mysql.sock to /tmp/mysql.sock
To do this run: sudo crontab -e
and add the following line:
5 * * * * ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
And for now that works for me. If you want a copy of some of the relevant config files / snippets (including the extra bit that ZC adds to the apache2.conf) then I have zipped them up for ease.
Zend Core itself looks like a good product – being able to access to php.ini options via web based tool is pretty useful, as is knowing you are working on a consistent & tested version of PHP. Its a shame MySQL doesn’t offer a similar free / unsupported version of their MySQL Enterprise in a similar way really…