Unable to connect to WSGI daemon process 'sampleapp' - django

I tried to install django in ubuntu server and i had 503 error in error.log
my apache2.conf is:
<VirtualHost x.xxx.xxx.xxx:8080>
ServerAlias www.samplesite.com
ServerAdmin info#samplesite.com
DocumentRoot /var/www/sampleapp/
ScriptAlias /cgi-bin/ /var/www/sampleapp/cgi-bin/
Alias /vstats/ /var/www/sampleapp/stats/
Alias /error/ /var/www/sampleapp/document_error
#SuexecUserGroup admin admin
CustomLog /var/log/apache2/domains/sampleapp.ir.bytes bytes
CustomLog /var/log/apache2/domains/sampleapp.ir.log combined
ErrorLog /var/log/apache2/domains/sampleapp.ir.error.log
WSGIProcessGroup sampleapp
WSGIScriptAlias /sampleapp /var/www/sampleapp/sampleapp/wsgi.py
WSGIDaemonProcess sampleapp python-path=/var/www/sampleapp:/var/www /sampleapp/envme/lib/python3.4/site-packages
<Directory /var/www/sampleapp/static/>
Require all granted
</Directory>
<Directory /var/www/sampleapp/media/>
Require all granted
</Directory>
<Directory /var/www/sampleapp/sampleapp/>
<Files wsgi.py>
require all granted
</Files>
</Directory>
<Directory /var/www/sampleapp/>
AllowOverride All
Options +Includes +Indexes +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and i have this error in my error.log:
(13)Permission denied: [client x.xxx.xx.xxx:59504] mod_wsgi (pid=26905): Unable to connect to WSGI daemon process 'sampleapp' on '/var/run/apache2/wsgi.26899.0.1.sock' as user with uid=1005.
I lost 2 days trying to solve it,

You can refer this url,
http://code.google.com/p/modwsgi/wiki/ConfigurationIssues#Location_Of_UNIX_Sockets
Adding this,
WSGISocketPrefix run/wsgi
will solve the error. The solution is to change where the socket files are kept to a location where Apache user can read them.

Related

How to fix? Error 500: No WSGI daemon process called... (Apache/ 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>

core error - Script timed out before returning headers: wsgi.py

I'm running a Django app on Apache/2.4.6 (CentOS) with mod_wsgi.
When I visit my domain, after few minutes I get "Internal Server Error".
The log file shows the following error -
[core:error] [pid 9361] [client 132.72.41.107:55906] Script timed out before returning headers: wsgi.py
The config file in sites-enable folder -
<VirtualHost *:80>
ServerName www.meshi1.cs.bgu.ac.il
ServerAlias meshi1.cs.bgu.ac.il
DocumentRoot "/var/www/meshi1.cs.bgu.ac.il"
ErrorLog /var/www/meshi1.cs.bgu.ac.il/log/error.log
CustomLog /var/www/meshi1.cs.bgu.ac.il/log/requests.log combined
Alias /static /home/cluster/orelhaz/bin/rom_deshe/djangonautic1/static
<Directory /home/cluster/orelhaz/bin/rom_deshe/djangonautic1/static>
Require all granted
</Directory>
WSGIDaemonProcess djangonautic python-home=/home/cluster/orelhaz/bin/rom_deshe/myenv/lib/python3.6
WSGIProcessGroup djangonautic
WSGIScriptAlias / /home/cluster/orelhaz/bin/rom_deshe/djangonautic1/djangonautic/wsgi.py
<Directory /home/cluster/orelhaz/bin/rom_deshe/djangonautic1/djangonautic>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
Thanks!

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

Django for windows, using WSGIPythonPath for multiple instances of Virtual Host

Im using Windows 10
In httpd.conf (Apache) how to use WSGIPythonPath for multiple instances of Virtual Host for different project and ports since WSGIDaemonProcess is not supported on Windows.
httpd.conf
LoadModule wsgi_module "c:/users/webdev/documents/mark/digos-logs/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIPythonHome "C:\Users\WebDev\AppData\Local\Programs\Python\Python37"
WSGIPythonPath "C:\Users\WebDev\Documents\Mark\digos-logs"
where "C:\Users\WebDev\Documents\Mark\digos-logs" is my project root folder and "C:\Users\WebDev\Documents\Mark" is my parent folder of all my projects.
Project 1
listen 9292
<VirtualHost *:9292>
ServerName 127.0.0.1
# error occured (Example)
WSGIPythonPath "C:\Users\WebDev\Documents\Mark\digos-logs"
######3
WSGIScriptAlias / "C:\Users\WebDev\Documents\Mark\digos-logs\app_ict\wsgi.py"
<Directory "C:\Users\WebDev\Documents\Mark\digos-logs\app_ict">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
DocumentRoot C:\Users\WebDev\Documents\Mark\digos-logs
<Directory "C:\Users\WebDev\Documents\Mark\digos-logs\static">
Require all granted
</Directory>
</VirtualHost>
Project 2
listen 9595
<VirtualHost *:9595>
ServerName 127.0.0.1
# error occured (Example)
WSGIPythonPath "C:\Users\WebDev\Documents\Mark\project2"
######3
WSGIScriptAlias / "C:\Users\WebDev\Documents\Mark\project2\app\wsgi.py"
<Directory "C:\Users\WebDev\Documents\Mark\project2\app">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
DocumentRoot C:\Users\WebDev\Documents\Mark\project2
<Directory "C:\Users\WebDev\Documents\Mark\project2\static">
Require all granted
</Directory>
</VirtualHost>

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>