Installing Aegir on OS X 10.6 with MAMP

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Aegir install on OSX Snow Leopard

Aegir install instructions are fantastic if you run Debian/Ubuntu Linux. Some of the steps for OS X are a quite different. These instructions assume you are installing on Snow Leopard Client; if you are running on Snow Leopard Server many of these steps will not apply to you.

Setting up the Server components.

Your Mac will need to run Apache, Php, Mysql, and Bind (for DNS). Snow Leopard comes with Apache, Php and Bind installed, however it comes with version 5.3 of Php which is not compatible wit Aegir and other parts of Drupal (as far as I can tell).

The easy solution is to downnload and install MAMP 1.82 from Sourceforge. Here is the direct link: http://sourceforge.net/projects/mamp/files/mamp/1.8.2/MAMP_1.8.2.dmg.zip.... Note: this is not the latest version of MAMP. The latest version runs PHP 5.3 also. MAMP 1.82 runs PHP 5.2.10. This is what we need. This gives us Apache, Php and Mysql. However, OSX still has the original versions of Apache and PHP. So we can trick the system using the MAMP versions as follows:

First back up the original version of Php.

$ sudo mv /usr/bin/php /usr/bin/php-apple

Symlink the MAMP version to /usr/bin/php

$ sudo ln -s /Applications/MAMP/bin/php5/bin/php  /usr/bin/php

Symlink mysql the same way if needed. (If you have never installed Mysql before than this will not be needed).

Back up the original version of apachectl.

$ sudo mv /usr/sbin/apachectl /usr/sbin/apachectl-apple

Symlink the apachectl version to /usr/sbin/apachectl

$ sudo ln -s /Applications/MAMP/bin/apache2/bin/apachectl /usr/sbin/apachectl  

Do the same for httpd.conf:

$ sudo mv /etc/apache2/httpd.conf /etc/apache2/httpd.conf.apple
$ sudo ln -s /Applications/MAMP/conf/apache/httpd.conf /etc/apache2/httpd.conf

Next, set up DNS services. See http://geoffhankerson.com/node/108 for a complete guide

You should now have Apache, Php, Mysql, and Bind running.

Other requirements - the xcode developer toolkit (so you have cvs), and wget. To install xcode, simply download it from http://developer.apple.com/tools/ and install from the .dmg. Wget compiles cleanly on Snow Leopard, so simply download it from http://ftp.gnu.org/gnu/wget/, uncompress, and open a terminal window.

$ cd /path/to/expanded/wget
sudo ./configure
sudo make && make install
  1. Create the aegir user
$ sudo dscl . -create /Users/aegir NFSHomeDirectory /var/aegir  

note: on snow leopard I had to assign a uid to the user in order to be able to chown, etc...
first, check for an unused uid:

dsexport users.out /Local/Default dsRecTypeStandard:Users

then open the file users.out in a text editor, look for the highest 5xx user, then add one, for me it was 505, so I chose 506 as the uid for aegir.
then delete this users.out file to be safe:

rm users.out

now assign this uid to aegir

dscl . -create /Users/aegir UniqueID 506 

note that the 506 may be different on your system.

  1. Set password for Aegir user
$ sudo passwd aegir
New Password:
Retype Password: 
  1. Create aegir home directory
$sudo mkdir /var/aegir
  1. Make aegir user the owner of his home directory
$sudo chown aegir /var/aegir/
  1. Change group to _www
$sudo chgrp _www /var/aegir/
  1. Become the aegir user
 su - aegir
password: 
 

Preparations

Setup CVS repository...

export CVSROOT=:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib  
cvs login  

You might see a warning at this point, which you can ignore ("cvs login: warning: failed to open /var/aegir/.cvspass for reading: No such file or directory"). Just proceed to the next step.

Download Drush and Provision

cvs -z6 co -d drush -r DRUPAL-6--2-0 contributions/modules/drush  
mkdir .drush  
cd .drush
/var/aegir/drush/drush.php dl provision
cd ..

Note: you may have to download and install the PEAR Console_Table package manually from http://pear.php.net/package/Console_Table/download before this step will work correctly.

At this point we need to gain superuser privileges to execute the next few commands, so we logout of the aegir session...

exit  

sudo -s 

chmod u+x /var/aegir/drush/drush   

ln -s /var/aegir/drush/drush /usr/bin/drush  

su - aegir

We're now back as the aegir user.

Test that the drush setup is working:

drush

This should list all available drush commands. Check that it includes the 'provision' commands. If this doesn't work as expected troubleshooting is needed... check the permissions of the directories and drush file. Try

/var/aegir/drush/drush.php

. If that works, then there's a problem with the symlink.

If all is working with drush, let's move on to the next step.

Setup Drupal codebase

We start by checking out the latest drupal 6 release...

drush dl drupal

See how easy drush makes things?!

Get Hostmaster install profile

Hostmaster contains information for setting up Aegir in the new Drupal directory. Change directory (chdir) to your newly-downloaded Drupal installation's "profiles" subdirectory. In my case, drush downloaded it to drupal-6.15:

cd drupal-6.15/profiles 

Then, set it up as follows:

 
export CVSROOT=:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib   
cvs login  
cvs -z6 co -d hostmaster -r DRUPAL-6--0-3 contributions/profiles/hostmaster  
mkdir hostmaster/modules
mkdir hostmaster/themes  
/var/aegir/drush/drush.php dl --destination=/var/aegir/drupal-6.*/profiles/hostmaster/modules hosting install_profile_api admin_menu
/var/aegir/drush/drush.php dl --destination=/var/aegir/drupal-6.*/profiles/hostmaster/themes eldir

Note that the hostmaster profile still needs to be checked out via CVS, as drush has problems downloading profiles (see http://drupal.org/node/500324).

Configure Apache

Now we'll copy across a file template (with the filename changed from aegir.example.com to the domain name of our aegir install)...

mkdir -p /var/aegir/config/vhost.d  
chmod 0711 /var/aegir/config
cp hostmaster/apache2.conf.txt ~/config/vhost.d/aegir.example.com  

Edit this file as you wish, but you must ensure the servername, documentroot and directory are all correct for the codebase. So:

vim ~/config/vhost.d/aegir.example.com

You must also enable php in the apache config file:

vim /etc/apache2/httpd.conf

Find the line where php5 is loaded - Press the "/" key to search, type "php5_module", and hit enter. It will take you to a line that looks like this:

#LoadModule php5_module        libexec/apache2/libphp5.so

Use the left and right arrow keys to position your cursor at the start of the line (over the #), and press "x" to delete that one character. Then type

:wq

Next, we'll create some other useful directories...

mkdir /var/aegir/backups  
chmod 0700 /var/aegir/backups

mkdir /var/aegir/platforms  

mkdir  /var/aegir/drupal-6.*/sites/all/modules  
chmod 0777 /var/aegir/drupal-6.*/sites/all/modules  

mkdir  /var/aegir/drupal-6.*/sites/all/themes  
chmod 0777 /var/aegir/drupal-6.*/sites/all/themes  

mkdir /var/aegir/drupal-6.*/sites/aegir.example.com
cp /var/aegir/drupal-6.*/sites/default/default.settings.php /var/aegir/drupal-6.*/sites/aegir.example.com/settings.php
chmod a+w /var/aegir/drupal-6.*/sites/aegir.example.com/settings.php
mkdir /var/aegir/drupal-6.*/sites/aegir.example.com/files
chmod 2770 /var/aegir/drupal-6.*/sites/aegir.example.com/files

And then...

logout  
sudo -s

So we're now back as root. Next we add the aegir user to the _www group.

 dscl . -append /Groups/_www GroupMembership aegir

If you are using the MAMP apache, you need to add your own user account to the _www group, too.

dscl . append /Groups/_www GroupMembership username

Now we want to tell apache to include aegir's vhost files. Apache will automatically run files in /etc/apache2/other, so add/edit the new file with:

sudo vim /etc/apache2/other/aegir.conf  

putting the following inside it:

Include /var/aegir/config/vhost.d/*  

Next we configure sudo to allow aegir user permission to restart apache:

sudo visudo  

Press '0' then enter to go to the last line. Press 'o' to add a line. Type:

aegir ALL=NOPASSWD: /usr/sbin/apachectl  

Hit Esc. Type ':'. type 'wq' and hit ENTER.

Configure MySQL

We'll now setup the necessary users and database in MySQL.

The main aegir site uses database 'aegir' and a database user 'aegir'.

mysql -uonlyme -p  

mysql> CREATE DATABASE aegir
mysql> GRANT ALL ON aegir.\* TO 'aegir'@'localhost' IDENTIFIED BY 'password';  

We also configure a MySQL 'superuser' who is capable of creating more databases. It is advised to not use the same user as the previous db user, but instead a separate superuser for security. As a naming standard, we recommend calling this superuser 'aegir_root'

mysql> GRANT ALL PRIVILEGES ON \*.\* TO 'aegir_root'@'localhost' IDENTIFIED BY 'password'  WITH GRANT OPTION;  
mysql> exit  

If your database server is running not on the local server but as a remote database server, substitute the 'localhost' commands for the wildcard '%'.

Run the installer

First, restart apache:

sudo /etc/init.d/apache2 restart  

Then in a browser, go to http://aegir.example.com (you will need to have setup the DNS entries for your domain to point at the IP of your server).

Hosting setup

Setup the database with the 'hostmaster' details we created earlier.

The setup will ask you to enter the path to drush.php. This is:

/var/aegir/drush/drush.php  

The configuration path is:

/var/aegir/config  

And the backup path is:

/var/aegir/backups  

We've already done the step of adding the line to httpd.conf.

On the Database page, enter the details for the 'aegir' database user.

On the Web Server page, enter the following values:

System account: aegir
Web server group: _www
Restart command: sudo /usr/sbin/apachectl graceful

On the

At some point during the install you'll be prompted to enter a drush command to run the hosting setup...

su - aegir  
cd /var/aegir/drupal-6.*
/var/aegir/drush/drush.php --uri=http://yoursite.com hosting setup  

Configure Aegir

Aegir is now installed, and you can configure it with your preferred settings. Have a browse around. Read the wiki and other posts on here: http://groups.drupal.org/aegir-hosting-system to find out what you can do with it. Prepare to be excited (if you're a geek)!

For next steps see: Aegir Is Installed - What Next?

Aegir hosting system

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: