setting up AMP (Apache2, MySQL5, PHP5) on OSX 10.5 Leopard with Fink

My Dell XPS1330 with lovely Ubuntu decided to stop working. I hate Windows Vista and I needed a good wireframing and graphic tool so I had no choice but to buy a Mac. Since OSX is based on FreeBSD, I thought setting up AMP was a piece of cake. But I quickly found out it wasn't the case...
I tried setting up vitrual hosts with apache that comes with OSX, but I keep getting 'access denied' and can't set it up. Also the directory structure is quite different from the one I'm used to. I was going 'where is "sites-available" and "sites-enabled"?' and stuff.

I was advised by my friend Chris to try out MacPorts, and it is also James Walker's choice of package management tool. While James' observation is correct and MacPorts seems to be better at keeping packages up-to-date, I ended up in settling it up with Fink because I'm more accustomed to Debian/Ubuntu.
Overview of the process:

  1. Disable OSX's apachectl
  2. Download, install and configure fink
  3. Install AMP
  4. Various tweaks to make the system work

 
So the actual steps:

  1. disable OSX's apachectl
  2. After installing Apache2 with Fink, you will have two Apache servers on your Mac. This will cause confusion so I made OSX's apachectl command unusable. First we make sure OSX's apache is disabled. To terminate the service, open System Preference -> Sharing, then untick 'Web sharing', or type the command below in the terminal:
    apachectl stop
    Then enter the command below:
    sudo mv /usr/sbin/apachectl /usr/sbin/apachectl.disabled
     

  3. Download and install Fink
    • Download and install FinkCommander from FInk's project page
    • After installation, you need to open FinkCommander's config panel and tick 'use unstable packages'. Apache2 and other stuff won't be available otherwise (it took me so long to figure this out...)
    • run selfupdate (in the menu bar, Source -> Self-update). Fink then retrieves a list of the latest packages.
    • run one of Fink's script to add Fink's directory to your path:
    • /sw/bin/pathsetup.sh

  4. install AMP
    Mind you, this process takes *fucking ages* because you download the source files AND also compile them
    • apache2
    • libapache2-mod-php5
    • php5
    • mysql
    • php5-mysql
    • phpmyadmin
  5. Select these packages in FinkCommander and click 'Install package from source' button. Now make yourself a tea, drink it, go for a walk, take a nap, have a meal, watch a movie and go to bed. It will be halfway done by the morning :p

  6. Various tweaks
    • autostart MySQL
    • $ sudo daemonic enable mysql
      $ sudo /Library/StartupItems/daemonic-mysql/daemonic-mysql start
      $ sudo cp share/mysql/my-medium.cnf /etc/my.cnf  

    • enable apache modules
    • sudo a2enmod rewrite
      sudo a2enmod php5

    • tweaking mysql's socket config for php
    • change /etc/my.cnf and /etc/php.ini's socket to /private/tmp/mysql.sock (or any correct path)

Finally, reboot apache and it should be good to go!
sudo apache2ctl restart
references:

 

Comments

Hey Mori, Thanks for the

Hey Mori,

Thanks for the amazing tutorial! I hate being bound by MAMP to just my htdocs directory, because sometimes you need to setup special directory structures when working with client's projects you checkout from CVS or SVN. So I feel like this is a much needed tutorial for serious web developers using OSX (unless you compile AMP in a different way).

One thing that might help others getting a bit stuck and only getting php5-ssl, instead of php5, is that you're probably getting some errors in the command output of Fink (View -> Show Comman Ouput). I got this:

W: Couldn't stat source package list file: unstable/crypto Packages (/sw/var/lib/apt/lists/_sw_fink_dists_unstable_crypto_binary-darwin-i386_Packages) - stat (2 No such file or directory)
W: Couldn't stat source package list file: unstable/crypto Packages (/sw/var/lib/apt/lists/_sw_fink_dists_unstable_crypto_binary-darwin-i386_Packages) - stat (2 No such file or directory)
W: You may want to run apt-get update to correct these problems
E: Some index files failed to download, they have been ignored, or old ones used instead.

If this is the case I suggest opening Terminal and running:
fink scanpackages
You can probably do it from Fink itself but I did it with Terminal. After that ran successfully I ran:
sudo apt-get update
When this is done go to Fink Commander and you should have php5 listed and not php4ssl and php5ssl and all that weird stuff.

Cheers

Glad you got it sorted and

Glad you got it sorted and thanks for the info! Yeah, to be honest, I wrote this tutorial after I finished setting everything up so there may be some bits that are missing. It may work slightly differently depending on which version of OS / Xcode / Fink you are using too. I would suggest people to fiddle around a bit if it doesn't install.

But what about the specifics?

It's nice to know that everyone told you to use macports and you used fink instead, and that you summarize the setup step into one line that says change apache config, change php config, change mysql config.

But for some weird reason your blog post has a high place in google for trying to find how to make macports install php with apache and make the configuration work ... and this page has no such information.

makes me a bit sad.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.

More information about formatting options