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 http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[/bash]

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
[/bash]

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()
1.4.5
>>>
[/python]

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 0.0.0.0 tells Django to accept external connections.
  2. Ensure the test port is open on the firewall.

[bash light=”true”]
$ cd /opt/foo
$ python manage.py runserver 0.0.0.0:8000
[/bash]

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
[/bash]

and fill the file with something like:

[python]
import os
import sys

sys.path.append(‘/opt/foo’)
sys.path.append(‘/opt/foo/foo’)

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

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

[/python]

Inside of the Apache virtual host:

[php]
<VirtualHost *:80>
ServerName foo.bar.com

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>

<Directory /opt/food/static>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
[/php]

Restart the Apache server.

Test to ensure that you can connect.

Credits

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.

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

The auto updater can then run:

[bash]
$ git pull
$ git submodule foreach git pull
[/bash]

Installing Django on CentOS 6

Django is available as an EPEL package.

First, activate EPEL via

[code lang=”bash”]
$ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[/code]

or for 32-bin CentOS,

[code lang=”bash”]
$ sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[/code]

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
[/code]

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()
1.4.5
>>> _
[/code]

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 ftp://ftp.gnu.org/gnu/wget/wget-1.15.tar.gz
tar xvzf wget-1.15.tar.gz
cd wget-1.15
./configure –with-ssl=openssl
make
sudo make install
[/code]

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

Trivial:


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 pastillas.com/likes/#blog_id=5074738&post_id=1598&origin=jamesreubenknowles.com&obj_id=5074738-1598-58a316b989c34′ data-name=’like-post-frame-5074738-1598-58a316b989c34′>

Like this: