Someone can help me why it doesn't work? (my project name is ikh)
i'm using ubuntu 16.04 LTS, Apache2 , Python3
ServerAdmin webmaster#localhost
DocumentRoot /var/www/ikh
WSGIDaemonProcess ikh python-path=/var/www/ikh/ python-home=/var/www/ikh/.env
WSGIProcessGroup ikh
WSGIScriptAlias / /var/www/ikh/ikh/wsgi.py
<Directory /var/www/ikh/ikh>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
i found that some interesting problems :
1 - first should set server to listen the port that i want to deploy on it!
Listen 8000
2 - to use WSGIDaemonProcess should do like this sample that i write it for my apache2 configuration
WSGIDaemonProcess ikh python-path=/var/www/ikh python-home=/var/www/ikh/env/lib/python3.5/site-packages
and thats about it!
Related
I'm hosting two Django projects on my Ubuntu 20.04 server using Apache, with two different domains.
djangoproject1 is hosted on example1.com:8000
djangoproject2 is hosted on example2.com:8000
However I'm having a strange issue where only one of the two is accessible at a time. Both sites work perfectly when the other one is disabled (using "a2dissite"). But when both are enabled, only one will work and the other one loads forever until time out.
djangoproject1.conf
<VirtualHost *:8000>
ServerAdmin webmaster#localhost
ServerName example1.com
ServerAlias www.example1.com
DocumentRoot /var/www/djangoproject1
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /var/www/djangoproject1/static
<Directory /var/www/djangoproject1/static>
Require all granted
</Directory>
Alias /static /var/www/djangoproject1/media
<Directory /var/www/djangoproject1/media>
Require all granted
</Directory>
<Directory /var/www/djangoproject1/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess djangoproject1 python-home=/var/www/djangoproject1/venv python-path=/var/www/djangoproject1
WSGIProcessGroup djangoproject1
WSGIScriptAlias / /var/www/djangoproject1/project/wsgi.py
</VirtualHost>
djangoproject2.conf (similar to djangoproject1.conf)
<VirtualHost *:8000>
ServerAdmin webmaster#localhost
ServerName example2.com
ServerAlias www.example2.com
DocumentRoot /var/www/djangoproject2
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /var/www/djangoproject2/static
<Directory /var/www/djangoproject2/static>
Require all granted
</Directory>
Alias /static /var/www/djangoproject2/media
<Directory /var/www/djangoproject2/media>
Require all granted
</Directory>
<Directory /var/www/djangoproject2/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess djangoproject2 python-home=/var/www/djangoproject2/venv python-path=/var/www/djangoproject2
WSGIProcessGroup djangoproject2
WSGIScriptAlias / /var/www/djangoproject2/project/wsgi.py
</VirtualHost>
The apache logs shows the following error multiple times:
(11)Resource temporarily unavailable: mod_wsgi (pid=1498191): Couldn't create worker thread 6 in daemon process 'djangoproject2'.
I would highly appreciate some help with this issue as I have no idea what's causing it and I can't find any solutions to this problem. Any suggestions or advice is welcome.
I am now deploying a django test project on aws-ec2 and the AMI is Ubuntu18.04 with Python 3.6, Django 2.1, Apache2.
The project is under /var/www/Project and I am trying to add the setting to apache.conf.
The project is simply generated by django-admin startproject Project and I want make sure that when hit the public IP provided by the instance, it should show up the django default page.
WSGIDaemonProcess ubuntu processes=2 threads=12 python-path=/var/www/Project
WSGIProcessGroup ubuntu
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIScriptAlias / /var/www/Project/Project/wsgi.py
<Directory /var/www/Project/Project>
Require all granted
</Directory>
Now i got the internal server error.
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster#localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
I have tried this previously. And it seems like it only works when i use python2.7 with django 1.11.
WSGIScriptAlias / /var/www/Project/Project/wsgi.py
WSGIPythonPath /var/www/Project
<Directory /var/www/Project/Project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
what's wrong with my conf file?
I finally come up with the following solution.
If you are using Apache2, Python2 and Ubuntu18.04 LTS, you can change the apache2.conf file by adding the following:
WSGIScriptAlias / [path_to_wsgi.py]
WSGIPythonPath [path_to_project]
<Directory [path_to_project]>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
If you want to use the latest Django 2+ version, change the /etc/apache2/sites-available/000-default.conf which is the settings for HTTP port 80. (000-default.conf file can't contains WSGIPythonPath in virtualhost)
<VirtualHost *:80>
ServerAdmin webmaster#localhost
Alias /static [path_to_static_folder]
<Directory [path_to_static_folder]>
Require all granted
</Directory>
<Directory [path_to_project]>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess [name] python-home=[path_to_virtualenv] python-path=[path_to_project]
WSGIProcessGroup [name]
WSGIScriptAlias / [path_to_project_wsgi.py]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I follow the tutorial http://docs.django-cms.org/en/develop/introduction/plugins.html, when I install the Polls App as indicated it is visible on 8000 port But not in WSGI/Apache mode (error message no module polls). To see the APP polls I need to copy Polls application files in the default root directory. Idem with the Aldryn Blog News. I guess I have to specify some more PATH in wsgi mode to help Python to find the modules. Where and how to do that in my Virtualenv, to be also effective when I deploy all the stuff on a remote platform ?
Thanks for any help
Thank you for your interest. IMHO I don't think the problem is on APACHE configuration, everything is OK and DjangoCMS works without polls. Herinafter the conf file, the domain is a local virtual one.
DocumentRoot "/var/www/djangocms"
WSGIScriptAlias / /var/www/djangocms/default/wsgi.py
ServerName djangocms.net
Alias /static/ /var/www/djangocms/default/static/
Options +ExecCGI
Order Allow,Deny
Allow from All
ErrorLog "logs/errordjangocms_log"
LogLevel error
Marcel
Here is a working config i use
<VirtualHost *:80>
ServerName iot.mydomain.com
ServerAlias iot
WSGIDaemonProcess iot.local python-path=/home/name/PycharmProjects/iotdata
WSGIProcessGroup iot.local
WSGIScriptAlias / /home/name/PycharmProjects/iotdata/iotdata/wsgi.py process-group=iot.local
#WSGIPythonPath /home/name/PycharmProjects/iotdata
Alias /static/ /home/name/PycharmProjects/iotdata/static/
<Directory /home/name/PycharmProjects/iotdata>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /home/name/PycharmProjects/iotdata/static>
Require all granted
</Directory>
</VirtualHost>
This below is the conf file for https://github.com/treeio/treeio
I used this method: http://goo.gl/KTdlUT , to configure treeio to my Azure Based Ubuntu VM but still it says: Forbidden You don't have permission to access / on this server.)
<virtualhost *:80>
ServerAdmin abcd#xyz.com
ServerName abcd.net
ServerAlias abcd.net
DocumentRoot "/home/User/treeio"
<Directory /home/Userk/treeio/>
<Directory /home/User/treeio/>
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess treeio.djangoserver processes=2 threads=15 display-name=%{GRO$
WSGIProcessGroup treeio.djangoserver
WSGIScriptAlias / /home/User/treeio/wsgi
ErrorLog "/home/User/treeio/log/error.log"
CustomLog "/home/User/treeio/log/access.log" combined
</virtualhost>
It seems like some configurations prefer Django projects to be installed in the /var/www/ directory, even though up until now the home folder had been the recommended location. This seems to make sense from a security perspective.
In addition, Microsoft has the simplest step-by-step instructions which actually work with Unbunto 14.04 in Azure:
http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-python-django-web-app-linux/
I am trying to give a Domain name and run multiple django projects on my apache
<VirtualHost first.site.com:80>
ServerName first.site.com
WSGIDaemonProcess first
WSGIScriptAlias / /opt/project/first/first/wsgi.py process-group=first application-group=%{GLOBAL}
ErrorLog ${APACHE_LOG_DIR}/error.log
<Directory /opt/project/first/first>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost second.site.com:80>
ServerName second.site.com
WSGIDaemonProcess second
WSGIScriptAlias / /opt/project/second/second/wsgi.py process-group=second application-group=%{GLOBAL}
ErrorLog ${APACHE_LOG_DIR}/error.log
<Directory /opt/project/second/second>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
but, second website don't work.
You don't have permission to access / on this server.
Any advice is much appreciated.
Thanks
Are all directories from / down to the directory where the WSGI script files are readable to the Apache user? That is the main reason why you get this error.
Updating Virtual Host Settings from Apache 2.2 to Apache 2.4
Apache 2.2
Order allow,deny
Allow from all
Apache 2.4
Require all granted