Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kogakure/320469 to your computer and use it in GitHub Desktop.
Save kogakure/320469 to your computer and use it in GitHub Desktop.
Bash: Install Django on Mac OSX Snow Leopard

Django Enviroment Setup on Mac OSX 10.6.2 (Snow Leopard)

Install Homebrew

sudo mkdir /usr/local
sudo chown -R `whoami` /usr/local
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C /usr/local
brew install git
cd /usr/local
git init
git remote add origin git://github.com/mxcl/homebrew.git
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git pull

Install Mysql

brew install mysql

Run the mysql setup script that configures your root password. mysql_install_db mysql_secure_installation Change the root password? [Y/n] y Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y

If you have a dump file of previous databases you can install them this way.

mysql -u root -p mysql < /path/to/mysql-dump-file-all-databases.sql

Install Basic Python Packages

Install PIP for easy python package installation

brew install pip

Install MySQL-python

pip install http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz?use_mirror=cdnetworks-us-2

Install virtualenv so you can setup virtual python environments easily for each of your django projects.

pip install virtualenv

Install NGINX

Install nginx using homebrew.

brew install nginx

Backup the origional nginx config file.

cd /usr/local/Cellar/nginx/0.7.65/conf/
cp nginx.conf nginx.conf.orig

Replace /usr/local/Cellar/nginx/0.7.65/conf/nginx.conf with the following.

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

	include /Users/oconnor/Sites/nginx-configs/sites-enabled/*;

}

Restart nginx

/usr/local/Cellar/nginx/0.7.65/sbin -s reload

Setup up Apache and PHP (optional)

Append the following to /private/etc/apache2/httpd.conf

# Include Virtual Hosts
NameVirtualHost *:8000
Include /Users/oconnor/Sites/apache-configs/sites-enabled/

Changed the port apache listens on to 8000. Find the line Listen 80 in the httpd.conf file and change the line to Listen 8000

Install php5 for the native OSX apache2 install. Got the follow steps from a tutorial I found doing a google search.

$  cd /usr/local/
$  git remote add boztek git://github.com/boztek/homebrew.git && git fetch boztek
$  git checkout boztek/php52 && git checkout -b working
$  git pull --rebase origin master
$  brew install php52 --with-mysql --with-apache
$  cd /usr/libexec/apache2
$  sudo mv libphp5.so libphp5.so.orig
$  sudo ln -s /usr/local/Cellar/php52/5.2.12/libexec/apache2/libphp5.so

Uncomment the following line in your httpd.conf

# LoadModule php5_module        libexec/apache2/libphp5.so

Restart Apache

$  sudo apachectl restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment