26 Nov 2012 @ 8:28 AM 

How to setup Django on the server with CPanel control panel. CPanel uses Python 2.4, but Django requires PHP mod_wsgi, which requires Python 2.6+.
We need to install 2 Python versions.


cd /usr/local/src/
wget http://www.python.org/ftp/python/2.6/Python-2.6.tgz
tar -xvzf Python-2.6.tgz
./configure --enable-shared
make install
cd /etc/ld.so.conf.d
echo "/etc/ld.so.conf.d/opt-local.conf" > python26.conf
ldconfig

Now Now you’re ready to build mod_wsgi through easy_apache. Download custom_opt_mod-mod_wsgi.tar.gz from this ticket at google code and run:

tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-mod_wsgi.tar.gz

That unpacks the module into the right location so that easy_apache will find it and present it as a build option. Run easy_apache as usual (either via script or through WHM) and select the mod_wsgi option. When complete, you’ll find mod_wsgi.so along with all your other modules in /usr/local/apache/modules. The best part is, this will now become part of the default easy_apache build process, so Django sites won’t break when you rebuild apache+php in the future.

Now you are ready to install Django. Also you should to install setuptools and flup:

y| yum install python-setuptools

or alternative method

cd /usr/src/
wget http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg
sh setuptools-0.6c11-py2.4.egg

Flup installation:

easy_install flup

Also we need to copy setuptools into Python 2.6

scp -rp /usr/lib/python2.4/site-packages/setuptools* /usr/local/lib/python2.6/site-packages/

Django installation, beacuse we have 2 versions of Python, we need to install Django for Python 2.6 (but you can install for both of them):

cd /usr/src/
wget https://www.djangoproject.com/download/1.4.2/tarball/
tar xzvf Django-1.4.2.tar.gz
cd Django-1.4.2
/usr/bin/python2.4 setup.py install
/usr/local/bin/python2.6 setup.py install

The last step is MySQL-python module, CPanel will not allow you to install this module via yum, so we need to install it manually:

wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download
tar -xzvf MySQL-python-1.2.3.tar.gz
MySQL-python-1.2.3*
/usr/bin/python2.4 setup.py install
/usr/local/bin/python2.6 setup.py install

The last step is configuration of client-side virtual host:
Now you need to create a file /usr/local/apache/conf/userdata/std/2/USERNAME/DOMAIN_NAME/vhost_mods.conf
and add to the file

WSGIScriptAlias / /home/USERNAME/public_html/index.wsgi
Alias /static/admin/ /usr/local/lib/python2.6/site-packages/django/contrib/admin/static/admin/

Uncomment (or add) in Virtualhost of your domain

Include "/usr/local/apache/conf/userdata/std/2/USERNAME/DOMAIN_NAME/*.conf"

P.S. Don’t forget to replace USERNAME and DOMAIN_NAME on your client’s username and domain name.

Restart apache:

/etc/init.d/httpd restart

Thats all, if some download links are not working – you can download packages from our site:

Django-1.4.2
MySQL-python-1.2.3
Python-2.6
mod_wsgi
setuptools

Posted By: lvlind
Last Edit: 06 Oct 2016 @ 03:54 PM

EmailPermalink
Tags
Tags: , ,
Categories: Uncategorized


 

Responses to this post » (None)

 

Sorry, but comments are closed. Check out another post and speak up!

Tags
Comment Meta:
RSS Feed for comments

 Last 50 Posts
Change Theme...
  • Users » 1
  • Posts/Pages » 35
  • Comments » 0
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Need Help?



    No Child Pages.

Check your IP



    No Child Pages.