我有一個網上商店,其中包含主頁面和商店頁面。現在這個主頁和商店頁面實際上是兩個不同的項目,所以爲了讓他們在線,我必須運行兩個django實例。無法在子域上運行apache的django項目
現在的事情是,我想擁有www.setakshop.ir上的主頁和shop.setakshop.ir上的商店。事情是,在設置必要的設置後,shop.setakshop.ir和setakshop.ir都指向主頁面!我只能通過setakshop.ir:8000看到這個店的頁面,這是我預期的Apache代理它shop.setakshop.ir 我所服務的DNS我,這裏是我的DNS設置:
;
; BIND data file for setakshop.ir
;
$TTL 3h
@ IN SOA ns1.setakshop.ir. admin.setakshop.ir. (
1 ; Serial
3h ; Refresh after 3 hours
1h ; Retry after 1 hour
1w ; Expire after 1 week
1h) ; Negative caching TTL of 1 day
;
@ IN NS ns1.setakshop.ir.
@ IN NS ns2.setakshop.ir.
setakshop.ir. IN MX 10 mail.setakshop.ir.
setakshop.ir. IN A xx.xx.xx.xx
ns1 IN A xx.xx.xx.xx
ns2 IN A xx.xx.xx.xx
www IN CNAME setakshop.ir.
mail IN A xx.xx.xx.xx
ftp IN CNAME setakshop.ir.
shop IN A xx.xx.xx.xx
當運行
nslookup shop.setakshop.ir
我收到了有效的答覆。所以我認爲DNS設置實際上很好。
現在我懷疑的另一件事是我的apache設置。我懷疑我沒有設置正確的代理設置。這裏是:
<VirtualHost *:80>
WSGIDaemonProcess main python-path=/var/www/setak:/var/www/setak/setakenv/lib/python2.7/site-packages
WSGIProcessGroup main
WSGIScriptAlias//var/www/setak/setakenv/main/ashop/ashop/ashop/wsgi.py
ServerAdmin [email protected]
ServerName www.setakshop.ir
ProxyPass/http://www.setakshop.ir:8001/
ProxyPassReverse/http://www.setakshop.ir:8001/
Alias /media/ /var/www/setak/setakenv/main/ashop/ashop/static/media/
Alias /static/ /var/www/setak/setakenv/main/ashop/ashop/static/
<Directory /var/www/setak/setakenv/main/ashop/ashop/static>
Order allow,deny
allow from all
</Directory>
<Directory /var/www/setak/setakenv/main/ashop/ashop/static/media>
Order allow,deny
allow from all
</Directory>
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/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>
<VirtualHost *:8080>
WSGIDaemonProcess setak python-path=/var/www/setak:/var/www/setak/setakenv/lib/python2.7/site-packages
WSGIProcessGroup setak
WSGIScriptAlias//var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/wsgi.py
ServerAdmin [email protected]
ServerName shop.setakshop.ir
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass/http://shop.setakshop.ir:8000
ProxyPassReverse/http://shop.setakshop.ir:8000
Alias /robots.txt /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/static/robots.txt
Alias /media/ /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/public/media/
Alias /static/ /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/public/static/
<Directory /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/public/static>
Order allow,deny
allow from all
</Directory>
<Directory /var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox/public/media>
Order allow,deny
allow from all
</Directory>
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/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>
現在我沒有得到我在做什麼錯在這裏! 我同時運行使用下面的命令的項目:
./manage.py runserver 0.0.0.0:8000
./manage.py runserver 0.0.0.0:8001
誰能告訴我什麼,我做錯了什麼?
在此先感謝。
我甚至不知道從哪裏開始形式。首先,django服務器不適合生產:「runserver只適用於本地機器上的開發,不適用於公開Web上的暴露。」 https://docs.djangoproject.com/en/1.8/howto/deployment/ – Wtower
否,該教程甚至沒有提及使用Apache作爲代理。而且它提到runserver的唯一時間就是測試Django是否正確設置。 –