Django on a shared host

51 views
Skip to first unread message

Snoop1990

unread,
Feb 27, 2008, 11:07:22 AM2/27/08
to Django users
Hey,
I am new to django (coming from ruby on rails) and I want to setup a
django application on a free webhost. I have ssh access and executed
the install scriped. But I am not allowed to write in the /usr/
folder, is there any way to install django without writing in the /
usr/ folder ?

Here is the Error :

creating /usr/lib/python2.3/site-packages/django
error: could not create '/usr/lib/python2.3/site-packages/django':
Permission denied

Please help, regrades Snoop1990

Jeff Anderson

unread,
Feb 27, 2008, 11:10:04 AM2/27/08
to django...@googlegroups.com
Hello,

simply put the django directory somewhere that is writable, and set your
pythonpath accordingly.
You could create a ~/python directory to hold django and any other
module you might need.
just prepend th ~/python directory to your python path so it looks there
first.

Jeff Anderson

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com
> To unsubscribe from this group, send email to django-users...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>


signature.asc

Alexey Moskvin

unread,
Feb 27, 2008, 1:18:13 PM2/27/08
to Django users

Matthew Miller

unread,
Feb 27, 2008, 1:24:29 PM2/27/08
to django...@googlegroups.com
Just make sure that the package you are trying to use i.e. django-photologue is in your python path.



2008/2/27 Alexey Moskvin <d...@inbox.ru>:

Tim Chase

unread,
Feb 27, 2008, 11:15:39 AM2/27/08
to django...@googlegroups.com
> I am new to django (coming from ruby on rails) and I want to setup a
> django application on a free webhost.

A free webhost that allows Django? Even if it's fairly limited,
this is interesting. Can you tell more?

> I have ssh access and executed
> the install scriped. But I am not allowed to write in the /usr/
> folder, is there any way to install django without writing in the /
> usr/ folder ?
>
> Here is the Error :
>
> creating /usr/lib/python2.3/site-packages/django
> error: could not create '/usr/lib/python2.3/site-packages/django':
> Permission denied

Django doesn't need to be installed...it merely needs to be in
your $PYTHONPATH environment. Thus, you can simply copy the
Django files (or do a Django checkout from the SVN repo) into
some place in your home directory, and then configure your
deployment to include that directory in your $PYTHONPATH. You
omit the details of what your server is (Apache? lighttpd?) so
the particulars of this vary. However, the basic gist would be
to do something like

cd ~
tar xvfz django-0.96.tgz

and then include /home/snoop/django-0.96 in your $PYTHONPATH

or, if you want the development head and subversion is installed
on your host (if so, I'm *really* interested in this free host):

cd ~
svn co http://code.djangoproject.com/svn/django/trunk/
django-trunk

and include /home/snoop/django-trunk in your $PYTHONPATH.

-tim

Ariel Mauricio Nunez Gomez

unread,
Feb 29, 2008, 10:34:19 AM2/29/08
to django...@googlegroups.com
There is a french web hosting alwaysdata.com
that offers free acounts with ssh access. Their support people is _very_ helpful and kind.

It was on the wiki before, but I can't seem to find it anymore.

Ariel

Amit Ramon

unread,
Mar 4, 2008, 1:15:17 AM3/4/08
to django...@googlegroups.com
I'm aware I'm a bit late :-), but here is a link to detailed instructions for setting up django on a shared host (site5 in this case):
http://forums.site5.com/showthread.php?t=10236


--- Amit


* Snoop1990 <snoo...@gmx.net> [2008-02-27 08:07 -0800]:

Snoop1990

unread,
Mar 9, 2008, 3:58:36 PM3/9/08
to Django users
My Host is profusehost.net I am not sure if they support django, but
they have python so I thought it might work. I am new to django !

Snoop1990

unread,
Mar 10, 2008, 10:48:56 AM3/10/08
to Django users
Ok, I tested your tips and always came to the same point. I do not
have a .bash_profile file ! Is there any way to do it without ? I
think the shell on the profusehost.net servers look all the same. Any
way without the path initialization ? I really want to try django !

Regrades Snoop1990

Evert Rol

unread,
Mar 10, 2008, 2:41:07 PM3/10/08
to django...@googlegroups.com

Guessing the problem (which is darn hard without the relevant
information copied in the email...), here are some options:

- Create a .bash_profile yourself
- Or otherwise, try a .bashrc (is your shell bash anyway?)
- Set the PYTHONPATH in front of your script, eg "PYTHONPATH=<path>
python manage.py runserver" or similar
- Hardcode the PYTHONPATH in your script, using sys.path.append(<path>)


Also, have a look at this possibly related thread: http://groups.google.com/group/django-users/browse_thread/thread/d77412f3bbbd1d1a/96eaf99878545253?hl=en&lnk=gst&q=cron#96eaf99878545253

Snoop1990

unread,
Mar 10, 2008, 4:53:59 PM3/10/08
to Django users
I talked to the support team and finally they gave me
my .bash_profile :D

profusehost.net the best free hosting service I have ever seen !
really try them, go to the official support and request, ssh and
your .bash_profile and you are ready to run django for nothing. (Ok it
is a bit time intensive but for those who want to try, no adds
nothing !) 200 MB for free and if you want more, you get more for
either placing a ad or 30 posts with 50 words a month (also a very
fair option I think) But this is no advertising try it yourself, for
me they are the best.

Regrades Snoop1990

cmcco...@gmail.com

unread,
Mar 10, 2008, 5:05:41 PM3/10/08
to Django users
eh, i applied last week to be a mediatemple beta tester. i've had mt
for quite a while and i'm looking to make the switch from my half-
assed PHP to django. i'm wanting to stay on mt, but if i don't hear
soon i'll probably switch to webfraction.

has anyone been able to get django on mt?

Snoop1990

unread,
Mar 11, 2008, 12:43:16 PM3/11/08
to Django users
Ok thank you all for your help, but it is still not working ! I
created a project following the tutorial at
http://jeffcroft.com/blog/2006/may/11/django-dreamhost/ but I can not
get it working. So where are the logs to see my faults ?

I run on apache with python activated (when I create a .cgi file I can
use python, but I can not execute .py files in the public_html
folder). My question simply is how to start the application ? (my
django_project is not located in my public_html folder for security
reasons). I the tutorial said something about a .fcgi file to use and
I tried it, but it does not work.

You see my application at http://django.snoop1990.uni.cc/ it ends up
saying something about the server is busy but I just think it is an
endless request ! I do not why but there is no response.

I would be very happy if any body can help me !



--------------------------------Update --------------------
The fcgi.py file is working via ssh the only thing not working is the
connection between the .fcgi file and the .py file

The dispatch.fcgi looks like this:

#!/usr/bin/env python
import sys
sys.path += ['/home/sn00p/django/django_src']
sys.path += ['/home/sn00p/django/django_projects']
from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'blog.settings'
WSGIServer(WSGIHandler()).run()



/home/sn00p/ is my home directory !
and "blog" is my project name !

Snoop1990

unread,
Mar 11, 2008, 1:35:51 PM3/11/08
to Django users
I figured it all out ! Thanks for support all of you !

papertrail

unread,
Apr 6, 2008, 3:10:24 PM4/6/08
to Django users
I just sent a reply, but I guess I don't know how to use Google groups
so well (sorry). I think it went directly to the author instead of
posting here. Basically I don't understand Tim's answer and could it
be explained a bit more?

Thanks.
> svn cohttp://code.djangoproject.com/svn/django/trunk/

Tim Chase

unread,
Apr 6, 2008, 3:53:26 PM4/6/08
to django...@googlegroups.com
> I just sent a reply, but I guess I don't know how to use Google groups
> so well (sorry). I think it went directly to the author instead of
> posting here.

Yes indeed, it did go directly to me :)

> Basically I don't understand Tim's answer and could it
> be explained a bit more?

I'll see what I can do. For the others on the list, I also got
the following via direct email:

> Hi, I am a complete moron. Will you translate this into English? ;)
>
> What do you mean by $PYTHONPATH and how do you "include" something?

PYTHONPATH is an optional environment variable that instructs
Python where to look for modules to load. If it's not set,
Python uses a select few places that can be shown by issuing

bash$ python
[copyright info]
>>> import sys
>>> sys.path
[output of all the places Python looks for modules that can be
"import"ed]

You can set your PYTHONPATH first:

bash$ export PYTHONPATH=/path/to/someplace/not/in/sys.path/
bash$ python
[copyright info]
>>> import sys
>>> sys.path
[output of all the places Python looks for modules that can be
"import"ed which should now include "/path/to/..." which I
believe falls at the beginning of the list]

Django is just a Python module (or group of modules), so the
"installation" just involves putting the contents someplace in
the sys.path. If you run the default install as an admin,
Django's files get dropped in the system-wide Python module
repository. For me here, that's likely
/usr/lib/python2.4/site-packages/ but may vary depending on your
setup/OS.

If you're not the administrator (or, like me, you want to install
various versions of Django and flip between them), you can just
so something like the following, choosing case #1 or #2 depending
on what tools you have access to:

bash$ cd ~/code
1 bash$ # if you have subversion installed:
1 bash$ svn co http://code.djangoproject.com/svn/django/trunk/ django
2 bash$ # if you don't have subversion installed, but have a .tgz
2 bash$ # snapshot of Django
2 bash$ tar xvfz django.tgz
bash$ export PYTHONPATH=~/code/django
bash$ python
[copyright info]
>>> import django
[if all went well, no traceback here]

The secondary problem is that PYTHONPATH needs to be set every
time a new environment is launched. In the above example, that
means that if you log out and log back in again, you have to set
PYTHONPATH again. For interactive work, you can set PYTHONPATH
in your .bashrc/.profile startup file so it gets set every time
you log in.

However, in a mod_python (and likely mod_wsgi, fastcgi, or
lighttpd setup) you need to use the config-option du-jour to tell
your hosting where to find Django and where to find your project:

http://www.djangoproject.com/documentation/modpython/

Thus, you might need your apache config to have a line like

PythonPath ['/home/snoop/code/django',
'/home/snoop/code/myproj'] + sys.path

so that mod_python can find both Django's source/modules, and
your own code in your ~/code/myproj directory.

> So I went to run the installation again to keep a keen eye on what was
> happening, but THIS time it's saying "permission denied" (that didn't
> happen before).

I'm guessing that since you're a non-root user, you don't have
rights to put Django's modules in the site-wide directory.

> Searching the net for an answer, this one is the closest that
> resembles my issue. But I do not understand your answer.

So you need to instruct the setup to install some place that you
*can* write (I don't know exactly how to do this, but I'm sure
one of the many other smart folks on the list will leap in here
with the right option to pass to setup.py) which would be
something like

python setup.py --base=/home/snoop/code/django install

or, as above, you can install the development version either from
Subversion or, if you have SVN on another machine, you can check
it out there and then push a tar-ball down to the server,
un-tar/gzipping there.

This still all assumes that your webhost has support for running
Django (either mod_python, mod_wsgi, or some other supported
non-CGI variant)


> Thanks.

Hope this helps. For the list archive purposes, I've included my
original email that papertrail included.

-tim

papertrail

unread,
Apr 7, 2008, 4:07:44 PM4/7/08
to Django users
Hi,

Thank you very much for your quick reply. I got it pretty much right
after you wrote it yesterday... I figured I'd get it working first,
then reply with my results for everyone's benefit. :) Alas, it really
took all day yesterday, a good night's rest and then getting a fresh
start with a fresh mind this morning.

And I got it working. What I did after many false starts, syntax
errors and 1+hr of phone time with my linux host, (1&1 if it helps
anyone):

First, my sources:
a. djangobooks.com (chapter2),
b. djangoproject.com/documentation/install
c. this thread, and
d. the Site5 thread

-- I first wiped out everything to start over as per djangoproject.com
-- Installed virtual-python as per Site5. That created my own locally
accessed /bin and /lib files (containing python [use "~/bin/python" to
get to >>>] and a /site-packages file).
-- Downloaded then installed Django tar.gz*
-- Performed import commands. It worked!*
-- Finally figured out what everyone means by setting a path: The goal
is to take the Django path (/yoursite/Django-0.96/django/bin/django-
admin.py) and drop a kind of "bookmark" to it into /lib/python2.4/site-
packages. Why? Because ~/bin/python uses /lib/python2.4 where /site-
packages resides. Site-packages has a list of paths (the "bookmarks")
it will look for stuff you're working with. By dropping a path to your
Django-0.96 file into the /lib's site-packages, you're telling it
where to look for your Django. THAT is what you are doing. So after
you put the path in there, that's all you do for that.
-- Lastly, I created a directory called "projects". I "cd" into that
and ran command: "django-admin.py startproject mysite" and it created
the /mysite file under /projects. And all the files were there as
predicted in djangobooks.

*Trial and error in case others have the same problems:
-- "sudo" doesn't work for me. I just omitted it from the command
lines.
-- ln -s commands get me "permission denied" even within my own
folders. My host did one for me, but it took 40 minutes.
-- I don't think $'s worked in anything I used.
-- This didn't work:
>>>import django
>>>import.VERSION (in any form)

I had to:

>>>import django
>>>django

-- and I think there may have been a couple of other examples where
the recommended syntax didn't work as written for my particular
instance.

There were quite a few irksome snags that I ran into yesterday that
made it difficult to understand what was happening. It was like being
in a 1/4mile maze for the first time and not recognizing a correct
turn while on the 8th mile of going the wrong way. But now that I'm
through, I see the solution thanks to the patience and generous help
of people who take the time to write answers for confused people. :)

Thanks!!!!! I can't wait to now dive in and see what django is all
about. :)
> Djangois just a Python module (or group of modules), so the
> "installation" just involves putting the contents someplace in
> the sys.path. If you run the default install as an admin,Django'sfiles get dropped in the system-wide Python module
> repository. For me here, that's likely
> /usr/lib/python2.4/site-packages/ but may vary depending on your
> setup/OS.
>
> If you're not the administrator (or, like me, you want to install
> various versions ofDjangoand flip between them), you can just
> so something like the following, choosing case #1 or #2 depending
> on what tools you have access to:
>
> bash$ cd ~/code
> 1 bash$ # if you have subversion installed:
> 1 bash$ svn cohttp://code.djangoproject.com/svn/django/trunk/django
> 2 bash$ # if you don't have subversion installed, but have a .tgz
> 2 bash$ # snapshot ofDjango
> 2 bash$ tar xvfzdjango.tgz
> bash$ export PYTHONPATH=~/code/django
> bash$ python
> [copyright info]
> >>>importdjango
> [if all went well, no traceback here]
>
> The secondary problem is that PYTHONPATH needs to be set every
> time a new environment is launched. In the above example, that
> means that if you log out and log back in again, you have to set
> PYTHONPATH again. For interactive work, you can set PYTHONPATH
> in your .bashrc/.profile startup file so it gets set every time
> you log in.
>
> However, in a mod_python (and likely mod_wsgi, fastcgi, or
> lighttpd setup) you need to use the config-option du-jour to tell
> your hosting where to findDjangoand where to find your project:
>
> http://www.djangoproject.com/documentation/modpython/
>
> Thus, you might need your apache config to have a line like
>
> PythonPath ['/home/snoop/code/django',
> '/home/snoop/code/myproj'] + sys.path
>
> so that mod_python can find bothDjango'ssource/modules, and
> your own code in your ~/code/myproj directory.
>
> > So I went to run the installation again to keep a keen eye on what was
> > happening, but THIS time it's saying "permission denied" (that didn't
> > happen before).
>
> I'm guessing that since you're a non-root user, you don't have
> rights to putDjango'smodules in the site-wide directory.
>
> > Searching the net for an answer, this one is the closest that
> > resembles my issue. But I do not understand your answer.
>
> So you need to instruct the setup to install some place that you
> *can* write (I don't know exactly how to do this, but I'm sure
> one of the many other smart folks on the list will leap in here
> with the right option to pass to setup.py) which would be
> something like
>
> python setup.py --base=/home/snoop/code/djangoinstall
>
> or, as above, you can install the development version either from
> Subversion or, if you have SVN on another machine, you can check
> it out there and then push a tar-ball down to the server,
> un-tar/gzipping there.
>
> This still all assumes that your webhost has support for runningDjango(either mod_python, mod_wsgi, or some other supported
> non-CGI variant)
>
> > Thanks.
>
> Hope this helps. For the list archive purposes, I've included my
> original email that papertrail included.
>
> -tim
>
> > On Feb 27, 9:15 am, Tim Chase <django.us...@tim.thechases.com> wrote:
> >>> I am new todjango(coming from ruby on rails) and I want to setup a
> >>>djangoapplication on a free webhost.
> >> A free webhost that allowsDjango? Even if it's fairly limited,
> >> this is interesting. Can you tell more?
>
> >>> I have ssh access and executed
> >>> the install scriped. But I am not allowed to write in the /usr/
> >>> folder, is there any way to installdjangowithout writing in the /
> >>> usr/ folder ?
> >>> Here is the Error :
> >>> creating /usr/lib/python2.3/site-packages/django
> >>> error: could not create '/usr/lib/python2.3/site-packages/django':
> >>> Permissiondenied
> >>Djangodoesn't need to be installed...it merely needs to be in
> >> your $PYTHONPATH environment. Thus, you can simply copy the
> >>Djangofiles (or do aDjangocheckout from the SVN repo) into
Reply all
Reply to author
Forward
0 new messages