Skip to content

Installation Instructions (Mac)

Sundar Raman edited this page Nov 30, 2011 · 26 revisions

This is the initial notes on installation of the Change by Us platform on a Mac. This will be messy and possibly incomplete for a while

Installation of core technologies

  • Install homebrew
    • Install XCode
    • ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)" (Check this page for an updated command)
  • Install lighttpd
    • brew install lighttpd
  • Install MySQL
    • Choose one of the following:
      • brew install mysql - be sure to note the post-install caveats
      • You could use MAMP. Simply download the .dmg and install like a normal Mac application. (NOTE: some developers have had issues installing the MySQL Python libraries using MAMP)
  • Install pcre
    • This should already be installed, if not try: brew install pcre
  • Install JPEG Support
    • brew install libjpeg
  • Install Fast CGI (fcgi)
    • brew install spawn-fcgi
    • Attempting to use spawn-fcgi because it was easy and seems to work.
  • Install Memcached
    • brew install wget
    • wget http://topfunky.net/svn/shovel/memcached/install-memcached.sh
    • chmod +x install-memcached.sh
    • sudo ./install-memcached.sh
    • Need to add environment variable. This will change if you are trying to run from a different user.
      • nano ~/.bash_profile
      • Add this line: EVENT_NOKQUEUE=1
      • source ~/.bash_profile
    • Check that it worked: memcached -h
    • See for reference: Lullabot how-to
  • Install beanstalkd
    • brew install beanstalkd
    • Mac OS X Lion has an issue with the current beanstalk script. Solution
  • Install gettext
    • brew install gettext
    • sudo brew link gettext
  • Monit ??
    • Not sure how or why this is needed yet

Setup DB

  • Using MAMP
    • From the MAMP Start Page, click on PHPMyAdmin.
    • Click the "Privileges" tab
    • Click "Add a new User"
    • Enter your user information and choose the option to "Create a new database with full permissions"
    • Click "Go" - this will create your user, a database of the same name, and give your user full permission on that database.
  • Using the MySQL CLI

Get Code

Get the code with Git.

git clone https://[email protected]/localprojects/Change-By-Us.git

All further commands are assuming you are in the directory created from this action (default is lp-changebyus).

Make directories

The application needs the following directories:

mkdir {run,logs,data,data-files}

Create virtual environment (optional)

A virtual environment can help manage Python packages for each application you may be using or running. It is suggested by not necessary. Do the following commands from within the CBU directory.

  • virtualenv cbu.env --no-site-packages
  • source cbu.env/bin/activate
  • In order to exit out of the virtual environment, use the following command: deactivate

Install Python Packages

  • Install pip: sudo easy_install pip
  • pip install -r requirements.txt

Load DB Structure and Data

Currently the data that is provided is NYC specific, so depending on your needs, you may not want to add the data.

NOTE: If you already have a database structure in place, follow the instructions in Data and Schema Migrations to get your database up to date.

  • Using MAMP
    • Since MAMP is already installed, use PHPMyAdmin (you can get to this from the MAMP start page)
    • Choose your CBU database (created above)
    • Click: import
      • Import the file: sql/cfa-models.sql
        • This sets up the database table structure.
      • Import the file: sql/data.sql
        • This adds some user roles and keywords.
      • Import the file: sql/location_data.sql
        • This is neighborhoods and the such and is NY specific
  • Using MySQL CLI
    • mysql -u cbu_user -p cbu_db < sql/models.sql
    • mysql -u cbu_user -p cbu_db < sql/data_badwords.sql
    • mysql -u cbu_user -p cbu_db < sql/data_tasks.sql
    • mysql -u cbu_user -p cbu_db < sql/data_user_groups.sql
    • mysql -u cbu_user -p cbu_db < sql/test_data/data_keywords.sql
    • mysql -u cbu_user -p cbu_db < sql/test_data/data_location_<city-name>.sql
    • mysql -u cbu_user -p cbu_db < sql/test_data/data_community_leaders_<city-name>.sql

NOTE: If you receive a 404 error when trying to open a project page, it may be because you need to load the data_location.sql. When CBU can't find the location attached to a project, it will simply 404. This is not all that helpful and should be improved.

Application configuration

  • Copy the sample config file cp ./etc/config.yaml.tmpl config.yaml
  • Update values as needed (this is not that clear at the moment).
    • Database information (username, password, and db name as created above)
    • Update email information. You should be able to just use your GMail account and password.
    • Update the AWS_SES fields. This is can be commented out if you want to force the use of the SMTP from GMail.
    • Update AWS information (not sure if this is needed yet)
    • Update bucket (not sure if this is needed yet)

WebServer configuration

  • Copy sample configuration: cp lighttpd.conf.sample lighttpd.conf
  • Update values as needed.
    • Update the group and user variables in the first section.
      • var.username = "<your_username>"
      • var.groupname = "<your_group>" (this is probably staff)
    • Uncomment the following line, but ONLY if you're on OSX
      • server.event-handler = "freebsd-kqueue" # needed on OS X

Setup Directories

  • mkdir {run,logs,data}

Start application

  • Start the web server with lighttpd -D -f lighttpd.conf
    • Alternatively, you might need to run /usr/local/sbin/lighttpd -D -f lighttpd.conf
  • Even though it doesn't tell you, the app should be available at http://localhost:8080/
  • If you want to run the app on a different port, set the server.port value in lighttpd.conf

TROUBLESHOOTING

As with all things there will be creeks. But here are the paddles.