最近都在玩 Python 反而 php 少碰非常多,這是一個在 Ubuntu 下架設 apache2 及 wsgi 的紀錄。因為在本機上測試東西,架個在 localhost 上這樣就不用一直下 reload 指令...(:-p)
* 安裝相關套件
1
2
3
4 | $ sudo apt-get install apache2 libapache2-mod-wsgi
#安裝套件
$ sudo a2enmod wsgi
#載入wsgi
|
* 設定相關檔案
這個部份可以在/etc/apache2/sites-available/
中新增一個 virtualhost 設定, 因為我需要開在別的 port 上所以以下是我的設定檔,僅供參考:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | Listen 8888
NameVirtualHost *:8888
<VirtualHost *:8888>
ServerAdmin webmaster@localhost
DocumentRoot /home/renn999/Program/illust
WSGIScriptAlias / /home/renn999/Program/illust/test.wsgi
WSGIDaemonProcess illust user=renn999 group=renn999 threads=5
<Directory /home/renn999/Program/illust>
WSGIProcessGroup illust
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
|
相關設定檔可見[http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives],最後連結virtual-hostfile
1 | $ sudo a2ensite <virtualhost-file>
|
* 啟動
如果是出現 500 error 請參照 error.log 修正