Nate C-K asked:
Ultimately, this question is about Yum and the Amazon Linux AMI (see the end for that part), but first I’ll give some background to how I got into my situation.
I installed PHP from source
I am working on setting up a new PHP application on a web server that’s hosted with Amazon Web Services. The EC2 instance is running “Amazon Linux AMI release 2012.09” (according to /etc/issue). I am not the primary admin for this server, so I’d like to limit the impact of the changes I make.
There are already some PHP applications running on this server. I need a newer version of PHP than they are using. They’re using the version from the distro package which is 5.3, too old for my purposes.
I figured I’d download the PHP source, build it myself and run it alongside the other version. (How I’m going to set this up is a different matter that I won’t get into here.)
I configured my PHP build with these options:
--prefix=/opt/php-5.5.9 --with-openssl --with-mcrypt --with-mysql --with-pdo-mysql --enable-fpm --with-apxs2=/usr/sbin/apxs
Then, I switched to root and ran
make install. (In retrospect, doing this as root was a mistake, I should have set user write permissions on the install directory and installed as my user so I could be sure none of the files were getting put outside the install directory. Too late for that now.)
I then noticed that the web server wasn’t responding. After restarting it, it worked fine. I poked around a bit and noticed that for
phpversion, the server now reports the new version that I just installed under
/opt, not the distro version that I had intended to leave in place. It turns out that
make install went ahead and replaced the existing
libphp5.so. RPM reports:
[root@xxxx etc]# rpm -V php S.5....T. /usr/lib64/httpd/modules/libphp5.so
Everything still works just fine on the new version as far as I know, so most likely no harm was done. However, I’d rather leave the old version of PHP in place so the packages can still be managed by the package manager. This was my intent in putting the new version in
Trying to put the old version back, Yum failed
I attempted to restore the old version of
yum reinstall. Here’s the output:
[root@xxxx etc]# yum reinstall php Loaded plugins: fastestmirror, local, priorities, security, update-motd, upgrade-helper Setting up Reinstall Process Loading mirror speeds from cached hostfile * amzn-main: packages.us-east-1.amazonaws.com * amzn-updates: packages.us-east-1.amazonaws.com amzn-main | 2.1 kB 00:00 amzn-updates | 2.3 kB 00:00 265 packages excluded due to repository priority protections Installed package php-5.3.20-1.29.amzn1.x86_64 (from amzn-updates) not available. Nothing to do
From this message, I’m not clear what the problem is. Is it failing to find the package on the update server? Is the server itself not available (hopefully temporarily)? Or is it excluding the package due to priority protections and thus refusing to reinstall it?
What is the best resolution for this problem that lets me restore the old version of PHP and put it back under the package manager’s control?
Amazon replaced the PHP 5.3.20 package with a newer point release (for security fixes, etc.). Just update to it instead:
yum update php
And for Pete’s sake, don’t do this stuff in production! Start a new instance and do your experimentation there.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.