Sunday, June 26, 2016

Re: Questions about Deploying django for production using apache and mod_wsgi.

On May 26, 2016, at 12:12 PM, Bruce Whealton <futurewavewebdevelopment@gmail.com> wrote:

Hello all,
        I have a few questions of which I am not finding answers.
1) If I export my development db (Postgresql) and then import it into production database,
won't I be pulling in a very weak password that I used for development?  I guess I can
just change that.

Don't do that.

2) Should I export all the content and structure from my development server to my
production server?  Or should I just create the database connection and then run migrations and
then create the data content on the production server?  Obviously, my development server has
minimal content.

Run the migrations and add the data.  There should be completely different data on the Production server as the dev server.

3) Should I just upload the other packages that I installed with pip on my development server or
should I instead run pip install on the production server to get all the packages needed on the
production server?  

Pip, pip, forever pip

4) Is it a best practice ( continuing from #3) to create a requirement file and use that to install
with pip all the packages, as opposed to uploading the packages from development to production?  
Note: I am developing on Ubuntu but deploying to Centos.  

Yes.  That way you can make changes to your install and just do `pip install -U -r requirements.txt` when there's a bug fix to one of your things.

5) I suppose, even if I had a Centos development environment, I would still want to install the required
packages on the production server instead of just uploading everything.

Pip doesn't use your distro.  It downloads from https://pypi.python.org/pypi

Regarding #5, I am liking Python better than what I have used for some time, PHP based application
development.  However, for the longest time, things were much simpler with php in that most php code is
just text and so there isn't the notion of "installing" a package.  One could expect things to work fine
if one just uploaded the site from development to production (perhaps certain new OO features are changing
this situation for php sites, e.g. the use of autoloaders but that's another topic).

First of all, that's not quite true.  For many PHP features you have to install a package from your Linux distro.  Or figure out how to compile PHP yourself.  Of course, many people just install all of the things, so that even if you don't use a feature, it's still a part of your monolithic PHP install.  This has been the case for over a decade.

6) Is there anything else, in addition to the top level assets (with js/css) that I would want apache to serve directly
versus going through mod_wsgi?  It seems like I read something to this effect relating to parts of the admin, 
that need to be served directly by apache.  I could be wrong.  

Anything that doesn't change.  That includes images too.  The admin has it's own CSS, JS, etc. that should be served by Apache.

Thanks in advance for any help,
Bruce  

P.S. If anyone wants to develop a course on udemy.com on a python framework, please don't develop with
sqlite3 since we won't use that in production and please discuss deployment on a server besides 
something like pythonanywhere.com.  The issues of setting things up on one's own vps server are not 
trivial at all.  (smile).

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/50b71c19-10a1-4610-8050-191bde7facda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter of the Norse



No comments:

Post a Comment