Pre-requsites: You already have Apache server and MySQL server installed on your Mac. If not, you can follow this guide to install them.
The Only Web-based Developer Environment Built for Drupal. Cloud IDE has everything you need to write great code and create experiences. Designed specifically for Drupal, set up in minutes. Acquia Dev Desktop 2.0 for Mac can be downloaded from our website for free. The most popular version of the program is 2.0. The software lies within Developer Tools, more precisely Webmaster Tools. Acquiadevdesktop-2-rc-2014.dmg is the most common filename for this app's installer. This free Mac app is a product of Acquia Inc.
1. Download the zip file from drupal.org, unzip it and rename the folder to example. The following commands in the Terminal, creates a folder sites in your home directory, mv the unzipped drupal folder to the folder sites and rename it to example.
2. Create a database called example in mysql
3. Make a copy of the default settings php file, and create a files folder in sites/default/, and give read, write and execute permissions
4. Create example.config for adding the drupal example website to the apache server. Change yourname in the following to your max os username that appears on the Terminal window.
5. Openg the apache config file and include the config file created from the above step. If you installed apache 2.4 using brew, the config file is in /usr/local/etc/apache2/2.4/httpd.conf, open it using your favoriate text editor, add this line at the end and save it. Again, yourname is your user name.
6. Open the host file in /etc/hosts using your favorite text edit, add the following and save it.
7. Restart Apache server.
8. Visit example.com in your favorite browser and you shall see the drupal installation page.
9. Follow and complete the installating steps and you will have a fresh drupal installed on your Mac.
10. If you see command line messages like permission denied when running any of the above commands, just add sudo in front of the command and it will prompt you for password. As long as you have the admin right, you will be fine.
MacOS comes with PHP 7, Apache2 http server, and SQLite built-in which is everything you need to run a Drupal site. If you want to use MySQL, that is an additional install. In this guide, we will look at how to setup Drupal on your Mac.
PHP should be installed by default. You can verify it by running:
To use Drupal, simply download and extract the files somewhere on your disk.
The sites/default/files/
directory will need to be writable by the web server.The default user and group that run are _www
and can be configured in /etc/apache2/httpd.conf
file.You can use chmod
and chown
to grant write permissions to the server.
The sites temporary files directory will need to be writable, as well as the public and private file system dirs. These directories are configured in the Drupal web interface at /admin/config/media/file-system
. Follow the same chown
and chmod
operations for any directory or file that needs writing by the server.
You will also need to copy the default.settings.php
to settings.php
and make it writable to use the web interface installer.
The best way to set up local sites with Apache is to use virtual hosts.
In your main Apache configuration file /etc/apache2/httpd.conf
:
LoadModule php7_module libexec/apache2/libphp7.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
Then in the same file, make sure to uncomment the lines related to virtual hosts:
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
Include /private/etc/apache2/extra/httpd-vhosts.conf
Then update the file /private/etc/apache2/extra/httpd-vhosts.conf
with the entries for your virtual hosts like this example:
You will also need to update your /etc/hosts
file to provide a local domain name that matches the ServerName
of your vhost like:
Control the Apache2 http server with the commands:
This step is optional, since you can choose to use SQLite instead.
Install MySQL using the official installer.When it asks what authentication method to use, choose the optionthat maintains legacy support with MySQL 5.
To start MySQL server, go to the System Preferences | MySQL and start.
sudo /usr/local/mysql/support-files/mysql.server stop
NOTE: The database configuration in your Drupal settings.php
may not work with localhost
and might need to be 127.0.0.1
.
After you have Apache configured and your Drupal files and permissions setup, you can start the Apache server and visit your site in the browser. In my example, my virtual host ServerName was mydrupal.local
and I updated my /etc/hosts
file to add mydrupal.local
so I can use my browser and visit http://mydrupal.local/
and I should see the Drupal site. If you have not configured your site in the settings.php
file already, it will prompt you to provide your site information.
After reading this, you should understand the steps involved with setting up a Drupal site on MacOS using PHP, Apache2 and MySQL.