How do I initialise my Satchmo website? - python

As an experienced PHP programmer I tend to avoid things like Python. However we all must play with the cards we have been dealt with and I now have to work with a Satchmo website.
I have very little python, django and satchmo so I need some help. I'm ok with setting up a development server but I cannot get my website to work on a production server.
I've seen the use of "python manage.py runserver", this solution is even on Stack Overflow. However, when I see this solution there is usually someone saying "I hope you're not using that on production" so I assume this is a very incorrect way to do it. To my frustration the people that seem to know that this command line is insecure, also have no desire to share with the rest of us, just how excatly does one initiate their Satchmo Production server?
Many thanks.

To deploy a Django website on a production server, you have to serve it either with Apache+mod_wsgi, nginx+gunicorn, nginx+uwsgi, or any other server supporting WSGI. The Django documentation has a page on deploying Django on Apache with mod_wsgi, for the other solutions, there are plenty of useful documentation around the web.

runserver is just for development/testing. It won't handle high load, security, etc.
Python.org has docs on how to set up a proper webserver to serve Python code:
http://docs.python.org/howto/webservers.html

Satchmo seems like a django derivative. Setting up django on production is quite easy if your deployment environment is linux with apache then use mod_wsgi which is well documented here if its windows then you can use the pyisapie module and follow the documentation here
Hope that helps

Related

How to distribute Django web app to users?

I am developing a Django app to run on every client computer separately. The question is, which technologies should I use to distribute such as docker, virtual machine etc.? How can I protect the Django app's code? How can I prevent to distribute without licenses?
I suggest you look into Heroku. They have a free plan too so you can test it without having to pay first. Their guide with django after you set up an app is good too. You will find everything in their documentation but if you get stuck, I recommend this video by Corey Schafer. Good luck
Edit: Heroku also supports Docker but I'm not too familiar with it. Might be useful to you

Python development: Server Handling

This might be a very dumb question, so please bear with me (there's also no code included either).
Recently, I switched from PHP to Python and fell in love with Django. Locally, everything works well.
However, how are these files accessed when on a real server?
Is the manage.py runserver supposed to be used in a server environment?
Do I need to use mod_python ?
Coming from PHP, one would simply use Apache or Nginx but how does the deployment work with Python/Django?
This is all very confusing to me, admittedly. Any help is more than welcome.
manage.py runserver is only used to speed your development process, it shouldn't be run on your server. It's similar to the newly introduced php's built-in server php -S host:port.
Since you're coming from PHP you can use apache with mod_wsgi in order to serve your django application, there are a lot of tutorials online on how to configure it properly. You might want to read what wsgi is and why it's important.

Python Web Server - mod_wsgi

I have been looking at setting up a web server to use Python and I have installed Apache 2.2.22 on Debian 7 Wheezy with mod_wsgi. I have gotten the initial page up and going and the Apache will display the contents of the wsgi file that I have in my directory.
However, I have been researching on how to deploy a Python application and I have to admin, I find some of it a little confusing. I am coming from a background in PHP where it is literally install what you need and you are up and running and PHP is processing the way it should be.
Is this the same with Python? I can't seem to get anything to process outside of the wsgi file that I have setup. I can't import anything from other files without the server throwing a "500" error. I have looked on Google and Bing to try to find an answer to this, but I can't seem to find anything, or don't know that what I have been looking at is the answer.
I really appreciate any help that you guys can offer.
Thanks in advance! (If I need to post any coding, I can do that, I just don't know what you guys would need, if anything, as far as coding examples for this...)
Python is different from PHP in that PHP executes your entire program separately for each hit to your website, whereas Python runs "worker processes" that stay resident in memory.
You need some sort of web framework to do this work for you (you could write your own, but using someone else's framework makes it much easier). Flask is an example of a light one; Django is an example of a very heavy one. Pick one and follow that framework's instructions, or look for tutorials for that framework. Since the frameworks differ, most practical documentation on handling web services with Python are focused around a framework instead of just around the language itself.
Nearly any python web framework will have a development server that you can run locally, so you don't need to worry about deploying yet. When you are ready to deploy, Apache will work, although it's usually easier and better to use Gunicorn or another python-specific webserver, and then if you need more webserver functionality, set up nginx or Apache as a reverse proxy. Apache is a very heavy application to use for nothing but wsgi functionality. You also have the option of deploying to a PaaS service like Heroku (free for development work, costs money for production applications) which will handle a lot of sysadmin work for you.
As an aside, if you're not using virtualenv to set up your Python environment, you should look into it. It will make it much easier to keep track of what you have installed, to install new packages, and to isolate an environment so you can work on multiple projects on the same computer.

How to develop a simple web application with server-side Python

I am wondering how to go about implementing a web application with Python.
For example, the html pages would link to python code that would give it increased functionality and allow it to write to a database.
Kind of like how Reddit does it.
If you're looking for server side programming with databases and html templates etc, I think Django is great, along with Pyramid. However, I use Flask ( http://flask.pocoo.org/ ) for this since it is easy to use, learn and deploy even though it may not have as much support as the before mentioned 2 framework since it's just a microframework, using the Jinja2 templating engine, including a development test server with it's own debugger.
On the other hand, if you're going for client-side programming (i.e. in browser implementation ) You can look up .NET Ironpython or even Brython which uses python like javascript.
You might want to check out mod_wsgi or mod_python.
What Is mod_wsgi?
The aim of mod_wsgi is to implement a simple to use
Apache module which can host any Python application which supports the
Python WSGI interface. The module would be suitable for use in hosting
high performance production web sites, as well as your average self
managed personal sites running on web hosting services.
-
Current State of Mod_Python
Currently mod_python is not under active development. This does not
mean that it is "dead" as some people have claimed. It smiply means
that the code and the project are mature enough when very little is
required to maintain it.
This is a good article from the Python website:
http://docs.python.org/howto/webservers.html
Plain CGI is a good starting point to learn about server side scripting, but it is an outdated technology and gets difficult to maintain after certain level of complexity. I would think it is no longer used in industrial-grade web server anymore. Plus you have to setup a web server and then install some module to interpret python script (like Apache with mod_python) just to get started.
I had some experience with Django (https://www.djangoproject.com/) and found it fairly easy to get started with since they come with development test server. All you need to have is a Python interpreter + Django and you can get up-and-running quickly and worry about the deployment setup later. They have pretty good documentation for beginner as well.
We have never used Python for a web site without a framework. In our case that is Django. In other words, we do not use Python for our web sites the way Perl can be used, just having Apache run a Perl script.
The recommendations you have received about Django are sound. If you go the Django route, Graham Dumpleton and the modwsgi Google group were very helpful to me. I could
not have gotten mod_wsgi deployed on Red Hat Enterprise 5 64-bit without Graham's help.
Whether you choose Django or "straight" Python, you will need to become familiar with mod_wsgi.
Good luck in quantum time, which means by now, I hope this all worked out for you.

Deploying Django on an apache server

I am new to web development. So be gentle. AND thanks in advance.
I am developing on windows env. and deploying on a linux server w/ Python 2.6.2 installed.
Running apache2.2 as Virtual Host, and I am using mod_wsgi. I plan to serve media files from the same Virtual Host.
I have a django site and I am now ready to deploy. I am stuck, and every site I go to seems to be outdated/incomplete/overmyhead.
https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
http://www.djangobook.com/en/2.0/chapter12/
...only 2 links as for the newbness
The top link seems to be what I need yet I am still confused on these things:
What does the file structure look like on the server
I cannot change/edit server files myself, I rely on the dba for that
I have django.wsgi, and django.wsgi~, where do those go?
Where do I put my project in relation to those wsgi files?
The httpd.conf file is something that the server has on it? or do I create another?
Do I need to put django in any way shape or form on the server? If so where? And what about the packages like registration, defaults?
Again sorry for the newbness, I have been banging my head for 2 weeks on this.
Any help/links will be greatly appreciated unless they link me to the django-docs. I have read those...A LOT! thanks
Also go read:
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
and watch:
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations
The latter includes Django examples and talks a bit about locations, permissions etc.
The first of these is even linked to in the document in the Django documentation.
It doesn't matter where the files go. They just have to be readable/executable by the user that the web server is running under.
I don't know what you mean by django.wsgi~, that sounds like a backup file created by your editor - you don't need that.
Yes the httpd.conf is the configuration file for Apache. Some distributions (eg Debian and Ubuntu) split this up into separate files for each site that the server runs. If your administrator is the only one who can edit files, he will know about this already.
Yes, you need Django, and any third-party packages.
#Nathan
An easier option for you while you are learning this is not to really have to many expenses.
I could also suggest you take a look at Heroku - allows you to easily deploy your applications in minutes.
Up until recently they only supported RoR and they have brought in support for Django and Python - they have some really well documented tutorials as well.
I hope this helps
Heroku Django / Python tutorial
I have written up an simple deployment guide for django applications it can be found here. It goes all the way from project setup and deployment. I also have references setup. I honestly believe it answers all your questions, I would give it a look.
Goodluck.

Categories