I’ve been supporting over 80 MediaWiki wikis and half a dozen or so WordPress blogs at Intuit, Inc.
I started out on a couple of old Dell PCs with Mandrake. When they were overloaded, and that didn’t take too long, I moved to an HP DL360 XEON Dual Processor server with 4 gig of RAM, redundant BIOS, 37 gig RAID 1, etc… A nice box.
At first I tried using a RedHat Enterprise image, but I quickly found that too limited. I downloaded Fedora Core 4 ISOs and installed that instead.
I’d just started using Linux a few months ago with Mandriva, and Fedora was just as easy to install. But then I hit a big roadblock: PHP 5 and it’s crazy –without-mysql default configuration. About the lack of MySQL support… The PHP FAQ says:
- This won’t actually affect that many people.
Yeah, right. That’s why Google returns hundreds of results where people have this problem. What a pain and a state of denial by the PHP folks.
I ended up forcing a PHP4 install on the box and I’ve hated it ever since. XSLT never has worked properly – I ended up creating my own PHP function that shells to the command line XSL transform app.
So when the need arose to setup a server for another group, I dusted off one of those old Dells and decided to figure out how to do it right – with all the latest versions of Apache, MySQL and PHP, and all working together nicely. It took me a few days to figure out, but I finally have a clean, working system.
I actually have every single click and step mapped out on the Intuit Innovation Lab’s internal wiki, and I won’t list every one of them here – only where there’s a change from the default.
- Download Fedora Core 4 ISO files and burn them to CDs
- Boot to Disc 1 and install using the graphical interface (skip the Media check unless you want to waste an hour or so)
- Select the Server installation
- In the Firewall section, you can install it if you really want… but a hardware firewall works much better. The IPTables and SELinux really slow down the box, so I disable both of those.
- In the Packages, add Gnome, Graphical Internet, Graphics, FTP, MySQL and Development Tools
- Also, in the Web Server details, add mod_auth_mysql, mod_auth_ldap and php-mysql
- Click through to let the install do its thing
http://download.fedora.redhat.com/pub/fedora/linux/core/4/i386/iso/FC4-i386-disc1.iso
http://download.fedora.redhat.com/pub/fedora/linux/core/4/i386/iso/FC4-i386-disc2.iso
http://download.fedora.redhat.com/pub/fedora/linux/core/4/i386/iso/FC4-i386-disc3.iso
http://download.fedora.redhat.com/pub/fedora/linux/core/4/i386/iso/FC4-i386-disc4.iso
When it is finished installing, you’ll need to create your default user. Then you’ll be presented with a logon screen.
- Login to the box with the user you created
- Access a terminal window: Applications/System Tools/Terminal
- Go root: type su and hit Enter
- Update your software: yum update apache mysql php
- Check that everything is running, plus configure stuff to run on boot:
/sbin/chkconfig httpd on
/sbin/service httpd start
/sbin/chkconfig mysqld on
/sbin/service mysqld start - Create a root password for MySQL:
mysqladmin -u root password ‘password’ - Browse to http://localhost and see that Apache installed
- Create a test page for PHP:
vi /var/www/html/phpinfo.php
i (insert mode in the VI editor)
<?php echo phpinfo(); ?>
Press Escape (exit insert mode in VI) then :wq and press Enter (colon write quit) - Browse to the PHP test page at http://localhost/phpinfo.php
As you can see from the PHP test page, the configuration is –without-mysql by default. Argh. So now for the hard part – configuring PHP with MySQL support.
- Get the PHP source files – you gotta compile ’em
wget http://us2.php.net/get/php-5.1.2.tar.gz/from/www.php.net/mirror - Extract them:
tar -zxvf php-5.1.2.tar.gz
This will create a folder called php-5.1.2 – in your user’s home folder assuming you haven’t gone CD’ing around since you started following these instructions. - Install the Apache developer files – Fedora Core 4 is missing a file that will cause PHP’s configure command to fail, but the developer files have what you need.
yum install httpd-devel-2.0.54
Note that the reason I’m installing 2.0.54 is because that’s the version of Apache that’s running. It shows up on that phpinfo.php page that you browse to. You should make sure that you install the same version that you are running if it’s changed since I posted this.
This will ask you about installing 4 packages and updating 11 more – don’t worry, just let ‘er rip! - Now for the lovely configuration and compile runs. First, change to the php source directory:
cd php-5.1.2 - Now run the configuration. Okay, this is a pretty big and hairy command, but basically it is the exact same configuration that shows in that phpinfo.php browse that you did earlier, with a few minor changes:
‘–with-mysql’ rather than ‘–without-mysql’ – the reason we’re all here
‘–without-unixODBC’ rather than ‘–with-unixODBC=shared,/usr’ – otherwise you get a lovely config error ’cause it isn’t installed by default on Core 4
‘–without-pspell’ rather than ‘–with-pspell’ – yet another thing that Core 4 is missing
And here’s the line to execute – just copy and paste it
./configure ‘–build=i386-redhat-linux’ ‘–host=i386-redhat-linux’ ‘–target=i386-redhat-linux-gnu’ ‘–program-prefix=’ ‘–prefix=/usr’ ‘–exec-prefix=/usr’ ‘–bindir=/usr/bin’ ‘–sbindir=/usr/sbin’ ‘–sysconfdir=/etc’ ‘–datadir=/usr/share’ ‘–includedir=/usr/include’ ‘–libdir=/usr/lib’ ‘–libexecdir=/usr/libexec’ ‘–localstatedir=/var’ ‘–sharedstatedir=/usr/com’ ‘–mandir=/usr/share/man’ ‘–infodir=/usr/share/info’ ‘–cache-file=../config.cache’ ‘–with-libdir=lib’ ‘–with-config-file-path=/etc’ ‘–with-config-file-scan-dir=/etc/php.d’ ‘–disable-debug’ ‘–with-pic’ ‘–disable-rpath’ ‘–with-bz2’ ‘–with-curl’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–enable-gd-native-ttf’ ‘–without-gdbm’ ‘–with-gettext’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg-dir=/usr’ ‘–with-openssl’ ‘–with-png’ ‘–without-pspell’ ‘–with-expat-dir=/usr’ ‘–with-pcre-regex=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-magic-quotes’ ‘–enable-sockets’ ‘–enable-sysvsem’ ‘–enable-sysvshm’ ‘–enable-sysvmsg’ ‘–enable-track-vars’ ‘–enable-trans-sid’ ‘–enable-yp’ ‘–enable-wddx’ ‘–with-pear=/usr/share/pear’ ‘–with-kerberos’ ‘–enable-ucd-snmp-hack’ ‘–without-unixODBC’ ‘–enable-memory-limit’ ‘–enable-shmop’ ‘–enable-calendar’ ‘–enable-dbx’ ‘–enable-dio’ ‘–with-mime-magic=/etc/httpd/conf/magic’ ‘–without-sqlite’ ‘–with-libxml-dir=/usr’ ‘–with-xml’ ‘–with-apxs2=/usr/sbin/apxs’ ‘–with-mysql’ ‘–without-gd’ ‘–without-odbc’ ‘–disable-dom’ ‘–disable-dba’ - Pray and then press Enter
If all goes well, you’ll get a License message and “Thank you for using PHP.”. You’re welcome. - Now you have to compile the configuration you just built. That’s easy:
make
Note that there are quite a few parameters differ in signedness warnings – don’t worry, the signedness-challenged nature of the php source doesn’t seem to hurt anything. - Now install it – first, stop Apache:
/sbin/service httpd stop - Now run the install: make install
- Before restarting and testing everything, you need to avoid a Warning that Apache shows due to the install causing a duplicate line in the Apache configuration. So edit the Apache config file:
vi /etc/httpd/conf/httpd.conf
and locate LoadModule php5_module /usr/lib/httpd/modules/libphp5.so and add a # before it:
# LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
(remember press i to insert, then Escape and :wq to write it and quit) - Now for the big moment, restart Apache!
/sbin/service httpd restart
Check the installation by browsing once again to http://localhost/phpinfo.php and see if you were successful! You should see –with-mysql now, and all your troubles are over… Until the next time…