I'm working on deploying a django app and I'm looking at a few tutorials which install apache within the virtualenv.
http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/
http://michal.karzynski.pl/blog/2013/09/14/django-in-virtualenv-on-webfactions-apache-with-mod-wsgi/
My question is that if I'm trying to deploy to a server that already has Apache installed on it, would installing a separate version of apache within the environment (as you would Django in general) overwrite any of the Apache settings currently on the server?
Using virtualenv doesn't mean installing a separate version of Apache. In fact, that's not even possible, because virtualenv is for Python libraries only.
Your Django app plus all its libraries lives in the virtualenv, but you use the system's Apache to serve it.
Related
I am new to web development. I am not familiar with Django. I have written some Python scripts which do some intense calculations and graphs plotting using Python packages such as numpy, matlibplot and so on. I want to publish it as a web application on a server to be accessed by other computers.
So I am wondering, do I need to copy all the required packages into the project directory before deploying the application to a server? Or Django will automatically handle the Python packages dependencies upon deploying?
All the needed packages need to be installed on the server where is the web application running. If you have all the packages installed on your personal computer before deploy you will need to install the on the server as well.
You have to create virtual environment.
A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments for them.
I'm working on creating my first "real" web app using Django.
Yesterday I learned I should be using a web server like Nginx to serve static files and pass off requests for dynamic content to my web app. I also learned that I need something like Gunicorn as the intermediary between the web server (Nginx) and my Django app.
My question is about virtualenv. It makes sense that we would contain app related software in it's own separate environment. What should I install in virtualenv, and what gets installed system wide? For example, in this guide we seem to install Python, Nginx and the database system wide (because they're installed before virtualenv is installed) while Django and Gunicorn are installed in virtualenv. It makes sense that Gunicorn would have to go in the virtualenv since its importing our python app, as explained here. Are the other things required to be installed system wide? Or can I pick either way? Is one way preferred over another?
Thanks!
Virtualenv is for managing Python libraries. It is not for managing Python itself, or for external services such as databases; it does however manage the Python libraries you use to access the database.
There's no room for confusion here, because there's simply no way to install Python itself or a database within a virtualenv.
I plan to deploy a django app on apache. After having set up apache ,python and django on the dev box,i was going through the tutorials for configuring mod_wsgi. I see that there are two methods-
Installation into Apache
Installation into Python
How do they differ?Apart from the obvious difference that file location will be different,what are the other differences? Going forward,what are the implications of each?
FYI, I do not have any issue with installing/configuring mod_wsgi with
apache. I am just interested in understanding the
implications/differences between installing into python and installing
into apache.
To make my question clear:
I have had wamp installed, and it brought Apache. Will this Apache be used by others like Django?
If the wamp Apache is enough for others, its Apache is in wamp directory C:\wamp\bin\apache, not sth like C:\programs file...It is ok for django
If I have to install Apache manually for django, will the step be install Apache, install mod_wsgi?
Any help would be greatly appreciated
Strictly interpreted, Django doesn't "use" Apache. Apache is just one way to direct requests (via mod_wsgi, for example) to your django app and returns the result to the user.
The existing Apache install will be fine. It doesn't matter where it is as long as it's running and reachable.
You will need to install mod_wsgi and configure it so that it knows about your Django app.
You can find documentation for configuring Apache and mod_wsgi here:
https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/
You don't need Apache at all at this point. For development, things work much better if you use the built in development server, as described in the tutorial.
I am of the PHP background and just have started to learn Django and Python (and loving it). I always used to install WAMP server for PHP development.
Now I dont know how do I configure Django to use PostgreSQL i.e how to make both communicate with each other. I have run some 'hello world' scripts with django. Curretly I have installed Python, django and PostgreSQL. here is the version information
Python : 2.7.2 & 3.2 (i have installed both)
Django : 1.3.1
PostgreSQL : 9.1.2
Apache : 2.2 (..this is from WAMP server)
Os : Ms Windows 7 32-bits (x86)
Since django has builtin development server is it at all necessary to have apache installed and use it instead of that one? If we use the built-in server how we are supposed to configure it for PostgreSQL?.
It is not necessary to have apache installed to develop on django. In fact it is often easier to use the development server because it is single threaded, lightweight, and extremely easy to use. python manage.py runserver 0.0.0.0:8080 to run on localhost port 8080, and your code is easily debuggable.
In django you dont configure your server for a database. You configure your project for a database. All database configurations are kept in the settings.py file located in your main project. Page one of the tutorial explains how to set up a database for your django prject. YOu have to specify, database name, host, port, user and password in your settings.py file.
https://docs.djangoproject.com/en/dev/intro/tutorial01/#database-setup
I would suggest walking through the django tutorial as it addresses most of the issues in setting up development on a new django project.
https://docs.djangoproject.com/en/dev/intro/tutorial01/
I recently deployed a Django based project and found this tutorial to be very helpful and concise.
Django virtualenv Apache2 mod_wsgi
And if you have CentOS, then you can install mod_wsgi as mentioned here:
Django Deployment - Setup mod_wsgi on CentOS
Getting Django to run on Apache requires getting Python to interpret that, you can do this with WSGI. follow the tutorial found here:
https://code.djangoproject.com/wiki/django_apache_and_mod_wsgi
there are other methods to deploy this, you can find here:
https://docs.djangoproject.com/en/dev/howto/deployment/