Category Archives: SysAdmin

Installing Django on CentOS

These are notes for what I did to get Django working on CentOS.

Activate EPEL.

Use the appropriate version, of course. I used:

[bash light=”true”]
$ sudo rpm -Uhv

Install Prerequisites

  1. Install Apache.
    1. Ensure it’s working, including ensuring the firewall lets traffic through.
  2. Install MySQL
  3. Install revision control or however you pull software, e.g. git.
    1. Create a non-priviledged user, if that’s you install your software.
    2. Ensure Apache can access the software directory.

Install Django

[bash light=”true”]
$ sudo yum install python Django mod_python MySQL-python

Test Django

[python light=”true”]
$ python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print django.get_version()

Install and Test the Software

I create a separate user for managing the code via git.
Put the code somewhere appropriate, e.g. /opt.

  1. The address tells Django to accept external connections.
  2. Ensure the test port is open on the firewall.

[bash light=”true”]
$ cd /opt/foo
$ python runserver

Attempt to connect to your application. Ensure, for example, that the settings allow database access.

Running Django from Apache WSGI

Create an Apache WSGI file.

[bash light=”true”]
$ cd /opt/foo
$ mkdir apache
$ vim apache/django.wsgi

and fill the file with something like:

import os
import sys


os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘foo.settings’

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


Inside of the Apache virtual host:

<VirtualHost *:80>

WSGIScriptAlias / /opt/foo/apache/django.wsgi

# Alias /robots.txt /opt/foo/static/robots.txt
# Alias /favicon.ico /opt/foo/static/favicon.ico
Alias /static/admin/ /usr/lib/python2.6/site-packages/django/contrib/admin/media/
Alias /static/ /opt/foo/static/

<Directory /opt/foo>
Order allow,deny
Allow from all

<Directory /opt/food/static>
Order deny,allow
Allow from all

Restart the Apache server.

Test to ensure that you can connect.


A big shout out to ITek Blog’s article Installing Python / Django on Centos 6.3 is Easy!.

Auto Updating with git Submodules

I like to be able to poke a remote machine and have it update itself (notes are in Remote Control Via ssh Keys). I also like to break projects up using git submodules.

These are my notes for setting up the remote machine’s project directory.

I’m no git wizard, so this may not be optimal; but it seems to work.

$ git clone –recursive [url] [directory]
$ git checkout [branch]
$ git submodule update –init –recursive
$ git submodule foreach git checkout [branch]

The auto updater can then run:

$ git pull
$ git submodule foreach git pull

Installing Django on CentOS 6

Django is available as an EPEL package.

First, activate EPEL via

[code lang=”bash”]
$ sudo rpm -Uvh

or for 32-bin CentOS,

[code lang=”bash”]
$ sudo rpm -Uvh

NOTE: That exact URL will change with time. I took it from the EPEL FAQ.

Next, install the Django package.

[code lang=”bash”]
$ sudo rpm install Django

Ensure that Django is working.

[code lang=”python”]
$ python
Python 2.6.6. (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or license" for more informaiton.
>>> import django
>>> print django.get_version()
>>> _

Install wget on OS X

These notes assume Xcode and the command-line tools are installed.

Get the current wget from the GNU FTP site. As of the date of this article, wget 1.14 is current. (Update: As Alex notes in the comments, 1.15 is available.)

Building is the typical GNU build sequence, but use the –with-ssl=openssl option with configure.

[code lang=”bash”]
curl -O
tar xvzf wget-1.15.tar.gz
cd wget-1.15
./configure –with-ssl=openssl
sudo make install

And it’s done.

Fixing Mountain Lion Runaway parentalcontrolsd

We upgraded a machine to Mountain Lion (10.8.2), but found that parentalcontrolsd was running constantly with high CPU usage. The steps to correct the problem were found on the Apple Support Forums.

  1. Disable parental controls on all users.
  2. Delete the folder /Library/Application Support/Apple/ParentalControls
    Please note that this command is a little dangerous.[code lang=”sh” light=”true”]$ sudo rm -rf "/Library/Application Support/Apple/ParentalControls"[/code]
  3. Restart Mac.
  4. Enable parental controls again.

Installing git on Centos 6


sudo yum install git-core


<div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='like-post-wrapper-5074738-1598-58a316b989c34' data-src='//widgets.wp viagra en′ data-name=’like-post-frame-5074738-1598-58a316b989c34′>

Like this: