Laravel 5.1? Easily upgrade to PHP 5.5 on CentOS 6!

I’ve been using Laravel a lot lately. Like seriously, a lot. I’m using it for Pdcast as well as a project in my day job.

Part of the draw to using Laravel was that there’s a LTS (Long Term Support) release available now, version 5.1! This version requires PHP 5.5.9+, however that’s not included in your bog standard CentOS or EPEL repositories.

Nice and quickly then, lets get the latest PHP installed so we can use the new Laravel. We’re assuming you’ve already got PHP installed, if not then replace the following “update” command with a yum install php command, keeping the enablerepos intact.

yum install
yum update --enablerepo remi --enablerepo remi-php55

You should now be at (at the time of writing) PHP version 5.5.26. Get your Laravel 5.1 on!

Webserver down: "Invalid command ‘php_value’"

Well this one took me by surprise I’ll say. It’s never fun when Zabbix lights up saying half of your websites have dropped out!

Starting httpd: Syntax error on line 31 of /etc/httpd/conf.d/php.conf:
Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration [FAILED]

Firstly DO NOT comment out the bottom two lines as some sites have recommended. The reason being this will allow your webserver to start up however PHP will not be processed, dumping all of your site’s code into the browser as plain text for anyone to see!

To summarise what happened I had done a yum update which bumped up php – apparently the Atomicorp (Atomic Rocket Turtle RPM Repository) repo I use had a bit of trouble with their packages, meaning the php.conf that ends up in /etc/httpd/conf.d/php.conf was a tad broken.

If you’re just in a bit of a panic rush like I was and would just like the quick fix, I had to add the following back to the very top of the file above everything else and then restarted httpd ( service httpd restart )

# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
<IfModule prefork.c>
LoadModule php5_module modules/
<IfModule worker.c>
LoadModule php5_module modules/

Hoping this helps you quicker than it took me to find the fix! I’m not sure if the issue has been fixed at atomic, only a couple of my web servers were affected by this while they’re all at the same version of php. Luckily it was just dev server for ICNerd that was affected by this issue.

A couple of other sites did flail off the internet into a broken php abyss though 🙁

Update: All of the sites using this repo were affected, they just hadn’t tried restarting or reloading httpd configs yet… that was fun


Side note. The featured image in this post is from openclipart: nuclear explosion by tzunghaor