Tentang IT dan Komputer

Teknologi Informasi

Install Fedora dan Web Server [download]

Posted by intrik on April 26, 2007

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.

  1. Download Fedora Core 4 ISO files and burn them to CDs
  2. 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

  3. Boot to Disc 1 and install using the graphical interface (skip the Media check unless you want to waste an hour or so)
  4. Select the Server installation
  5. 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.
  6. In the Packages, add Gnome, Graphical Internet, Graphics, FTP, MySQL and Development Tools
  7. Also, in the Web Server details, add mod_auth_mysql, mod_auth_ldap and php-mysql
  8. Click through to let the install do its thing

When it is finished installing, you’ll need to create your default user. Then you’ll be presented with a logon screen.

  1. Login to the box with the user you created
  2. Access a terminal window: Applications/System Tools/Terminal
  3. Go root: type su and hit Enter
  4. Update your software: yum update apache mysql php
  5. 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
  6. Create a root password for MySQL:
    mysqladmin -u root password ‘password’
  7. Browse to http://localhost and see that Apache installed
  8. 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)
  9. 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.

  1. 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
  2. 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.
  3. 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!
  4. Now for the lovely configuration and compile runs. First, change to the php source directory:
    cd php-5.1.2
  5. 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’
  6. Pray and then press Enter
    If all goes well, you’ll get a License message and “Thank you for using PHP.”. You’re welcome.
  7. 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.
  8. Now install it – first, stop Apache:
    /sbin/service httpd stop
  9. Now run the install: make install
  10. 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)
  11. 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…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: