Alas this meant reinstalling certain things, like ImageMagick and APC.
This also brought up the question of pagespeed, which I keep toying with. I use it at work, but since this server’s on CentOS with EasyApache, there’s no ‘easy’ way to install PageSpeed yet (not even a yum install will work), so it’s all manual work plus fiddling. I don’t mind installing ImageMagick and APC, but Google’s own ‘install from source’ aren’t really optimized for CentOS, even though they say they are, and I’m nervous about the matter. Well… I did it anyway. It’s at the bottom.
The only reason I had to do this all over is that I moved to a new major version of PHP. If I’d stayed on 5.3 and up’d to 5.3.21, that wouldn’t have mattered. But this changed a lot of things, and thus, a reinstall.
I started using ImageMagick shortly after starting with DreamHost, since my co-worker Shredder was working on the ‘Have WP support ImageMagick’ project. It was weird, since I remembered using it before, and then everyone moved to GD. I used to run a photo gallery with Gallery2, and it had a way to point your install to ImageMagick. Naturally I assumed I still had it on my server, since I used to (in 2008). Well since 2008, I’ve moved servers. Twice. And now it’s no longer default.
Well. Let’s do one of the weirder installs.
First you install these to get your dependancies:
yum install ImageMagick yum install ImageMagick-devel
Then you remove them, because nine times out of ten, the yum packages are old:
yum remove ImageMagick yum remove ImageMagick-devel
This also cleans out any old copies you may have, so it’s okay.
Now we install ImageMagick latest and greatest from ImageMagick:
cd ~/tmp/ wget http://imagemagick.mirrorcatalogs.com/ImageMagick-6.8.1-10.tar.gz tar zxf ImageMagick-6.8.1-10.tar.gz cd ImageMagick-6.8.1-10 ./configure --with-perl=/usr/bin/perl make make install
Next we install the -devel again, but this time we tell it where from:
rpm -i --nodeps http://www.imagemagick.org/download/linux/CentOS/x86_64/ImageMagick-devel-6.8.1-10.x86_64.rpm
Finally we can install the PHP stuff. Since I’m on PHP 5.4, I have to use imagick-3.1.0RC2 – Normally I’m not up for RCs on my live server, but this is a case where if I want PHP 5.4, I have to. By the way, next time you complain that your webhost is behind on PHP, this is probably why. If they told you ‘To get PHP 5.4, I have to install Release Candidate products, so your website will run on stuff that’s still being tested,’ a lot of you would rethink the prospect.
cd ~/tmp/ wget http://pecl.php.net/get/imagick-3.1.0RC2.tgz tar zxf imagick-3.1.0RC2.tgz cd imagick-3.1.0RC2 phpize ./configure make make install
Next, edit your php.ini to add this:
Restart httpd (
service httpd restart) and make sure PHP is okay (
php -v), and you should be done! I had to totally uninstall and start over to make it work, since I wasn’t starting from clean.
Speaking of clean, cleanup is:
yum remove ImageMagick-devel rm -rf ~/tmp/ImageMagick-6.8.1-10* rm -rf ~/tmp/imagick-3.1.0RC2*
I love APC. I can use it for so many things, and I’m just more comfortable with it than xcache. Part of it stems from a feeling that if PHP built it, it’s more likely to work. Also it’s friendly with my brand of PHP, and after 15 years, I’m uninclined to change. I like DSO, even if it makes WP a bit odd.
Get the latest version and install:
cd ~/tmp/ wget http://pecl.php.net/get/APC-3.1.14.tgz tar -xzf APC-3.1.14.tgz cd APC-3.1.14 phpize ./configure make make install
Add this to your php.ini:
extension = "apc.so"
Restart httpd again, clean up that folder, and then one more…
I hate Google. Well, no I don’t, but I don’t trust them any more than I do Microsoft, and it’s really nothing personal, but I have issues with them. Now, I use PageSpeed at work, so I’m more comfortable than I was, and first I tried Google’s installer. The RPM won’t work, so I tried to install from source, but it got shirty with me, fast, and I thought “Why isn’t this as easy as the other two were!?” I mean, APC was stupid easy, and even easier than that would be
yum install pagespeed right?
Thankfully for my sanity, someone else did already figure this out for me, Jordan Cooks, and I’m reproducing his Installing mod_pagespeed on a cPanel/WHM server notes for myself. 1 Prerequisite was to have mod_deflate, which I do.
The commands are crazy simple:
cd /usr/local/src mkdir mod_pagespeed cd mod_pagespeed wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm rpm2cpio mod-pagespeed-beta_current_x86_64.rpm | cpio -idmv cp usr/lib64/httpd/modules/mod_pagespeed.so /usr/local/apache/modules/ chmod 755 /usr/local/apache/modules/mod_pagespeed.so mkdir -p /var/mod_pagespeed/cache chown nobody:nobody /var/mod_pagespeed/*
Once you do this, you have to edit the file, and this is where I differ from Jordan’s direction. He just copied this over
/usr/local/apache/conf/pagespeed.conf but I had an older version from a ‘Let’s try Google’s way….’ attempt and someone else’s directions, so I made a backup and then took out the
ModPagespeedGeneratedFilePrefix line since I know that’s deprecated. I also added in a line to tell it to ignore
Here’s my pagespeed.conf (edited):
To tell Apache to run this, edit
/usr/local/apache/conf/includes/pre_main_global.conf and add:
Note: We put this code here because EasyApache and httpd.conf will eat your changes.
Finally you rebuild Apache config and restart apache and test your headers to see goodness! My test was a success.
HTTP/1.1 200 OK Date: Mon, 21 Jan 2013 03:12:13 GMT Server: Apache X-Powered-By: PHP/5.4.10 Set-Cookie: PHPSESSID=f4bcdae48a1e5d5c5e8868cfef35593a; path=/ Cache-Control: max-age=0, no-cache Pragma: no-cache X-Pingback: http://ipstenu.org/xmlrpc.php X-Mod-Pagespeed: Powered By mod_pagespeed Vary: Accept-Encoding Content-Length: 30864 Content-Type: text/html; charset=UTF-8
For those wondering why I’m ignoring wp-admin, well … sometimes, on some servers, in some setups, if you don’t do this, you can’t use the new media uploader. It appears that PageSpeed is compressing the already compressed JS files, and changing their names, which makes things go stupid. By adding in the following, I can avoid that:
Besides, why do I need to cache admin things anyway, I ask you?
So there you are! Welcome to PHP 5.4!
- By the way, I keep a copy of this article saved to DropBox since invariably I will half-ass this and break my site. ↩