Friday, June 08, 2007

Installing PHP on RedHat ES4 with Apache 2

Apache 2 was installed during the system build of this RHEL ES4 system. Now, the task, to get MySQL 5.0 and PHP 5.2.3 installed. Here are some things I learned along the way.

First things first,
Remove any old MySQL versions with rpm -ev.
Also check for and remove any old php versions (rpm -qa | grep php)

Download the tar/gz bundle from php.net.

Download and install these packages from MySQL - I used community server:
MySQL-client-community-5.0.41-0.rhel4 (Client)
MySQL-shared-community-5.0.41-0.rhel4 (Shared Libraries - this may not be needed)
MySQL-server-community-5.0.41-0.rhel4 (Server)
MySQL-devel-community-5.0.41-0.rhel4 (Headers and Libraries)

Note that if you don't install the devel RPM you'll get this error on ./configure of PHP:
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!

It goes away after you install the devel RPM.

Then, it's time to ./configure PHP
I'm loosely following this doc: http://us.php.net/manual/en/install.unix.php
and Example 4.1 although I have Apache 2.0 instead of 1.3.
(the Apache 2.0 example gives some useful info also, but isn't strictly accurate either)

Prerequisites, per this page:
gcc
flex
bison

I installed these with up2date which may not give the latest versions, but hopefully good enough.

up2date gcc also installed:
cpp
glibc2
glibc-devel
glibc-headers
libgcc
glibc-common

I checked if PHP was currently loaded in the /etc/httpd/conf/httpd.conf file - looking for php in the "LoadModule" section. Not there. Keep going.

Noticed that in the example on php.net the ./configure specifies "with-apxs" so I wanted to see what apxs was and if I already had it.

What it is - tip of the keyboard to http://www.onlamp.com/pub/a/php/2001/03/15/php_admin.html
it's used to build and install Apache extension modules. After a few random searches, I found it's installed in the httpd-devel RPM. Of course it's not an apache-devel RPM, because RedHat prefers to disguise Apache with the httpd name. You tell me why, I'll give you a quarter.

up2date httpd-devel
and apxs magically appeared in the /usr/sbin directory.

httpd-devel said it depended on a bunch of other things too:
apr-devel
apr-util-devel
cyrus-sasl-devel
db4-devel
expat-devel
openldap-devel
pcre-devel
compat-openldap

First time I ran ./configure in the PHP directory (ignoring the example that says to install Apache first, since it's already installed) - I got this error:

./configure --with-mysql --with-apxs=/usr/sbin/apxs
...
checking for Apache 1.x module support via DSO through APXS... configure: error: You have enabled Apache 1.3 support while your server is Apache 2. Please use the appropiate switch --with-apxs2

Maybe we should tell the php folks how to spell "appropriate" except then I'd have to admit I didn't read the instructions first....oh well.

next run:
./configure --with-mysql --with-apxs2=/usr/sbin/apxs
next error:
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.

Oh where, oh where do I find xml2-config?
It's in libxml2-devel, of course! Now why didn't I know that???

up2date libxml2-devel
also installed this dependency:
zlib-devel

now this file exists: /usr/bin/xml2-config ...yay!checking for MySQL UNIX socket location... /var/lib/mysql/mysql.sock
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!

But if you already installed the MySQL-community-devel package (see note at beginning), you didn't get this right?

next run:
./configure --with-mysql --with-apxs2=/usr/sbin/apxs

got this error:
checking for gcc... gcc
checking whether the C++ compiler (gcc ) works... no
configure: error: installation or configuration problem: C++ compiler cannot create executables.

this web page gave me the next clue - to check the config.log in the directory where I'm doing the ./configure -
in the last few lines of config.log:
gcc: installation problem, cannot exec `cc1plus': No such file or directory

So now I'm on the hunt for cc1plus.
I found it through hints on random websites...it's in the gcc-c++ package.

up2date gcc-c++
which also installed:
libstdc++
libstdc++-devel

./configure --with-mysql --with-apxs2=/usr/sbin/apxs ... again
Oh my Dog...it actually worked:
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+

Thank you for using PHP.

Now...back to the php.net install on unix page.

make
which had a friendly reminder to run "make test"

make test

{sudo} make install
gave this reminder:
libtool: install: warning: remember to run `libtool --finish /home/julie/php-5.2.3/libs'

Since libtool doesn't exist on my system, so I installed it:

up2date libtool
which also installed
autoconf
automake

and running this:
libtool --finish /home/me/php-5.2.3/libs

said this:
PATH="$PATH:/sbin" ldconfig -n /home/julie/php-5.2.3/libs
----------------------------------------------------------------------
Libraries have been installed in:
/home/julie/php-5.2.3/libs

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

But otherwise php installed fine with a new module in /etc/httpd/conf/modules:
libphp5.so

and added this to /etc/httpd/conf/httpd.conf:
LoadModule php5_module /usr/lib/httpd/modules/libphp5.so

service httpd stop
service httpd start

And I should be good to go!

Friday, June 01, 2007

FSCK and a 4TB filesystem

It's not like I had a choice, the 4TB filesystem made of 10 x 500Gb SATA disks in RAID5 lost a disk and did a funky dance, and now it won't let anyone mount it except read only.

So I had to unmount it, with umount -l because when I tried plain old umount /name it said "device is busy". I don't know how it could be busy, I was the only person connected to the machine and no other server had it mounted...so I ran "umount -l /name" and that did the trick in about 20 seconds.

Then on to the fsck of the unmounted filesystem...did I mention it's 4 terabytes? What I would love to know...LOVE to know....is how long it takes to fsck a 4TB filesystem? A couple hours, a day, a weekend, or until eternity and the disks stop spinning?

I guess too if I had another wish it would be that there was some kind of moving blinking cursor to let me know fsck was doing something. After I said "yes" to a few dozen errors about block bitmaps, inode bitmaps, and inode tables with their ominous message "warning: severe data loss possible" then it spit out:

/dev/sdb contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes

where it has sat for the last hour, completely unresponsive.

Am I missing something? Did I miss the prompt for verbose output???

Answers:
- there is a prompt for verbose output but it didn't help much
- fsck on a 4TB disk took about 6 hours with lots of errors
- there is a progress bar using -C but I couldn't get it to display, probably missed something

Finally I ran it as root in the background, sent output to a log file, and went to sleep.