Thursday, May 26, 2016

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


On May 26, 2016 20:12, "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.

Yes you can, and yes, you will. I usually start prod with an empn]ty DB, I consider that safer.

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

See my previous answer. If your dev data is production-ready, I don't see the downside though.

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

If you use virtualenv, you should use pip install. I suggest creating a requirements.txt file (you can create one with pip freeze) and update it regularly.

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

See previous answer.

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

PHP has its package system, too, it is called composer. It also has binary modules (although they require much more effort on the server side)

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

Take a look at the collectstatic management command. Also, if you use django-compress, e.g. for less,sass, css/js minimizing), you need to run that.

>
> Thanks in advance for any help,
> Bruce  

Also, you may want to check this page[1] for other possible caveats and best practises.

[1] https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

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

--
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/CACczBULd2mqRCuY72euyZR0xiUCT2wWNKWBYF78qLsWP7KbFww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment