in Technology

Installing PHP on RHEL 4

Had to install PHP5 with SOAP support on a server. The server was a fresh RHEL4 edition. It’s been a while I setup PHP on a server and our sys admin was on leave, so I decided to do it.

My experience in installing PHP on a server has been this: no matter how many times I have done it, I will face a new problem every time!

So in tune with that, I faced numerous issues this time as well! The first problem with the situation is that you have to recompile PHP. If you want to add SOAP support (or something similar) to PHP, you will have to recompile PHP (or load a dynamic module). So I downloaded the PHP source code. But I wanted to be sure I have other things set on the machine before I begin.

Problem 2: apxs is not available on the server. This is actually a known trouble starter. Most people don’t have apxs on their installation. And it’s needed for PHP to compile. So this means, I need to get httpd-devel on the server. So I download the latest httpd and httpd-devel RPMs from rpmfind.net. But I forgot there is something called as dependenies too! The newer versions of Apache required newer libraries of a lot of things.

So I did all that – going through dependencies one by one and upgrading / installing / forcing / avoiding dependencies. Yum was not available on the system, and when I tried to RPM Yum, it gave me further dependency problems.

Solution 1: After much frustration, I decided to try some automated method. This point generally comes when you are on the 4th or 5th level of dependency resolution. I tried “up2date“, and well, it worked! I removed all the latest version RPMs I had installed, and got the versions that came with the original setup via up2date. Also added httpd-devel.

Problem 2: Then I wanted to install MySQL. The server had MySQL client libraries, but not the server. This was strange, so I installed the MySQL server via RPM. But the server did not start. Checking the /var/log/messages, I found this:
Apr 21 23:30:07 bigserver kernel: audit(1145680207.552:0): avc: denied { write } for pid=13965 exe=/usr/sbin/mysqld name=mysql dev=dm-4 ino=114815 scontext=root:system_r:mysqld_t tcontext=root:object_r:var_lib_t tclass=dir

Solution: I had never seen a problem like this! So I Googled, and found out that this is something that happens because of the SELinux configuration in RHEL. It’s actually a reported bug on MySQL. I invoked the “system-config-securitylevel” application from the server, and disabled SELinux policy for mysql daemon. That got rid of the error. But the server still wouldn’t start.

Searching more, I found that unless I manually deleted my.cnf and other MySQL files, it would not work. So I deleted the /var/lib/mysql and my.cnf and installed MySQL server again. That made it work!

Problem 3: I knew that if I just took the PHP configure string from phpinfo output, it’s not going to compile. Most of the libraries will not be available and configure will complain about them. So I cleaned the ./configure command and executed it. But oops, it said libmysqlclient was either not present or the version was wrong. Now just a while ago I had installed the latest MySQL server, I checked the lib folder and the library was right there. What could be the problem then? After a bit of hitting around, it struck me that may be the file was indeed wrong version. The file was never replaced in the RPM installation because of the same problem that I faced earlier. So unless I manually remove those files and install MySQL devel again, it would not work. So I did that, and configure worked like an obedient servant after that.

Note: The easiest part in this whole process was the actual PHP compilation. It completed before I could check my emails! The server was pretty fast and the compilation was completed quickly and without a hassle. I did a make install and that set things right.

I am now ready to setup the application on the server and let it roll!

And I am wearing my PHP t-shirt today! 🙂

Write a Comment

Comment

  • Related Content by Tag