2

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:

  1. Created a Django project at /var/www/yak/public_html, so in /var/www/yak/public_html I have such structure:

enter image description here

  1. Then, added a line WSGIPythonPath /var/www/yak/public_html/testproject to my /etc/apache2/apache2.conf file

  2. Here'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:

enter image description here

1
  • Likely that VirtualHost isn't used. It should be within the same VirtualHost as your Wordpress application is setup. BTW. That you can see the code shows why you should NEVER put your Django project code under DocumentRoot directory. It should go somewhere else. Also use daemon mode of mod_wsgi and not embedded mode. blog.dscpl.com.au/2012/10/… Aug 2, 2015 at 4:01

1 Answer 1

1

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

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Where you only serve wsgi.py and wsgi.py it's used to serve your application.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .