Heya, Eric.
Configuring Apache, PHP and MySQL from source is not too difficult, and after awhile, it can be fun!
Really.
Maybe just for me.
Anyway, here we go.
The first thing you'll want to do is download the most recent versions of the source for Apache, MySQL and PHP.
Apache MySQL PHP
Note that MySQL has two downloadable versions: there's a fully-compiled version for Mac OS X, or you can download the source code. I prefer the source because then I can configure it to only support Unicode, but it's up to you.
Setting Up
Unzip / untar each archive (Mac OS X's BOMArchiveHelpe r will do this for you when you double-click on the downloaded file).
In the Finder select Go->Go to Folder... and type /usr/local. Click Go.
Create a new folder and name it 'src'. We're going to store all our source files in this directory.
Copy each source folder into /usr/local/src.
Launch Terminal.app and cd /usr/local/src.
Compiling Apache
In the Terminal, cd into your httpd source folder (the tab key is your friend).
Now, you can get wildly complicated with this (to see just how complicated, issue ./configure --help), but we're going to stick to the basics for now.
We're going to configure Apache with support for Mass Virtual Hosting (mod_vhost_alia s) and URL Rewriting (mod_rewrite).
Issue the following commands:
-
> ./configure --cache-file=config.cache --enable-shared --disable-static --enable-vhost-alias --enable-rewrite
-
> make
-
> make check
-
> sudo make install
make check will take awhile. Go grab yourself something to drink.
Of course, you will want to make sure that your build doesn't fail any tests before issuing a make install.
Note also that we did not configure Apache with SSL support. To get this working, you will need to install OpenSSL. If you need this, post back, and we'll get you set up.
Compiling MySQL
PHP requires that MySQL be installed first, so the next app to compile is MySQL.
cd into your MySQL source directory.
If you downloaded a pre-compiled version of MySQL, you're all set to go. All you need to do is copy the contents of the distro to /usr/local:
-
>cp -r /usr/local/src/mysql-{version info} /usr/local
-
>ln -s /usr/local/mysql-{version info} /usr/local/mysql
-
Replace {version info} with your MySQL version info. For example, if you downloaded version 5.0.45 for PowerPC, your folder might be named mysql-5.0.45-osx10.3-powerpc.
And you're done.
If you've opted to compile the source code instead, you'll need to issue these commands:
-
> ./configure --config-file=./config.cache --enable-shared --disable-static --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_unicode_ci --with-extra-charsets=none
-
Remove that '--with-extra-charsets=none' if you want to be able to use character sets other than utf8.
MySQL also has additional configuration options (./configure --help).
Next, do the standard
-
> make
-
> make check
-
> sudo make install
-
MySQL's make check takes even longer than Apache's. Go grab something to eat.
Compiling PHP
cd into your PHP source directory.
PHP's a lot of fun to configure (./configure --help). We'll stick to the bare bones here:
-
> ./configure --cache-file=config.cache --enable-shared --disable-static --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd --with-curl
-
> make
-
> make test
-
> sudo make install
-
> sudo pear upgrade-all
-
There are many many MANY more configuration options, and you may need some of them, but fortunately, it is possible (and in fact quite easy) to compile PHP without affecting your Apache nor MySQL installations, so you are always free to experiment, and you can post back anytime you get stuck :)
Note that PHP has make test instead of make check. PHP takes the least time to test of the 'big three'. Go do something that doesn't take long.
PHP will probably fail several tests. That's OK. A lot of functionality in the PHP language is experimental or not widely supported. As an example, my PHP build failed almost 200 tests (out of close to 3000, which works out to approximately 95% passed), but not a single one of them was for functionality that I will ever use.
And you can always recompile and install without affecting any of your other apps.
To start up Apache, issue:
-
> sudo /usr/local/apache2/bin/apachectl start
-
And MySQL:
-
> sudo /usr/local/mysql/support-files/mysql.server start
-
The location of the mysql.server file varies from build to build; it might be in /usr/local/mysql/bin instead.
Tune in next week to find out how to set up Mac OS X to automatically start httpd and mysqld at startup!
PS. Remind me to post this as an article.