溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

ubuntu fastcgi怎么配置

發(fā)布時間:2022-10-12 11:53:23 來源:億速云 閱讀:135 作者:iii 欄目:服務(wù)器

這篇“ubuntu fastcgi怎么配置”文章的知識點大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“ubuntu fastcgi怎么配置”文章吧。

lighttpd 的配置腳本在 /etc/lighttpd/lighttpd.conf,采用默認值缺省的server.document-root路徑是 /var/www
具體實施步驟:
1) 首先實現(xiàn)一個 python 腳本

touch /var/www/hello.py
chmod 755 /var/www/hello.py
vim /var/www/hello.py

復(fù)制代碼 代碼如下:

#!/usr/bin/env python
import web
urls = (
'/hello', 'hello', '/hello/(.*)$', 'hello'
)
app = web.application(urls, globals())
class hello:
def get(self, name=none):
if not name:
name = 'world'
return 'hello, ' + name + '!'
if __name__ == "__main__":
app.run()


2) 配置 fastcgi
vim /etc/lighttpd/conf-available/10-fastcgi.conf

復(fù)制代碼 代碼如下:

server.modules += ( "mod_fastcgi" )
fastcgi.server = ("/hello" =>
((
"bin-path" => "/var/www/hello.py",
"socket" => "/tmp/hello.py.socket",
"max-procs" => 1,
"bin-environment" => (
"real_script_name" => ""
),
"check-local" => "disable"
))
)


3) 啟用 fastcgi
lighttpd-enable-mod fastcgi
4) 重啟 lighttpd
/etc/init.d/lighttpd force-reload
5) 在瀏覽器中驗證結(jié)果
http://localhost/hello 得到的結(jié)果是 hello, world!
http://localhost/hello/sendltd 得到的結(jié)果是 hello, sendltd!
6) 補充說明
這樣配置靜態(tài)頁面和動態(tài)頁面可以共存,不需要配置 mod_rewrite。
每次修改 python 腳本都要重啟lighttpd。
可以在 10-fastcgi.conf 中 配置多個sever,但是socket不能相同 。

以上就是關(guān)于“ubuntu fastcgi怎么配置”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對大家有幫助,若想了解更多相關(guān)的知識內(nèi)容,請關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI