Django a Turnkey Linux -- I need your experience.

274 views
Skip to first unread message

Petr Přikryl

unread,
Dec 14, 2011, 4:15:16 AM12/14/11
to django-users
Hi,

 

Being quite new to Django, I need to move the semi-ready

application to the publicly available server (for a company users)

and test it there.

 

It happened that the Django Turnkey Linux virtual machine

was installed for the purpose by someone else. I have succeeded

to SCP the files there. I can run the console for the root account.

 

I was able to run the manage.py syncdb and it seems that it

created the wanted application tables in the MySQL preinstalled

database. So far, so good.

 

I have added my application to the settings.py and to the urls.py.

 

Now I need the equivalent of the restart of the previously

used development server (manage.py runserver). I have found

something about "touch .wsgi", but I am not sure if it holds also

for the Django Turnkey Linux installation.

 

How can I do that without the need to restart the virtual machine?

Can you help me here?

 

Thanks,

Petr  

Brett Epps

unread,
Dec 14, 2011, 4:58:11 PM12/14/11
to django...@googlegroups.com
You'll need to do some research to find out how Turnkey Linux deploys your Django app.  There are multiple methods, but the one recommended in the Django docs is to use Apache + mod_wsgi.  If Turnkey Linux uses this method, Apache should be configured with a virtual host that points at a WSGI file that handles running your application.  Check out the Django documentation for more detailed info on how this is set up.

It sounds like you already have the app up and running, and you just want to be able to reload the app.  The best method is to run the touch command on the WSGI file.  So, in your terminal on the Turnkey Linux server:

$ touch /path/to/wsgi/file.wsgi

Will cause the app to be reloaded.  If that doesn't work for some reason, you could also restart Apache.  You'll have to research how to do that for Turnkey Linux; usually you use a command like "sudo /etc/init.d/apache2 restart" or "sudo service httpd restart".

Hope this helps,

Brett

--
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.

Nick Raptis

unread,
Dec 14, 2011, 8:49:54 PM12/14/11
to django...@googlegroups.com
Hello Petr.
While certainly not a full fledged django user, I do have taken the
Turnkey Linux approach myself, and frankly, I love it.
Hope I can give you some helpful pointers. They are pretty generic
though I'm afraid and perhaps not addressing your specific problem. If
so, please share more.

- Turnkey is basically a LAMP stack with mod_wsgi on top of Ubuntu. Just
sharing that information will attract plenty more answers from people
who may not be familiar with Turnkey per se, but have similar stacks.
Heading over to turnkey forums will get you great help too.
- The quick and dirty way to install a django app in Turnkey is to
overwrite the sample 'project' folder in /var/www (or over any other
working project there). Do keep the wsgi_handler.py from the original
though, and paste it back in.
- Just copying your data over to a folder in /var/www won't cut it. You
will need to configure.
1. First make a wsgi configuration file. The wsgi_handler in the sample
project is a great start. This can have any name is what you may hear
called .wsgi elsewhere and this is the file you touch to restart the
project.
2. If going this route, you'll also need to make apache aware of your
new project. See what's already up there in the apache configuration for
the default project in terms of virtual hosts and copy/modify as needed.
A couple of apache shell commands make that easier too, but can't really
remember the specifics. Generic tips and documentation will help there.
After all's done restart apache.

PS: I think I may have confused your meaning of 'application' in your
post and you're only adding to a working project. But since I wrote all
the above I'm leaving it there in case it helps someone else. In that
case, just look at point 1. , in turnkey the .wsgi is named
wsgi_handler.py. Also scan it to see if it needs any changes (it may
happen that sys.path manipulations happen there that you need to take
into account)

Hope that my response doesn't sound all shitty to the more seasoned devs
out there, and I hope it helped even just a bit,
Nick

Petr Přikryl

unread,
Dec 15, 2011, 10:47:51 AM12/15/11
to django...@googlegroups.com
Thanks, Brett,

 

"Brett Epps" wrote...

> You'll need to do some research to find out how Turnkey Linux

> deploys your Django app.  There are multiple methods, but
> the one recommended in the Django docs is to use Apache + mod_wsgi.
> If Turnkey Linux uses this method, Apache should be configured with
> a virtual host that points at a WSGI file that handles running your
> application.  Check out the Django documentation for more detailed
> info on how this is set up.
Yes, it uses apache2 and mod_wsgi.  In the meantime, I have found
that the last Django Turnkey Linux uses quite obsolete Django (ver. 1.1.1)
which is a bit unfortunate.
I am not that fluent with Linux, so I did hope that using the Django TurnKey
Linux will be a nice shortcut.  It seems to me now, that 
I will check the documentation.
> [...] The best method is to run the touch command on the WSGI file...
> $ touch /path/to/wsgi/file.wsgi
The problem is that I did not find any *.wsgi file.  Or I am searching
wrongly, or it is not there.
> Will cause the app to be reloaded.  If that doesn't work for some reason,
> you could also restart Apache.  You'll have to research how to do that
> for Turnkey Linux; usually you use a command like
> "sudo /etc/init.d/apache2 restart" or "sudo service httpd restart".
I did restart the whole virtual machine, which is not a problem
in this phase of the development.  The things did not work.
This can possibly be caused by the old Django version.
Thanks for the help,
   Petr
P.S. Do you prefer some specific combination of a Linux distribution,
Django and Python versions, the specific SQL server... for a vmware
box? (I have to start somewhere.)

Petr Přikryl

unread,
Dec 15, 2011, 10:55:59 AM12/15/11
to django...@googlegroups.com

Thanks Nick,
 
By the 'application' I mean another part of the Django installation/project
that does some specific function. Thanks for telling me that
the wsgi_handler.py is the ".wsgi" file that I was searching for ;)
 
Do you have any experience with updating the version of Django?
 
Petr

Nick Raptis

unread,
Dec 15, 2011, 11:12:40 AM12/15/11
to django...@googlegroups.com
Yes, I did once, by installing the newest django in a virtualenv along
with my project. Search for "apache mod_wsgi virtualenv" for relevant
information. Not that hard to do.
By I guess you could also get up-to-date ubuntu packages for django from
a ppa in launchpad, but it's not something I have done.

Nick

Brett Epps

unread,
Dec 15, 2011, 11:46:10 AM12/15/11
to django...@googlegroups.com
I prefer Ubuntu Server, but your choice of distro isn't that important as long as it is new-ish.  You'll want to use Python 2.7 if possible.  You should also use Django 1.3.1 (the latest release).  I'd highly recommend learning how to use pip and virtualenv for installing Python packages and managing dependencies.  Virtualenv gives you a virtual Python environment that is insulated from the system Python, which is nice in cases where the system Python environment includes old packages or ones you don't need.  For a database server, I prefer Postgres.  Django should still work well if you choose the SQLite or MySQL routes though.

Brett

From: Petr Přikryl <pri...@atlas.cz>
Reply-To: <django...@googlegroups.com>
--

Petr Přikryl

unread,
Dec 15, 2011, 5:21:10 PM12/15/11
to django...@googlegroups.com

Thanks Brett for the info.

 
> I prefer Ubuntu Server, but your choice of distro isn't that important
> as long as it is new-ish.  
 
If I understand it well, then TurnKey Linux 11.3 is actually based
on Ubuntu 10.04... plus the selected neccessary packages for
the chosen purpose.

> You'll want to use Python 2.7 if possible.  
> You should also use Django 1.3.1 (the latest release).  
 

This is what I was thinking about.  So, I have to learn how to
update...


 
> I'd highly recommend learning how to use pip and virtualenv
> for installing Python packages and managing dependencies.  
> Virtualenv gives you a virtual Python environment that is insulated
> from the system Python, which is nice in cases where
> the system Python environment includes old packages
> or ones you don't need.  
 

... and this is very valuable info for me. And it also fits with
Nick's recommendations.


 
> For a database server, I prefer Postgres.  
> Django should still work well if you choose
> the SQLite or MySQL routes though.

So far, I did use the SQLite for Django locally, but only
the way that is almost completely managed by Django.
The Django TurnKey Linux uses MySQL. 
I am aware of Postgres as probably one of the most
matured SQL engines for free.
 
Thanks and have a good time,
    Petr
 

Reply all
Reply to author
Forward
0 new messages