-
Notifications
You must be signed in to change notification settings - Fork 4
Installing TidePools on MacOS X
Make sure your software packages are up-to-date by selecting 'Software Update…' from the Apple menu in the top left-hand corner of your screen.
- Mac OS v.10.7.5
- MAMP v.2.1.1
- Apache v.2.2.22 (Unix)
- PHP v.5.3.15 with Suhosin-Patch (cli)
- Xcode 4.3
- MacPorts v.2.1.2 *** PHP Driver for MongoDB **
- MongoDB v.2.2.2
- Docroot folder: /Users/USERNAME/Sites/tidepools.local
You can check your versions using the following methods:
Mac: sw_vers -productVersion
MAMP: Install the latest version via http://www.mamp.info/en/index.html
Apache: httpd -v
PHP: php -v
PHP Driver for MongoDB: Create phpinfo.php and view it in your browser as shown below
MongoDB: mongo -v
#Installing Required Applications
Follow these instructions, replacing 'nano' with your preferred text editor (eg; emacs)
You'll first need to install MAMP (a local server environment for Mac), which includes Apache, MySQL and PHP. This can be downloaded at http://www.mamp.info/en/index.html.
Next, you'll need to install Xcode and MacPorts, a package manager for Mac OS X that makes it easy to install and configure a lot of open-source software. Xcode can be downloaded from the Mac App Store. You will also need to install Command Line Tools for XCode. MacPorts can be downloaded from macports.org.
#Install and Configure MongoDB
Open a Terminal (which can be found by going to Finder -> Applications -> Utilities -> Terminal), ensure you're using an account with Administrator privileges (by typing 'sudo su -' and typing in your password), and type:
port install mongodb
After MongoDB has been installed, create the directories required by MongoDB:
mkdir -p /var/lib/mongodb
mkdir -p /var/log/mongodb
Create a config file:
nano /etc/mongodb.conf
In the config file, paste the following:
# This is an example config file for MongoDB.
# Place it at /etc/mongodb.conf
# Based on a sample provided at
# http://www.mongodb.org/display/DOCS/File+Based+Configuration
dbpath = /var/lib/mongodb
bind_ip = 127.0.0.1
noauth = true
Save the file and quit.
#Enable Apache and PHP5
Start Apache:
In System Preferences, go to Sharing, and then check the box next to “Web Sharing”.
Enable PHP5 support in Apache:
Open the Apache config file, /etc/apache2/httpd.conf, and locate the following line.
# LoadModule php5_module
Uncomment that line, so it reads:
LoadModule php5_module
Restart Apache. Type in a Terminal window:
apachectl graceful
Test if PHP is working correctly. Create a new PHP file at /Library/WebServer/Documents/phpinfo.php and paste the following:
<?php phpinfo(); ?>
Browse to http://localhost/phpinfo.php, and you should see a long page showing your PHP configuration.
Apache and PHP5 are now configured.
#Install and Configure the PHP5 MongoDB driver.
Install PEAR. PEAR is the PHP Extension and Application Repository, from which we’ll install the PHP5 MongoDB driver.
cd /tmp
curl -O http://pear.php.net/go-pear.phar
php -d detect_unicode=0 go-pear.phar
You’ll be prompted with a default file layout. Change this to install it in /usr/local/pear instead of under /Users/Admin.
Below is a suggested file layout for your new PEAR installation. To change individual
locations, type the number in front of the directory. Type 'all' to change all of them
or simply press Enter to accept these locations.
1. Installation base ($prefix) : /Users/Admin/pear
2. Temporary directory for processing : /tmp/pear/install
3. Temporary directory for downloads : /tmp/pear/install
4. Binaries directory : /Users/Admin/pear/bin
5. PHP code directory ($php_dir) : /Users/Admin/pear/share/pear
6. Documentation directory : /Users/Admin/pear/docs
7. Data directory : /Users/Admin/pear/data
8. User-modifiable configuration files directory : /Users/Admin/pear/cfg
9. Public Web Files directory : /Users/Admin/pear/www
10. Tests directory : /Users/Admin/pear/tests
11. Name of configuration file : /Users/Admin/.pearrc 1-11, 'all' or Enter to continue:
At this prompt, type 1
(Use $prefix as a shortcut for '/Users/Admin/pear', etc.)
Installation base ($prefix) [/Users/Admin/pear] :
At this prompt, type '/usr/local/pear'
Below is a suggested file layout for your new PEAR installation. To change individual
locations, type the number in front of the directory. Type 'all' to change all of them
or simply press Enter to accept these locations.
1. Installation base ($prefix) : /usr/local/pear
2. Temporary directory for processing : /tmp/pear/install
3. Temporary directory for downloads : /tmp/pear/install
4. Binaries directory : /usr/local/pear/bin
5. PHP code directory ($php_dir) : /usr/local/pear/share/pear
6. Documentation directory : /usr/local/pear/docs
7. Data directory : /usr/local/pear/data
8. User-modifiable configuration files directory : /usr/local/pear/cfg
9. Public Web Files directory : /usr/local/pear/www
10. Tests directory : /usr/local/pear/tests
11. Name of configuration file : /Users/Admin/.pearrc 1-11, 'all' or Enter to continue:
At this prompt, type 11
(Use $prefix as a shortcut for '/usr/local/pear', etc.)
Name of configuration file [/Users/Admin/.pearrc] :
At this prompt, type /etc/pearrc
Below is a suggested file layout for your new PEAR installation. To change individual
locations, type the number in front of the directory. Type 'all' to change all of them
or simply press Enter to accept these locations.
1. Installation base ($prefix) : /usr/local/pear
2. Temporary directory for processing : /tmp/pear/install
3. Temporary directory for downloads : /tmp/pear/install
4. Binaries directory : /usr/local/pear/bin
5. PHP code directory ($php_dir) : /usr/local/pear/share/pear
6. Documentation directory : /usr/local/pear/docs
7. Data directory : /usr/local/pear/data
8. User-modifiable configuration files directory : /usr/local/pear/cfg
9. Public Web Files directory : /usr/local/pear/www
10. Tests directory : /usr/local/pear/tests
11. Name of configuration file : /etc/pearrc 1-11, 'all' or Enter to continue:
At this prompt, type Enter
Would you like to alter php.ini </private/etc/php.ini>? [Y/n] :
At this prompt, type Y.
Install the PHP MongoDB driver:
/usr/local/pear/bin/pecl install mongo
Check for php.ini in /private/etc/php.ini. If it's not there, type the following:
cp /private/etc/php.ini.default /private/etc/php.ini
Add the following line to php.ini, after searching for 'extension=':
extension=mongo.so
Restart Apache:
apachectl graceful
Create a simple test script:
nano /Library/WebServer/Documents/mongodb.php
Paste the following:
<?php $mongoDB = new Mongo(); $database = $mongoDB->selectDB("example"); $collection =
$database->createCollection('TestCollection'); $collection->insert(array(test => 'Test OK'));
$retrieved = $collection->find(); foreach ($retrieved as $obj) { echo($obj['test']); } ?>
Test the installation. Browse to http://localhost/mongodb.php.
If you see the following output, then congratulations, MongoDB is properly installed and configured to work with PHP on your Mac!
Test OK
You're now ready to install TidePools.
#Installing TidePools
Download Github for Mac: http://mac.github.com/
Clone the Github repository for Tidepools via the 'Clone for Mac' button in the top left- hand corner of the Tidepools repo: https://github.com/opentechinstitute/TidePools
Save it in your Downloads folder: /Users/USERNAME/Downloads
Move the folder to /var/www:
mv /Users/USERNAME/Downloads/TidePools /var/www/
Uncomment vhost line in extra:
**Find vhost line and put this here**
Create a virtual host file:
nano /etc/apache2/extra/httpd-vhosts.conf
Replace the contents of this file with the following:
NameVirtualHost *:8888
<VirtualHost *:8888>
DocumentRoot "/var/www/TidePools"
ServerName tidepools.localhost
ErrorLog "/private/var/log/apache2/tidepools.localhost-error_log"
CustomLog "/private/var/log/apache2/tidepools.localhost-access_log" common
</VirtualHost>
Edit your /etc/hosts file:
nano /etc/hosts
Paste the following at the bottom of the file:
127.0.0.1 tidepools.localhost
Restart Apache:
/Applications/MAMP/bin/stopApache.sh
/Applications/MAMP/bin/startApache.sh
If you receive the error: "port: command not found" when attempting to install MongoDB, you likely need to edit your .bash_profile with the following:
cd ~/
nano .bash_profile
Paste the following:
export PATH=$PATH:/opt/local/bin
export MANPATH=$MANPATH:/opt/local/share/man
export INFOPATH=$INFOPATH:/opt/local/share/info
Save and close the file, then type the following to reset .bash_profile:
. .bash_profile