5
我遇到了問題。我有一個Python腳本。你可以稱之爲CGI腳本。它在Apache2下工作正常,但在我關閉系統之前只剩下一個它永遠運行。新系統使用nginx。 我在配置虛擬主機的解決方案上搜索時,按照許多人的建議配置了uwsgi,以便此腳本運行。 我已經使用uwsgi wiki上的第一個例子來確認我已正確配置nginx,並且它可以與uwsgi進行通信。像魅力一樣工作。nginx uwsgi和cgi python腳本
現在我的併發症:
我的劇本是前一段時間寫的,而不是專爲WSGI,我也想/可以重寫它。
所以我爲uwsgi安裝了cgi模塊並嘗試使用它。我得到的是502錯誤。沒有任何正在執行的uwsgi。
這裏是我的配置我使用這個應用程序:
[uwsgi]
plugins = cgi
socket = 127.0.0.1:9010
cgi = /=/usr/share/test/
cgi-allowed-ext = .py
cgi-helper = .py=python
這裏是代碼我在index.py(測試腳本):
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "<html><body><h1>It works!</h1></body></html>"
我嘗試測試uwsgi與以下命令:
/usr/sbin/uwsgi --http :9011 --ini /etc/uwsgi/test.ini --master
,這裏是輸出我得到:
[uWSGI] getting INI configuration from /etc/uwsgi/test.ini
*** Starting uWSGI 1.1.2 (64bit) on [Fri Apr 20 15:26:33 2012] ***
compiled with version: 4.4.6 20110731 (Red Hat 4.4.6-3) on 19 April 2012 15:09:37
current working directory: /home/user
detected binary path: /usr/sbin/uwsgi
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread mutexes
uWSGI http bound on :9011 fd 3
uwsgi socket 0 bound to TCP address 127.0.0.1:9010 fd 6
your server socket listen backlog is limited to 100 connections
*** Operational MODE: single process ***
initialized CGI mountpoint:/= /usr/share/test/
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 6727)
spawned uWSGI worker 1 (pid: 6728, cores: 1)
spawned uWSGI http 1 (pid: 6729)
-- unavailable modifier requested: 0 --
-- unavailable modifier requested: 0 --
-- unavailable modifier requested: 0 --
-- unavailable modifier requested: 0 --
問題在哪裏?請幫忙。
在此先感謝。
偉大的你找到了解決方案,但是最好是將它作爲答案添加它,這使得閱讀帖子的其他人更清楚。謝謝! – CharlesB 2012-04-20 20:13:28
@CharlesB這是我的計劃,但它讓我等了7個小時。當我找到解決方案時,我想馬上發佈。我會在今天晚些時候或明天晚些時候將其發表意見。謝謝。 – sashk 2012-04-21 00:15:59
這是一種提醒,這樣你就不會忘記你可以知道addd的答案:) – CharlesB 2012-04-21 07:13:25