开发者

How can I have a Django application on my main domain, and a PHP application on a subdomain?

开发者 https://www.devze.com 2023-03-13 22:06 出处:网络
I have a Django application hosted on my main domain (example.com), and I now need to host a PHP application on a subdomain (forum.example.com).

I have a Django application hosted on my main domain (example.com), and I now need to host a PHP application on a subdomain (forum.example.com).

In the directory of the main domain, I have the following .htaccess entries:

SetHandler mod_python
PythonPath "/home/.../apps/example'] + sys.path"
PythonOption mod_python.importer.path "['/home/vlive/python']+ sys.path"
PythonHandler django.core.handlers.modpython

#PythonDebug On
SetEnv DJANGO_SETTINGS_MODUL开发者_运维问答E example.settings
SetEnv PYTHON_EGG_CACHE /tmp/egg-cache

At present, when I load the subdomain (forum.example.com) I still see the main site (example.com).

How can I fix this?


You need to set up your subdomains via the VirtualHost directive and only add the mod_python / mod_wsgi handler in one of the VirtualHosts.

You said you loaded the subdomain and it still shows the main site. Would you mind showing us your Apache's site configuration?


The most common reason for wrong VirtualHost being selected is a missing NameVirtualHost directive that matches host/port qualifier specified in VirtualHost directive.

What NameVirtualHost directive do you have set? What is the argument to the two VirtualHost configurations?

The general layout would be:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName example.com
...
</VirtualHost>

<VirtualHost *:80>
ServerName forum.example.com
...
</VirtualHost>

These would usually be in the same file for a Linux Apache distribution though.

What have you used?


As Graham noted, most probably you have wrong VirtualHost configuration.

Double check that there is two different VH with right ServerName and that you don't use * (wildcard) in ServerName and ServerAlias that may overlap with subdomain or it goes AFTER subdomain. Apache only search for first VH that matches, so if you have something like *.example.com above any other subdomain like forum.example.com would not work.

Also mod_wsgi is recommended by django documentation, consider switching to it.

0

精彩评论

暂无评论...
验证码 换一张
取 消