Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Hello all am new to django and all its goodies ill like to know how to set up something like this with nginx and gunicorn for a django project thanks
virtual host1
<VirtualHost *:80>
ServerName project1.com
ServerAlias www.project1.com
ServerAdmin info#project1.com
Alias /static/ /path/to/project1/project1/static/
Alias /media/ /path/to/project1/project1/media/
ErrorLog /path/to/project1/error.log
CustomLog /path/to/project1/access.log combined
WSGIDaemonProcess project1.com processes=2 threads=15 display-name=%{GROUP} python-path=/path/to/project1:/path/to/project1/local/lib/python2.7/site-packages
WSGIProcessGroup project1.com
WsgiScriptAlias / /path/to/project1/project1/wsgi.py
<Directory /path/to/project1/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
virtual host 2
<VirtualHost *:80>
ServerName project2.com
ServerAlias www.project2.com
ServerAdmin info#project2.com
Alias /static/ /path/to/project2/project2/static/
Alias /media/ /path/to/project2/project2/media/
ErrorLog /path/to/project2/error.log
CustomLog /path/to/project2/access.log combined
WSGIDaemonProcess project2.com processes=2 threads=15 display-name=%{GROUP} python-path=/path/to/project2:/path/to/project2/local/lib/python2.7/site-packages
WSGIProcessGroup project2.com
WsgiScriptAlias / /path/to/project2/project2/wsgi.py
<Directory /path/to/project2/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Take a look at http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/ - that should be enough to get you started with nginx and gunicorn.
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.
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!
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Question
I have tried and read all sort of questions on this topic but can't get this to work. I am trying to use a virtual host to access a different folder than the default /www that wamp uses. But i keep getting an error;
Forbidden
You don't have permission to access / on this server.
I can access local host and phpmyadmin perfectly but not any virtual hosts that i create.
httpd-vhosts.conf
# Virtual Hosts
#
# Required modules: mod_log_config
Listen 80
<VirtualHost *:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Program Files (x86)\2. Apps\Wamp\www"
ServerName localhost
<Directory "C:/wamp/www">
Options Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Users\Chris\Documents\CBull Files\Projects\Tests"
ServerName test.lo
ServerAlias test.lo
<directory "C:\Users\Chris\Documents\CBull Files\Projects\Tests">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
hosts
# Wamp Server Settings
127.0.0.1 localhost
127.0.0.1 test.lo
httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Thanks
Thanks for everyone's input, there were two main problems
I installed wamp into a folder which was nested in a folder who's name had a space in so c:/folder/folder with a space/wamp/ which i have since been told is bad practice, if anyone knows why please tell.
The were issues with the internet protocol, namely ipv6, so solve this you need to ensure wamp only uses ipv4, inside httpd.conf find Listen 80 and change to Listen 0.0.0.0:80. Again i'm not sure what this does so if anyone knows please post below.
I hope this helps anyone else stuck.
Try replacing the following block with:
<VirtualHost test.lo:80>
ServerAdmin admin#localhost.com
DocumentRoot "C:\Users\Chris\Documents\CBull Files\Projects\Tests"
ServerName test.lo
ServerAlias test.lo
<directory "C:\Users\Chris\Documents\CBull Files\Projects\Tests">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</directory>
</VirtualHost>
I have made just one change: <VirtualHost *:80> replaced with <VirtualHost test.lo:80>.
Note: You had </VirtualHost> missing in the end.
So I may be missing a bit of a fundamental understanding on what's going on here, but I cannot get this to work. I have two django websites, and I want to be able to host them both on the same box, both on port 80. Is there some magic to get this to work properly? Here's what my sites-available/default file looks like:
<VirtualHost *:80>
WSGIScriptAlias / /path/to/proj/apache/django.wsgi
AliasMatch ^/([^/]*\.css) /path/to/proj/static/
Alias /media /path/to/proj/static/
Alias /static/ /path/to/proj/static/
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
WSGIScriptAlias / /path/to/otherproj/apache/django.wsgi
ErrorLog ${APACHE_LOG_DIR}/error2.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Obviously this doesn't work since navigating to the site hits the first one and it never goes to the second one. So my question is, how do I set this up so I can host 2 web sites on port 80. Perhaps I could do like localhost/site1 and localhost/site2 and figure it out that way, but no matter what I try I can't seem to get that to work.
I have played with the ServerName property, but I don't really understand how that can work, setting it doesn't seem to change that hitting the ip of that machine only shows the first website, and I don't know where using the ServerName affects anything.
Any suggestions, or let me know if I need to give more information.
Also note they both work if I change the second one to port 8080, but when doing that I can't seem to put a domain name on top of myip:8080.
I don't think there is anything to explain here. You just need to actually specify the name of each virtual domain.
Note:NameVirtualHost is deprecated
<VirtualHost *:80>
ServerName site1.ltd
WSGIScriptAlias / /path/to/proj/apache/django.wsgi
AliasMatch ^/([^/]*\.css) /path/to/proj/static/
Alias /media /path/to/proj/static/
Alias /static/ /path/to/proj/static/
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName site2.ltd
WSGIScriptAlias / /path/to/otherproj/apache/django.wsgi
ErrorLog ${APACHE_LOG_DIR}/error2.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I followed the django docs on how to deploy django 1.4 to apache using mod_wsgi https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ on mac osx lion and when I add the WSGIPythonPath directive apache cant restart .Yet without it my app is non existant in the path . In the log I am getting an error that reads
WSGIPythonPath cannot occur within VirtualHost section
here is what my virtual host config looks like
<VirtualHost *:80>
ServerAdmin jmured#gmail.com
DocumentRoot "/Users/jamo/code/work/projects/bfpd/fapp"
ServerName bfpd.dev
ServerAlias bfpd.dev
ErrorLog "/private/var/log/apache2/bfpd.dev-error_log"
CustomLog "/private/var/log/apache2/bfpd.dev-access_log" common
Alias /static/ /Users/jamo/code/work/projects/bfpd/fapp/fapp/static/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp/static>
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
IndexOptions FancyIndexing
</Directory>
WSGIScriptAlias / /Users/jamo/code/work/projects/bfpd/fapp/fapp/wsgi.py
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/
<Directory /Users/jamo/code/work/projects/bfpd/fapp/fapp>
Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
what am i doing wrong ???
I fixed it.
WSGIPythonPath /Users/jamo/code/work/projects/bfpd/fapp/
should be in http.conf
As mentioned in the comment by nemesisfixx, and specified by the error in your original question:
WSGIPythonPath cannot occur within VirtualHost section
Moving WSGIPythonPath outside of VirtualHost resolved Apache crashing on OS X server.
$ cat sites/0000_any_80_mysite.com.conf
WSGIPythonPath /Library/Server/Web/Data/Sites/mysite/django-app:/Users/owen/.virtualenvs/mysite:/Users/owen/.virtualenvs/mysite/lib/python2.7/site-packages
<VirtualHost *:80>
ServerName mysite.com
ServerAdmin admin#example.com
DocumentRoot "/Library/Server/Web/Data/Sites/mysite/site"
...
WSGIScriptAlias /api /Library/Server/Web/Data/Sites/mysite/django-app/mysite/wsgi.wsgi
...
<VirtualHost>
It took a lot of putzing for me to get the paths correct (including full path to site-env, which I initially thought would be included automatically after adding the virtualenv top level).