I’m trying to run Django 1.3.1 on apache 2.6.6, using mod_wsgi, CentOS 6.
I have change httpd.conf file:
WSGIPythonPath /var/www/vhosts/domain.co.uk
<VirtualHost *:80>
#ServerName domain.co.uk
ServerName 46...233
##DocumentRoot /var/www/vhosts/domain.co.uk/httpdocs
LogLevel debug
ErrorLog /var/www/vhosts/domain.co.uk/logs/error.log
CustomLog /var/www/vhosts/domain.co.uk/logs/access.log combinedio
HostnameLookups Off
UseCanonicalName On
WSGIScriptAlias / /var/www/vhosts/domain.co.uk/sites/somod/apache/django.wsgi
WSGIDaemonProcess somod:80 user=somod group=psaserv processes=1 threads=1
WSGIProcessGroup somod:80
#WSGIPythonPath /var/www/vhosts/domain.co.uk
Alias /robots.txt /var/www/vhosts/domain.co.uk/sites/templates/robots.txt
Alias /favicon.ico /var/www/vhosts/domain.co.uk/sites/media/favicon.ico
<Directory "/var/www/vhosts/domain.co.uk/httpdocs">
AllowOverride None
Options -ExecCGI -Includes -FollowSymLinks -Indexes
Order allow,deny
Allow from all
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
</Directory>
<Directory "/var/www/vhosts/domain.co.uk/sites">
AllowOverride None
Options +ExecCGI -Includes +FollowSymLinks -Indexes
Order allow,deny
Allow from all
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
</Directory>
Alias /media "/var/www/vhosts/domain.co.uk/media"
<Location "/media/">
SetHandler None
</Location>
</VirtualHost>
So I paste my apache config (only code which I add). This is in /etc/httpd/conf/httpd.conf.
I can restart apache now without any errors, but website isn’t visible yet. Unfortunately I couldn’t run sudo a2enmod wsgi, I’m using cenos 6 and a2enmod isn’t available. But I’m sure it has been install, because I order vps with it, just not sure it’s running. I will check it.
My question now is what url should be to view website? Is it value form ServerName, or ip address/ServerName value? Can I use ip address in? Because I want run website and make sure everything is ok before I switch domain, because right now under this domain is website which I’m moving to new server.
Many thanks for help
Don’t know what you’re doing, but here’s a sample config for you brother:
Create this file and name it
yoursiteand put it under/etc/apache2/sites-available. Then runsudo a2ensite yoursiteand it will be palced unsites-enabled, too.This depends on:
apache2libapache2-mod-wsgiMake sure wsgi is enabled by running
sudo a2enmod wsgi.I recommend having the file in your version control repo, and then symlinking it from
/etc/apache2/sites-available.Also note that I’ve created an alias for /static/ and if you want to use that, make sure you run
sudo ./manage.py collectstatic. This will place all static files in/var/www/yoursite/yourproject/static.Good luck.