Forbidden 403 Apache error on an Indico installation - python-2.7

I installed Indico http://indico-software.org/ that is an open source tool for event organization, archival and collaboration on Ubuntu with this instructions https://indico.syntek.org/category/1/material/0/0.pdf, installation looks ok but when I try to open localhost/indico I get a forbidden 403 error.
I added this lines to the /etc/apache2/apach2.conf
WSGIScriptAlias / /opt/indico/htdocs/
WSGIPythonHome /usr/local/pythonenv/BASELINE
WSGIPythonPath
/usr/local/pythonenv/indico12/lib/python2.7/sitepackages
WSGIPythonEggs /opt/indico/tmp/egg-cache
<Directory /opt/indico/htdocs>
Options Indexes FollowSymLinks
AllowOverride None
<Files indico.wsgi>
Require all granted
</Files>
</Directory>
This is my virtulhost file on /etc/apache2/sites-available/a2indico.conf
<VirtualHost *:80>
ErrorLog /var/log/apache2/error.log
LogLevel warn
Alias /indico/images "/opt/indico/htdocs/images"
Alias /indico/css "/opt/indico/htdocs/css"
Alias /indico/js "/opt/indico/htdocs/js"
Alias /indico/ihelp "/opt/indico/htdocs/ihelp"
WSGIDaemonProcess WSGIDAEMON processes=32 threads=1 inactivity-
timeout=3600 maximumrequests=10000 python-
path=/usr/local/pythonenv/indico12/lib/python2.7/site-packages python-
eggs=/opt/indico/tmp/egg-cache
WSGIScriptAlias /indico "/opt/indico/htdocs/indico.wsgi"
<Directory "/opt/indico">
WSGIProcessGroup WSGIDAEMON
WSGIApplicationGroup %{GLOBAL}
AllowOverride None
Options FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
The chown for the /etc/apach2 and /opt/indico directorys are for www-data user.
Thank you very much for your help.
Plz give me some advise. =)

Your probably not landing in that newly created virtualhost, it has no ServerName or ServerAlias. apachectl -S will show you the other virtualhosts you have. Even after specifying a ServerName or ServerAlias here, you may need to modify your default (000-default) virtualhost as it may implicitly use your local systems name as a ServerNAme (ubuntu leaves it blank which can hide a later vhost!)

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>

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

How do I receive subdomain wildcards on Apache2 using mod wsgi?

I'm developing an app with Django 1.8 and I'm trying to receive subdomains and then present customized homepages dependent on the subdomain. For example: example.com is my company's homepage, a user signs up as conqueryor.example.com and they get a new homepage named "conqueryor.example.com" or whatever they want.
Sounds simple enough, there's even the django subdomains library that I'm using. My current issue lies in setting up Apache2 and mod WSGI locally so that I can test it out locally before I affect everyone else on the project. I'm currently able to use the following .conf file with the lines 127.0.0.1 example.dev and 127.0.0.1 .example.dev in my /etc/hosts file. In my browser I'm able to access my app from example.dev, but if I try any subdomains I receive the Server Not Found page. I've also attempted using dnsmasq and adding the line address=/.example.dev/127.0.0.1
Current environment:
Ubuntu 15.10
Django 1.8.1
Apache 2.4
<VirtualHost *:80>
ServerName example.dev
DocumentRoot /home/example
ServerAlias www.example.dev
WSGIDaemonProcess example python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example
WSGIScriptAlias / /home/example/saas/wsgi.py
<Directory /home/example/static>
Require all granted
</Directory>
<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.dev
DocumentRoot /home/example
ServerAlias example.dev
WSGIDaemonProcess example2 python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example2
WSGIScriptAlias / /home/example/saas/wsgi.py
Alias /static/ /home/example/static/
<Directory /home/example/static>
Require all granted
</Directory>
<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.dev
DocumentRoot /home/example
ServerAlias *.example.dev
WSGIDaemonProcess example3 python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example3
WSGIScriptAlias / /home/example/saas/wsgi.py
Alias /static/ /home/example/static/
<Directory /home/example/static>
Require all granted
</Directory>
<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Thanks!
I'm going to leave the question in case this helps anyone else, but I found the solution... I forgot I hadn't restarted dnsmasq, so after adding the address=/.example.dev/127.0.0.1 line to /etc/dnsmasq.conf and restarting dnsmasq with sudo /etc/init.d/dnsmasq restart I was able to access sites on subdomains. Oops!

Unable to connect to WSGI daemon process 'sampleapp'

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.

Two Django projects running simultaneously and mod_wsgi acting werid

I'm trying to run two Django projects simultaneously. I happened to be using mod_wsgi, and found the site is acting weird. Perhaps there would be a workaround, but I'd like to know what I'm missing and how to solve the problem.
In the apache configuration
# Setup the Python environment
# As root owns basically everything on a Amazon AMI and root
# cannot be used. Create a folder under /var/run/wsgi
# with the owner as ec2-user and group ec2-user.
WSGISocketPrefix /var/run/wsgi
# Call your daemon process a name
WSGIDaemonProcess pydaemon processes=1 threads=5
# Call your daemon process group a name
WSGIProcessGroup pydaemon
# Point to where the handler file is. This will be different
# If you are using some other framework.
WSGIScriptAlias /test /var/www/html/test/wsgi.py
WSGIScriptAlias /proto /var/www/html/proto/wsgi.py
After Apache restarts, if I connect to '/proto', then the proto site is shown. However, then I connect to '/test', without restarting Apache, the proto site is still shown, and I cannot access to the test site.
Now I restart Apache, this time I go to '/test' first. The test site comes up! However, if I go to '/proto' it still shows the test site, not the proto site.
What could make this happen? I added SESSION_COOKIE_PATH differently for each application just in case, but the problem still exists.
[UPDATED]
I also tried as the following, to give different WSGI application group names, but without luck.
Alias /cuedit /var/local/test/wsgi.py
<Location /test>
SetHandler wsgi-script
Options +ExecCGI
WSGIApplicationGroup test
</Location>
Alias /proto /var/local/proto/wsgi.py
<Location /proto>
SetHandler wsgi-script
Options +ExecCGI
WSGIApplicationGroup proto
</Location>
[UPDATED]
I changed from the daemon mode to the embedded mode. I guess the problem was two instances shared the same mod_wsgi daemon process so their namespace collide.
I would expect they should be handled correctly, but in the daemon mode I couldn't get it right.
Use this as a workaround:
WSGIDaemonProcess pydaemon-1 processes=1 threads=5
WSGIDaemonProcess pydaemon-2 processes=1 threads=5
WSGIScriptAlias /test /var/www/html/test/wsgi.py
<Location /test>
WSGIProcessGroup pydaemon-1
WSGIApplicationGroup %{GLOBAL}
</Location>
WSGIScriptAlias /proto /var/www/html/proto/wsgi.py
<Location /proto>
WSGIProcessGroup pydaemon-2
WSGIApplicationGroup %{GLOBAL}
</Location>
This will force each application into separate daemon process group and no way they should be able to interfere with each other.
If that still doesn't work, you have problems with your WSGI script file somehow.
I also have 2 Django projects however each one is running on a different port (httpd config), it looks something like this:
<VirtualHost *:80>
ServerAdmin xx
ServerName xx
ServerAlias xx
ErrorLog /path/to/first/project/logs/error.log
CustomLog /path/to/first/project/logs/access.log combined
Alias /static/ /path/to/first/project/sitestatic
WSGIDaemonProcess app processes=1 threads=15 display-name=%{GROUP}
WSGIProcessGroup app
WSGIScriptAlias / /path/to/first/project/django.wsgi
<Directory /path/to/first/project/apache>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin xx
ServerName xx
ServerAlias xx
ErrorLog /path/to/second/project/logs/error.log
CustomLog /path/to/second/project/logs/access.log combined
WSGIDaemonProcess app1 processes=1 threads=15 display-name=%{GROUP}
WSGIProcessGroup app1
WSGIScriptAlias / /path/to/second/project/apache/django.wsgi
<Directory /path/to/second/project/apache>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
The problem might be related to Apache sharing the Python sub interpreter between WSGI applications. Try adding this to the Apache configuration to avoid sharing:
WSGIApplicationGroup %{GLOBAL}
Check this blog post for in-depth explanation and additional tips (check the comments too).
Can't comment on the answer given by Graham, so adding one of my own.
The problem for me really was the Python Interpreter, but I also had to add the python-path for each interpreter. Here follows an example configuration:
WSGIDaemonProcess py_app1 processes=1 threads=5 python-path=/path/to/app1
WSGIScriptAlias /app1 /path/to/app1/wsgi.py
<Directory /path/to/app1>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
<Location /app1>
WSGIProcessGroup py_app1
WSGIApplicationGroup %{GLOBAL}
</Location>
WSGIDaemonProcess py_app2 processes=1 threads=5 python-path=/path/to/app2
WSGIScriptAlias /app2 /path/to/app2/wsgi.py
<Directory /path/to/app2>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
<Location /app2>
WSGIProcessGroup py_app2
WSGIApplicationGroup %{GLOBAL}
</Location>