How to make Apache, PHP, vhosts, Laravel, mcrypt and JSON work in Ubuntu 13.10 after upgrade

I just upgraded my Ubuntu from 13.04 to 13.10 an suddenly my PHP dev environment does not work anymore.

Investigating changes I found that apache2.2 was replaced with apache2.4 and php 5.4 was replaced with php5.5.

Firstly vhosts did not work and all local sites showed only “It Works” default page.

There was new 000-default vhost created but removing it and restarting apache2 did not have any effect. Turns out that you need to add .conf extension for all of the vhosts definitions in sites-available and sites-enabled.

Next issue was that my Laravel sites did not have mcrypt extension anymore. This is bug and workaround is

sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available
sudo php5enmod mcrypt
sudo service apache2 restart

Now having php5-mcrypt working came another issue

Call to undefined function Illuminate\Foundation\json_decode()

First I suspected Laravel defect but soon it turned out that composer dump-autoload had same issue and everything else that used json_decode as well. Reason behind it is php builtin json module license agreement which stated

“The Software shall be used for Good, not Evil.”

This does not agree with the Free Software Foundation’s (FSF) freedom 0:

“The freedom to run the program for any purpose.”

As a result Debian Ubuntu and other free and open-source distros removed the Crockford JSON implementation from PHP. Some sites suggested using pecl-json-c and some other workarounds but actually fix is pretty easy. Just install it via ubuntu apt-get feature

apt-get install php5-json

Final “issue” is more strict server security. Comment in /etc/apaches/apache2.conf says

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.

My vhost DocumentRoot was outside /var/www so I got either forbidden or not found when I navigated to rewrite-d url-s. Solution was adding following directory to /etc/apache2/apache2.conf

Error could be “AH01630: client denied by server configuration:”

<Directory /home/username/devprojects/>
        AllowOverride ALL
        Require all granted
</Directory>

I hope your adventure in making PHP development environments work again will be faster than mine 🙂


1 thought on “How to make Apache, PHP, vhosts, Laravel, mcrypt and JSON work in Ubuntu 13.10 after upgrade

Leave a Reply

Your email address will not be published.


*