好的,所以我一直在尋找幾個小時,這讓我難倒了。主要和測試版WSGI應用程序
我有一個應用程序還沒有在生產中,我的客戶希望它分裂成不太穩定和更穩定。因此,我選擇將dev版本移動到/var/www/dev
並將半穩定版本複製到/var/www/master
(直到此調試,半穩定也在/var/www
不破壞訪問)。這個想法是domain.com
將永遠是功能性的,新的東西/測試將在dev.domain.com
。
因此,according the apache docs,我現在有兩個virtualhosts:
<VirtualHost _default_:443>
ServerAdmin [email protected]
DocumentRoot "/var/www/master"
ServerName domain.com
SSLEngine on
# [ssl stuff]
Header add Strict-Transport-Security "max-age=15768000"
WSGIDaemonProcess master_wsgi user=www-data group=www-data
WSGIScriptAlias /master "/var/www/master/src/main.py"
# [ Aliases .... ]
<Directory "/var/www/master/src">
Options +ExecCGI
AddHandler wsgi-script .py
Order allow,deny
Allow from all
</Directory>
<Directory "/var/www/master">
Options +ExecCGI
AddHandler wsgi-script .py
Order allow,deny
Allow from all
</Directory>
<Location /master>
# [HTTP auth stuff]
WSGIProcessGroup master_wsgi
</Location>
# modules, cache, error directories, etc
</VirtualHost>
然後同樣的事情重複,除了:
DocumentRoot "/var/www/dev"
ServerName dev.domain.com
ServerPath /dev/
和master
別名所有其他情況下,守護等,成爲dev
(我字面上做了replace-string
)。守護進程和進程組是我chasing another SO answer如果我說沒有成功的,因爲子目錄的要求(因爲顯然他們都需要在一個虛擬主機,但我不能在<Location>
指定DocumentRoot
)現在
,做到這一點,我得到的都是兩個文件列表。正確的文件列表,介意,但只是文件列表。 如果我去任一個,並將WSGIScriptAlias
更改爲/
(舊副本),它可以很好地從該python文件中正常運行(儘管它當然意味着開發者的東西實際上指向了舊的模板,所以這並不好因爲我不能更改模板,只是腳本,因爲templateDir = os.path.realpath(os.path.dirname(os.path.realpath(__file__)) + "/../templates/") + "/"
始終是/var/www/templates
)。
這不是錯誤,它只是提供文件列表,所以它指向正確的位置,但WSGIScriptAlias沒有做它應該做的事情?我錯過了什麼?
如果它是相關的,這裏是在httpd.conf
相關VH之前的東西,但我對此表示懷疑:
LoadModule wsgi_module modules/mod_wsgi.so
WSGICallableObject app
WSGIPythonHome /usr/local/bin/python
NameVirtualHost *:80
<VirtualHost *:80>
ServerName domain.com
Redirect permanent/https://domain.com/
## Heading ##</VirtualHost>
是的,其他別名目錄中有靜態文件資產。 python路徑也是一個目錄(該目錄中的二進制文件是'python')。 理由是,最終,每個子目錄本質上都是git分支的一面鏡子(發佈版本會有一些這樣的組織變更),所以它們理想上是完全獨立的。 因此,'/ var/www/master/src'中引用的模板會引用'/ var/www/master/templates'中的模板,而'dev'也是相同的。這個想法是看看'main.py'的目錄,然後選擇相關的模板。 – 2014-08-28 03:38:02
雖然我想,現在你提到它了,如果我把這個應用放在'/'中,我可以指向一個目錄,如果它要求一個子域名的話,而另一個如果不是的話。 host_url'在一些分裂和檢查,但我真的很快就擁有了它現在的所有自足(見上面有關釋放的警告)。它們是同一件事的兩個版本,並不是兩個獨立的應用程序 - 它們應該像這樣。 – 2014-08-28 03:55:40
你指出我在正確的軌道上。稍後進行一些清理和小修復,它開始正常工作。謝謝! – 2014-08-28 04:34:04