How to fix? Error 500: No WSGI daemon process called... (Apache/ Django) - django

I have an internal Server Error 500 on my Django Server. When I check the error.log, I get the following error:
No WSGI daemon process called "..." has been configured: "..."
I hope someone can help me to fix this Error.
Here is my Apache config:
<VirtualHost *:80>
ServerAdmin ADMIN
ServerName DOMAIN
ErrorLog /home/USER/PROJECT/site/logs/error.log
CustomLog /home/PROJECT/PROJECT/site/logs/access.log combined
Alias /static /home/USER/PROJECT/static
<Directory /home/USER/PROJECT/static>
Require all granted
</Directory>
<Directory /home/USER/PROJECT/src/social>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess PROJECT python-path=/home/USER/PROJECT/ python-home=/home/USER/PROJECT/VIRTUALENV
WSGIProcessGroup PROJECT
WSGIScriptAlias / /home/USER/PROJECT/src/social/wsgi.py
</VirtualHost>

move your project path from /home/USER/PROJECT to /var/www/PROJECT
make sure you are chmod project folder --> sudo chmod -R 777 /project
if not work give your email to me for contact
<VirtualHost *:80>
# edit all /home/USER/PROJECT to /var/www/PROJECT
ServerAdmin ADMIN
ServerName DOMAIN
ErrorLog /home/USER/PROJECT/site/logs/error.log
CustomLog /home/PROJECT/PROJECT/site/logs/access.log combined
Alias /static /home/USER/PROJECT/static
<Directory /home/USER/PROJECT/static>
Require all granted
</Directory>
<Directory /home/USER/PROJECT/src/social> # here put path of where wsgi.py existing folder
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess PROJECT python-path=/home/USER/PROJECT/ python-home=/home/USER/PROJECT/VIRTUALENV
WSGIProcessGroup PROJECT
WSGIScriptAlias / /home/USER/PROJECT/src/social/wsgi.py
</VirtualHost>

Related

Apache error on ubuntu ERROR: Site (SiteName) does not exist

I'm facing a problem when I run sudo a2ensite test.watermaps-eg.com.conf to add a new site to apache2 it gives me ERROR: Site test.watermaps-eg.com does not exist!
What I tried to do
Added the file test.watermaps-eg.com.conf inside sites-enabled.
Added the apache2 configurations inside the file.
<VirtualHost *:80>
ServerName https://test.watermaps-eg.com
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#innoventiq.com
ServerName test.watermaps-eg.com
DocumentRoot /home/ubuntu/test_water_maps_django
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/ubuntu/test_water_maps_django/static
<Directory /home/ubuntu/test_water_maps_django/static>
Require all granted
Order Allow,Deny
Allow from all
AllowOverride all
</Directory>
<Directory /home/ubuntu/test_water_maps_django/kml_files>
Require all granted
</Directory>
<Directory /home/ubuntu/test_water_maps_django/water_maps>
Require all granted
Order Allow,Deny
Allow from all
AllowOverride all
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess test_water_maps_django python-path=/home/ubuntu/test_water_maps_django python-home=/home/ubuntu/test_water_maps_django/venv
WSGIProcessGroup test_water_maps_django
WSGIScriptAlias / /home/ubuntu/test_water_maps_django/water_maps/wsgi.py
WSGIPassAuthorization On
</VirtualHost>
I ran the command sudo a2ensite test.watermaps-eg.com.conf and it returns the mentioned above error.
You might want to add the conf (test.watermaps-eg.com.conf) file inside /etc/apache2/site-available
before running the command
sudo a2ensite test.watermaps-eg.com

Need help configuring apache .conf file

I want to deploy my django app on a Apache 2.4 server. The same server will host static files. The thing is that this server hosts other php based web sites.
In order for all this to work I just need to install mod_wsgi and configure apache's .conf file related to this web site, is that right?
After reading few articles I came up with this config, assuming that the web site will be in the var/www/ folder :
<VirtualHost *:80>
ServerName example.com
# Alias /events /var/www/events/html
ServerAdmin webmaster#localhost
DocumentRoot /var/www/example
Alias /media/ /var/www/example/media/
Alias /static/ /var/www/example/static/
<Directory /var/www/example/static>
Order deny,allow
Require all granted
</Directory>
<Directory /path/to/example/media>
Order deny,allow
Require all granted
</Directory>
WSGIScriptAlias / /var/www/example/events_promgruz/wsgi.py
WSGIDaemonProcess example.com python-path=/var/www/example:/opt/envs/lib/python3.6/site-packages
WSGIProcessGroup example.com
<Directory /path/to/example/example>
<Files wsgi.py>
Order allow,deny
Require all granted
</Files>
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
What would you suggested to change or add to config?
Is there some other steps to ensure that django app will work and that it doesn't interfere other non wsgi apps?
This is what I ended up using:
<VirtualHost *:80>
ServerName expample-domen.com
ServerAdmin webmaster#localhost
Alias /static /var/www/example/static
Alias /media /var/www/example/media
<Directory /var/www/example/static>
Require all granted
</Directory>
<Directory /var/www/example/media>
Order deny,allow
Require all granted
</Directory>
<Directory /var/www/example/example>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess example python-home=/path/to/virtualEnv python-path=/var/www/example
WSGIProcessGroup example
WSGIScriptAlias / /var/www/example/example/wsgi.py
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Django project set up with Apache2 - i want to access it through I.P/application_name/

Hi I want to set up my django project to be access through apache2 by I.P/application_name/
So "192.0.0.0/app/" (Ip being an example)
Here is my 000-default.conf file in etc/apache2/sites-available
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
WSGIDaemonProcess HTSv2 python-home=/home/django/config/env python-path=/usr/local/django/app
WSGIProcessGroup HTSv2
WSGIScriptAlias / /usr/local/django/app/application/wsgi.py
<Directory /usr/local/django/app/application>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /usr/local/django/app/static/
<Directory /usr/local/django/app/static>
Require all granted
</Directory>
<Directory /usr/local/django/app>
Deny from all
Allow from ...
</Directory>
</VirtualHost>
When I change the line:
WSGIScriptAlias / /usr/local/django/app/application/wsgi.py
to
WSGIScriptAlias /app/ /usr/local/django/app/application/wsgi.py
I can access the home page of my application by 192.0.0.0/app/
However when I click on any buttons, obviously does not keep to this, so for example going to page1, does not go to 192.0.0.0/app/page1, it goes to 192.0.0.0/page1
How can I configure apache2 to do this? The reason I want to do this is so I can host multiple projects on the same server, so the root of 1 project is 192.0.0.0/app1/ and then the root of the other is 192.0.0.0/app2/ etc...

run multiple django project in different virtualenv on apache

I want to run two different django_projects each in different virtualenv.
This is the code :
ServerName ubuntu_server_apache
<VirtualHost *:80>
ServerName dev.hexxie.com
ErrorLog "/home/ashish/deployments/mysite_dev/conf/mysite_dev_error.log"
WSGIScriptAlias / /home/ashish/deployments/mysite_dev/mysite/mysite/wsgi.py
Alias /static /home/ashish/deployments/mysite_dev/static_root
<Directory /home/ashish/deployments/mysite_dev/static_root>
Require all granted
</Directory>
Alias /media /home/ashish/deployments/mysite_prod/data/media
<Directory /home/ashish/deployments/mysite_prod/data/media>
Require all granted
</Directory>
<Directory /home/ashish/deployments/mysite_dev/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
WSGIPythonPath /home/ashish/deployments/mysite_dev/mysite:/home/ashish/.virtualenvs/mysite_dev/lib/python2.7/site-packages
<VirtualHost *:80>
ServerName hexxie.com
ServerAlias *.hexxie.com
ErrorLog "/home/ashish/deployments/mysite_prod/conf/mysite_error.log"
WSGIScriptAlias / /home/ashish/deployments/mysite_prod/mysite/mysite/wsgi.py
Alias /static /home/ashish/deployments/mysite_prod/static_root
<Directory /home/ashish/deployments/mysite_prod/static_root>
Require all granted
</Directory>
Alias /media /home/ashish/deployments/mysite_prod/data/media
<Directory /home/ashish/deployments/mysite_prod/data/media>
Require all granted
</Directory>
<Directory /home/ashish/deployments/mysite_prod/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
WSGIPythonPath /home/ashish/deployments/mysite_prod/mysite:/home/ashish/.virtualenvs/mysite_prod/lib/python2.7/site-packages
But I am getting internal server error using this apache conf. I feel that this is due to WSGIPythonPath used twice in conf. WSGIPythonPath can't be included inside virtualhost. So how to run two diff django project each on diff virtualenv on apache ?
For a start, use a daemon process group so each runs in a separate process and then use the python-home option on the respective WSGIDaemonProcess group directives. See:
http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html
http://blog.dscpl.com.au/2014/09/using-python-virtual-environments-with.html
Here's an example of how I do it. You'll have to change paths / project names based on your setup, naturally (example is SSL on port 443, but works on port 80 as well):
LoadModule wsgi_module modules/mod_wsgi.so
LoadModule ssl_module modules/mod_ssl.so
WSGISocketPrefix /var/run/wsgi
NameVirtualHost *:443
Listen 443
<VirtualHost *:443>
ServerName your.server.com
ErrorLog /home/user/apache_errors.log
WSGIDaemonProcess project1-https python-home=/home/user/.virtualenvs/project1
WSGIScriptAlias /project1 /var/www/html/project1/project1/wsgi.py process-group=project1-https application-group=project1-https
WSGIProcessGroup project1-https
Alias /project1/static/ /var/www/html/project1/static/
WSGIDaemonProcess project2-https python-home=/home/user/.virtualenvs/project2
WSGIScriptAlias /project2 /var/www/html/project2/project2/wsgi.py process-group=project2-https application-group=project2-https
WSGIProcessGroup project2-https
Alias /project2/static/ /var/www/html/project2/static/
</VirtualHost>
The virtualenv takes care of the Python executable and path when configured in this manner.

VirtualHost configuration doesn't allow second website to run

I have this in my /etc/apache2/sites-available/staginnx.com.conf
WSGIScriptAlias / /home/ubuntu/v1/staginnx-info/app/website/website/wsgi.py
WSGIPythonPath /home/ubuntu/v1/staginnx-info/app/website
<VirtualHost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin info#staginnx.com
ServerName staginnx.com
ServerAlias www.staginnx.com
<Directory /home/ubuntu/v1/staginnx-info/app/website/website>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /home/ubuntu/v1/staginnx-info/app/website/ui/static/
<Directory /home/ubuntu/v1/staginnx-info/app/website/ui/static>
Require all granted
</Directory>
Alias /favicon.ico /home/ubuntu/v1/staginnx-info/app/website/ui/static/images/favicon.ico
ErrorLog /var/log/apache2/error.log
</VirtualHost>
<VirtualHost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin blog.staginnx#staginnx.com
ServerName blog.staginnx.com
ServerAlias blog.staginnx.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.php
DocumentRoot /var/www/html/blog/
<Directory /var/www/html/blog>
Require all granted
</Directory>
# Custom log file locations
LogLevel warn
ErrorLog /var/www/html/blog/log/error.log
CustomLog /var/www/html/blog/log/access.log combined
</VirtualHost>
Now the first one, the main website is working fine. The second one, BLOG is not working.
I have done sudo a2ensite staginnx.com.conf and a symlink is generated at sites-enabled. I have done reload apache and restart too.
Surfed around but no luck.
Want to install wordpress blog in my blog folder.
In order to use your django application inside a virtual host you need to set the WSGIScriptAlias inside the virtualhost settings and also you can't use the WSGIPythonPath, you need to use WSGIDaemonProcess like in the following settings.
<VirtualHost *:80>
WSGIScriptAlias / /home/ubuntu/v1/staginnx-info/app/website/website/wsgi.py
WSGIDaemonProcess example.com python-path=/home/ubuntu/v1/staginnx-info/app/website
# Admin email, Server Name (domain name) and any aliases
ServerAdmin info#staginnx.com
ServerName staginnx.com
ServerAlias www.staginnx.com
<Directory /home/ubuntu/v1/staginnx-info/app/website/website>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /home/ubuntu/v1/staginnx-info/app/website/ui/static/
<Directory /home/ubuntu/v1/staginnx-info/app/website/ui/static>
Require all granted
</Directory>
Alias /favicon.ico /home/ubuntu/v1/staginnx-info/app/website/ui/static/images/favicon.ico
ErrorLog /var/log/apache2/error.log
</VirtualHost>
Also in case you want to host multiple application on the same host then you need to change a small setting in the wsgi.py file as well.
instead of using
os.environ.setdefault(DJANGO_SETTINGS_MODULE, "app.settings")
you should use
os.environ["DJANGO_SETTINGS_MODULE"] = "app.settings"
I hope this helps you.
For WSGIDaemonProcess setting