You must first sign up to be able to contribute.

I had to install a working Symfony environment on a MacBook? Pro. Maybe this can help some of you using Mac OS X asking whether they can switch or not. The best tool I've found for symfony and Mac Intel is MacPorts.

So first install MacPorts?, follow the instructions carefully. Note that the XCode tools distributed by Apple with OS X must be installed for MacPorts? to work.

Then to install PHP5 with Apache2 and MySQL4 support:

sudo port install php5 +macosx +mysql4 +apache2

Now take a deeeep breath, go get a coffee, watch the news, it can take a long time :)...

If you get an error about "php/.lock" or "php/.xx files already installed",

sudo port remove php5

If it complains about multiple versions of php5, remove the old version:

sudo port remove php5 @..someversion..

Then try to install again.

Here we have the whole application compiled, now we do some setup:

  • Apache2 :
    1. You can add the apache2 support programs to your $PATH, just add /opt/local/apache2/bin" to the '~/'.profile file that is created when you setup DarwinPorts?
    2. In /opt/local/apache2/conf rename the httpd.conf.sample to httpd.conf and change the conf you want

  • PHP5 :
    1. Go into /opt/local/apache2/modules and type /opt/local/apache2/bin/apxs -a -e -n "php5"
    2. Then it looks like a little bug hit darwinport, so to activate PHP5 in apache2, edit /opt/local/apache2/conf/httpd.conf and add this
      # php5 settings
      Include conf/extras-conf/mod_php.conf
    3. Rename either /opt/local/etc/php.ini-dist or /opt/local/etc/php.ini-recommended to /opt/local/etc/php.ini
    4. Symphony needs magic_quotes_gpc off, so be sure to check if it is off in php.ini:
      ; Magic quotes for incoming GET/POST/Cookie data.
      magic_quotes_gpc = Off
    5. Currently PEAR is no longer included with PHP5 in DarwinPorts?. So we use PEAR from OS X itself. So we need to enable that in php.ini. Search for include_path and edit the line so it reads as follows:
      ; UNIX: "/path1:/path2"
      ;include_path = ".:/php/includes
      include_path = ".:/php/includes:bin/lib:/opt/local/lib/php:/usr/lib/php/"
    6. To really use PEAR with PHP5 from DarwinPorts? you will need to add the following to your .profile:
      export PHP_PEAR_PHP_BIN=/opt/local/bin/php
  • MySQL4
    1. Change ownership:
      chown -R mysql:mysql /opt/local/var/db
      chown -R mysql:mysql /opt/local/var/run/mysqld
      chown -R mysql:mysql /opt/local/var/log/mysql
    2. Create the default database:
      sudo -u /opt/local/bin/mysql_install_db --user=mysql

Et voila! It's done. Now you can run as root :

/opt/local/apache2/bin/apachectl start
/opt/local/bin/mysqld_safe &

You can change /opt/local/apache2/conf/extra/httpd-vhost.conf to add your Symfony virtual host.

Symfony on Leopard

To install symfony on leopard using the PHP5 version included in the system, use these commands as PEAR-BASE in darwinports has bugs with leopard

sudo su -
curl > go-pear.php
php -q go-pear.php

pear channel-discover
pear install symfony/symfony

You can change /private/etc/apache2/extra/httpd-vhost.conf to add your Symfony virtual host like the following:

<VirtualHost *>
ServerName YourServerName
DocumentRoot "/Users/YourUserName/Sites/YourProjectFolder/web"
DirectoryIndex index.php
Alias /sf /usr/share/pear/data/symfony/web/sf
<Directory "/Users/YourUserName/Sites/YourProjectFolder/web">
AllowOverride All
Allow from All

Don't forget to uncomment the line

# Include /private/etc/apache2/extra/httpd-vhosts.conf

in /private/etc/apache2/httpd.conf

If DarwinPorts? seems imposing; you can install the universal packages made by Marc Liyanage at, if you don't need to compile PHP/MySQL. His packages include many common PHP extensions (including PostgreSQL and GD).