The OS X installation instructions at Drupal.org will have you install MAMP, which is maybe a little weird, since Apache and PHP are pre-installed with OS X.
Also a little weird is that there are not a lot of resources available for setting up a Drupal installation without going the recommended MAMP route. However, Vesa Palmu put up a very thorough walkthrough at http://mearra.com/blogs/vesa-palmu/how-setup-mac-os-x-106-drupal-environment.
I had a few small problems with Vesa’s instructions, almost entirely due to me not knowing enough about what I was doing. All in all, I think it’s a great resource. If you are already fairly experienced with configuring Apache and MySQL on your machine, you may not need any of the information below.
Note that this information is just a set of notes and may have some holes in it… Please drop me a line in the comments if you have any corrections or additions.
Vesa’s post is organized into a couple of headers, and my notes follow those headers. I recommend reading my post and Vesa’s all the way through before doing anything, by the way (hindsight).
System setup
In the System setup section, I discovered while trying to install Drupal that I had to export the mysql path to ~/.bash_profile, as well as to ~/.profile.
Also, during Drupal installation I found I had to manually change references to /var/mysql/mysql.sock (change them to /tmp/mysql.sock) – so the instructions for linking these files may not be relevant – but it doesn’t hurt anything, as far as I can tell.
Configuring Apache
The only part of the instructions that gave me any trouble was the section on setting up virtual hosts. Virtual hosts (in this context) are a convenience and not at all necessary. The idea is that you will be able to type http://drupal to hit your Drupal installation, rather than something like http://localhost/~rosshenderson/drupal. However, this section of the instructions actually derailed me a bit, as it turns off normal usage of the Sites directory (http://localhost/~rosshenderson/site root).
For now, do not comment out the User home directories include in httpd.conf (Include /private/etc/apache2/extra/httpd-userdir.conf)
I’m not sure why this is part of the given instructions, but I think it has to do with the next set of steps, which involve setting up a series of virtual hosts. The virtual hosts are a convenience and not at all necessary. Since getting my installation running, I haven’t gone back and experimented further with virtual hosts, but I will try to do so in the near future. For now, just ignore all instructions that have to do with setting up virtual hosts, and put your Drupal installation in your Sites directory (i.e. unpackage the Drupal download in the Sites directory). I named my root Drupal folder ‘drupal’, and access it at http://localhost/~rosshenderson/drupal. Would be nice to be able to hit it at http://drupal, but we’ll see.
Ignoring the virtual hosts instructions includes:
1. Commenting in the Include /private/etc/apache2/extra/httpd-vhosts.conf
line in httpd.conf (leave it commented out).
2. All modifications to httpd-vhosts.conf.
Installing Drupal
Note that the terminal command provided for creating databases assumes that you have not set up a password for your root user via phpMyAdmin, or some other way. If you already have a password set up for your root user, change:
mysql -uroot -e “create database drupal6;create database drupal7;”
to:
mysql -uroot -p[your password] -e “create database drupal6;create database drupal7;”
Incidentally, you can actually just skip this step, since you have to do some work in phpMyAdmin as part of the Drupal installation instructions, anyway.
These minor modifications to the post got me to the point where I was ready to install Drupal.
Lastly, I unpackaged phpMyAdmin in my /Library/WebServer/Documents directory (so it is available at http://localhost/phpMyAdmin).
If you don’t have the mySQL panel installed in your Preferences Pane, you can start/stop/restart mySQL via the terminal like so:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
sudo /Library/StartupItems/MySQLCOM/MySQLCOM restart
(thanks to mloughran’s response to this question on StackOverflow)
Setting up Drupal
The Drupal installation guide is available at http://drupal.org/documentation/install.
Since you have already downloaded Drupal, go to Step 2: Create the database – even if you created a database while following the mearra instructions.
Next, move on to Step 3: The settings.php file. Not having worked with PHP for quite awhile, I got stuck here for a bit because the initial setup of phpMyAdmin allows a username of ‘root’ with no password, which is what I was using. I had to go into phpMyAdmin and change the password before I could get a working connection going.
Around line 93 of settings.php there is a line that should look something like this:
$db_url = ‘mysql://root:drupa1@localhost/umdrupaldb’;
Or, if you created a user called ‘myUser’ with a password of ‘myPassword, and a database called ‘myDrupalDb’:
$db_url = ‘mysql://myUser:myPassword@localhost/myDrupalDb’;
The format, given a few lines above, is: $db_url = ‘mysql://username:password@localhost/databasename’;
Finally, move on to Step 4: Run the installation script. Here’s where this document really pays off, if you are working with Drupal 6. First, you have to scroll down quite a ways to get to the Drupal 6 instructions.
Secondly, the instructions are wrong. DO NOT point your browser to the base URL of your Drupal site – point it at baseURL/install.php.