I have a Wordpress blog, let's say that it's address is like yakblog.org
and it is a Wordpress blog installed on Ubuntu 12.04 server.
Now, I would like to run a Django application as one of the sub page of my blog, so I could access it like this: yakblog.org/testproject
.
Here's the EXACT situation: https://community.webfaction.com/questions/17758/wordpress-on-root-domain-django-in-subdirectory (although I don't use webfaction). Also, I tried the solution given here: https://stackoverflow.com/questions/26013379/run-django-project-inside-wordpress-on-suburl-of-wordpress-using-apache-and-mod, but then I have a Wordpress message: This is somewhat embarrassing, isn’t it?
However, I encountered some problems doing this, and I'm not sure if it's possible with my set up. Ok, so here's what I did to achieve what I need:
- Created a Django project at
/var/www/yak/public_html
, so in/var/www/yak/public_html
I have such structure:
Then, added a line
WSGIPythonPath /var/www/yak/public_html/testproject
to my/etc/apache2/apache2.conf
fileHere's my virtual host code:
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName yakblog.org/testproject ServerAlias www.yakblog.org/testproject #RedirectPermanent / http://yakblog.org/testproject WSGIScriptAlias /testproject /var/www/yak/public_html/testproject/testproject/wsgi.py DocumentRoot /var/www/yak/public_html/testproject/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/yak/public_html/testproject/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /home/yak/logs/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /home/yak/logs/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
The problem is when entering http://yakblog.org/testproject
I can't see my application, but only the list of files in this directory:
The problem is here
<Directory /var/www/yak/public_html/testproject/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
You are showing the content of the folder, not running the actual application.
You can look the documentation to setup your server https://docs.djangoproject.com/es/1.9/howto/deployment/wsgi/modwsgi/
What you need to do is install mod_wsgi and add this to
Where you only serve wsgi.py and wsgi.py it's used to serve your application.