Also: installing postgres w/o root Re: django-admin.py --> permission denied (shared server deployment)

39 views
Skip to first unread message

Andrew Farrell

unread,
May 19, 2015, 4:57:08 PM5/19/15
to django...@googlegroups.com
Hi Florian

It occurs to me that, you may want to install postgresql, a more powerful database. Here is how to do so without root permissions:

conda install --channel https://conda.binstar.org/bkreider postgresql psycopg2
which psql
createuser -s test_user1 --pwprompt --createdb --no-superuser --no-createrole
createdb -U test_user1 --locale=en_US.utf-8 -E utf-8 -O test_user1 test_database1 -T template0

This will install both postgres and the python-postgres adapter into the isolated environment. It will then create a postgres user and ask you for a password. I'll assume you gave it the password "testpass" for the purpose of this tutorial. Then, it will create a database owned by that user and using UTF-8 encoding.

Now, we just need to configure django use this. Open settings.py and at line 77, change the DATABASES variable to look like 

DATABASES = {
    'default': {
      'ENGINE': 'django.db.backends.postgresql_psycopg2',
      'NAME': 'test_database1',
      'USER': 'test_user1',
      'PASSWORD': 'testpass',
      'HOST': 'localhost',
      'PORT': '5432',
    }
}

Then you can set up your tables with

python manage.py migrate 

You can also log in to the database with

python manage.py dbshell

On Tue, May 19, 2015 at 11:50 AM, Andrew Farrell <armors...@gmail.com> wrote:
Hello Florian,

If you are having trouble installing python without root permissions, you should consider installing the miniconda distribution of python that is used in the scientific computing community. Assuming you are on a linux server, you can do this with

chmod +x ./Miniconda-latest-Linux-x86_64.sh
./Miniconda-latest-Linux-x86_64.sh -b
conda update conda
conda create --name try_django django
source activate try_django

This will set you up with an isolated conda environment (similar to a virtualenv environment) where you can install packages without touching anyone else's packages. From there you can do

django-admin.py startproject test_project
cd test_project
python manage.py migrate
python manage.py runserver 0.0.0.0:8000

And to get yourself set up with the django dev server running on top of sqlite.
You can see the documentation for conda here.

On Tue, May 19, 2015 at 3:04 AM, x <ung...@zetteeh.net> wrote:
hello hello,

finally i was able to install a python instance on my shared-server.
it was also impossible to pip-install django. yeah.

but right then - so close already - i got a permission problem again.
i couldn't figure out exactly what django-admin.py wants to do/execute and why it's
not satisfied with my nice brand new local python 2.7.9 instance.. muhhuuu.

this is the ssh prompt:

> (uiserver):u74138225:~/django_build >  django-admin.py startproject test --user-
> bash: /customers/homepages/45/d5012545412/htdocs/python27/bin/django-admin.py: Permission denied

for any suggestions how to domesticate django on this shared server i'd be very happy.

thanks and all the best
florian

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/D96C8E64-18CA-4E2A-B9BD-D384AD563766%40zetteeh.net.
For more options, visit https://groups.google.com/d/optout.


Reply all
Reply to author
Forward
0 new messages