I have created a django application and deployed it on the server.I have run the application through :-
python manage.py runserver 8000 &
and handle the requests on the apache server through proxy
ProxyPass "/" "http://www.example.com/"
.
ProxyPassReverse "/" "http://www.example.com/"
But there is a issue that I am facing while testing the api through JMeter, when i am running a test case for 10 users my python service over the server gets killed automatically.
What i am doing wrong or what i have to do more to resolve the above test scenario,please suggest?
2
Answers
You cannot using
python manage.py runserver 8000
on a server, it’s for development ONLY.You can see the documentation here https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
A basic conf for Apache would be :
You need to adapt this for your project.
If you need to install mod_wsgi : https://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html
For me i would use https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/uwsgi/ it’s more convenient (
pip install uwsgi
)First of all you need to deploy it on other server like
apache
. Below I am sharing how as usual configuration of apache2 to deploy a python django project.virtual environment
Apache installation:
You need to install apache if not installed yet. Here I am showing the apache2 installation and some other installation which we need.
configuration of 000-default.conf file : Generally the apache2 is located on linux m at path
/etc/apache2/sites-available/000-default.conf
. And the configuration file may like that.Django project wsgi.py : The django project you created there have a
wsgy.py
and this file may look like.After that you can start you apache2 sever
sudo service apache2 start
Also you need to give the permission of you project directory
sudo chmod -R 777 /path/to/my-project
This is the basic configuration of apache2 with python django project. Hope this will help to configure any
linux machine
with yourpython django project