Quantcast

Run Drupal locally on your Mac

Ivan's picture

Drupal on your Mac

Drupal is becoming a highly popular CMS and several readers requested for help with installation on their Macs. You can test and build a Drupal site locally on your Mac without the need for a hosting server.

There are many ways of installing Drupal and I'm trying to come up with the simplest solution for you, so I packaged all the needed files into one downloadable package and put together a step by step tutorial. The installation altogether will take around 15 minutes in total.

Please feel free to correct me or further simpify the process. I've written about this subject before, but that was a bit too complicated for some and it didn't touch up on Drupal. Hopefully this time it's going to be easier.

  1. Download this package which includes all files you will need in step two, three and four.
  2. Update PHP by running the installation file for Entropy-PHP-4.3.10-1. PHP is installed on OS X by default, but you may want to update it. This is the programming language that will run your web site.
  3. Install MySQL: CompleteMySQL-4.0.21. MySQL doesn't come with OS X. This is the database engine that will serve your site with data.
  4. Drag the MySQL.prefPane from the mounted volume to your System Preferences pane to add.
  5. Open your new System Preferences called MySQL and click Initialize. You will need to put your MySQL password, which is not set at this stage, so just press Enter and then you will need to put your admin password. Once it's finished, you can click Start.
  6. Install CocoaMySQL-v0.5. This is free OS X application that will help you manage your databases. Put it into your Application folder.
  7. Switch on Personal Web Sharing in your System Preferences/ Sharing/ Services pane. This will start the built in Apache server on your Mac.
  8. Copy the Drupal folder into your /Library /Webserver/ Documents/ folder. (Main root directory, not under your user.)
  9. Open CocoaMySQL and enter host:localhost and user:root. Leave the rest empty.
  10. Click the little icon on the left with a plus sign to add a new database and enter: drupal.
  11. Now still in CocoaMySQL go to File/ Import/ CocoaMySQL dump and select this file: /Library /Webserver/ Documents/ drupal/ database/ database.mysql. This will populate your new database with the essential data to run your Drupal site.
  12. Open your browser and type http://localhost/drupal.
  13. Register the first user, which will be the administrator user on your local site. It doesn't matter what email address you enter. Once you are logged in change your password to something you can easily remember under the edit tab.

Now you can start adding content and exploring the different features of Drupal.

Optionally you may want to add a password to your MySQL. You can do that in the MySQL system preferences by clicking the Set Root Password. Once you set it up you will need to open a file: /Library /Webserver /Documents /drupal /sites /default /settings.php and find the line that starts as $db_url = 'mysql://root: and enter your password right after it and just before the @ sign. Save.

To password protect your whole site you can follow these directions

Dalis Moustache's picture

Interesting

I found your blog today, loving these OSX geek/graphics tips. Very cool stuff. I'm going to play with Drupal tomorrow…

http://dalismoustache.blogspot.com/

Ivan's picture

welcome!

Let me know if you have any issues. We've run a test of this tutorial with Tigerstorm and he managed to install Drupal following the steps.

scott's picture

MAMP?

what about installing it on mamp (http://mamp.info) so you don't have to modify os x? mamp has php 4.3.11, apache 2.0.50 and mysql 4.0.20.

of course you wouldn't want to use this as a production server - but it is an option for those who just want to play locally and don't want to modify os x.

Ivan's picture

That's a good option. How

That's a good option. How would the port settings of MAMP modify the installation of Drupal?

scott's picture

that's a good question. i

that's a good question. i haven't had time to try it out yet, but it's next on my list of to-dos.

liske's picture

Wow

Ivan that is very generous of you to set up an option like this for Drupal Newbies!

If I wasn't overwhelmed with having a baby, multiple web projects, closing ecrow on another fixer-upper rental, doing an open house party next week, being best man in my brothers wedding, I would be trying it out. Perhaps in August then.

I really like the DIY, roll up the sleeves approach you have and the community here at CB. Kudos.

Ivan's picture

Congrats on your baby! That

Congrats on your baby! That beats all geek stuff! :D

Josh's picture

XAMPP

Although I use windows (don't hurt me!), you guys/girls might find this app useful:

http://www.apachefriends.org/en/xampp-macosx.html

The OS X version is pretty new, but its very simple and easy/quick to use. You just install it, and in seriously 2 clicks of your mouse you have a fully functional test server running.

This version is still in progress for OS X, but this app is absolutely priceless for me on my PC. If the Mac version is just as good, it's a must-have (which I hope, as I plan on getting a mac again soon).

---------------------
Josh Stevens | Nautilus7 Design

vik407's picture

no problem in IIS

i installed drupal in IIS without any problems, some things dont work but are the standar from web applications made in linux...

Anonymous's picture

Didn't Work

I tried, all I get when I try to access my http://localhost/drupal url is an error "illegally written in line 90-123"

how do you uninstall everything? Im afraid this is over my head.

Ivan's picture

Do you only get an error at

Do you only get an error at the very last step? Can you give the whole error message?

You can just trash the Drupal folder if you don't want it. MySQL folder is in /Library.

chromatic@drupal.org's picture

I run a localhost setup on

I run a localhost setup on my linux computer. It's super sweet and I highly recommend it to anyone designing drupal websites. Here's a couple useful tips:

1. install running a multisite setup. If you are creating designs for a few sites just install one codebase and setup using drupal's multisite capabilities. I don't prefix my separate databases but specify a new database for each site. I think it keeps things a little more clean that way. This method has some great benefits - you can import your current website to your local installation and test modules and new designs. Since there is one theme and modules folder that links to all the sites it's a breeze to test themes with different block and column settings too. Finally, it's much easier to maintain a theme if you have one codebase for it -- previously I would work on a theme then try it on a different website to see how flexible it was but then the two different sites would end up being asyncronous, one would fix something and the other might have another fix.

2. If you are going to test existing sites you'll probably need to open your php configuration file and increase the maximum size for the database. I guess that may be specific to phpmyadmin (which I run locally). I think the default upload through php is 2mb. I changed mine to 20mb and had no problems afterward. It could be overkill, but I was importing a big site.

Ivan's picture

PHP setting on a Mac?

Where do I find it? I did have problems importing large databases. Thank you!

chromatic@drupal.org's picture

php.ini

In your php.ini file (for my system it's located in /etc/php4/apache2) check the sizes of

upload_max_filesize
memory_limit
post_max_size

I've set them all to 20mb. It may not be good practice, ie - it might slow things down overall. I would determine the size of the database to import and use best judgement.

You'll probably need superuser or root access to the file to save it. I'll leave that up to the Macheads to figure out. And don't forget to make a backup first!

Ivan's picture

Thanks!

Will try this.

Josh's picture

Just curous...version?

Hi Ivan, I was just curious what version of Drupal comes with the package you created?

Thanks!

---------------------
Josh Stevens | Nautilus7 Design
My CB Blog

Ivan's picture

One new version came out

One new version came out since the package was created. You should download the latest from Drupal.

Josh's picture

Thanks!

Thanks for the reply (and most importantly this thread :-))

For some reason I am getting errors when copying my themes over, and thought it might have something to do with it :/

*EDIT*
The errors were caused by incorrect file permissions. Oops!

---------------------
Josh Stevens | Nautilus7 Design
My CB Blog

Donateko's picture

A little late

Ivan, I know this post is a little old, but I did everything without a problem except when I type: http://localhost/drupal it does not work, it just wont open, what should I do?

--designer wannabe--

logangreer's picture

(moved to appropriate

(moved to appropriate thread)

User login

Partner With Us













Latest critique

New Website