我是一個新手到整個網站的東西Django項目......真的很感激,如果你能在這裏給出一些幫助......使用Apache供職於RHEL(503錯誤)
我想要做的是什麼在遠程服務器上託管Django項目(紅帽,CentOS版本6.5)
我一直在使用的開發服務器和端口8000的遠程服務器上運行的項目的測試:
python manage.py runserver *.*.*.*:8000 --insecure
在這情況下,該網站工作正常,可從其他機器訪問。
0 errors found
September 04, 2014 - 08:13:03
Django version 1.6.4, using settings 'mysite.settings'
Starting development server at http://*.*.*.*:8000/
Quit the server with CONTROL-C.
現在我想把它放在生產環境中,並且我選擇了使用Apache http server和mod_wsgi。我已經安裝並激活了httpd和wsgi。我httpd.conf配置文件更改爲:
Listen *:80 (I've also tried Listen *:8000 and Listen (IP address):8000)
#DocumentRoot "/var/www/html"
DocumentRoot "/testsite" (I put a plan html file under the directory just for test)
ServerName <here is the url of the site,with no port number>
然而,當我嘗試打開我總是有一個503錯誤的網頁:
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime
or capacity problems. Please try again later.
Apache/2.2.3 (CentOS) Server at <site url> Port 80
我試了幾件事情(1)檢查什麼是使用的端口80:
~# sudo lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 28732 root 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
httpd 28734 apache 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
httpd 28735 apache 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
httpd 28736 apache 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
httpd 28737 apache 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
httpd 28738 apache 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
httpd 28739 apache 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
httpd 28740 apache 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
httpd 28741 apache 4u IPv6 19802111 0t0 TCP *:http (LISTEN)
~# service httpd status
httpd (pid 28732) is running...
(2)重新啓動Apache服務器:
service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
(3)在/ var/www/html/testsite中放置一個普通的.html文件,用於測試的DocumentRoot目錄。
(4)我試圖運行(如8008,8001和80)
e.g. python manage.py runserver *.*.*.*:8008 --insecure
0 errors found
September 04, 2014 - 07:56:18
Django version 1.6.4, using settings 'mysite.settings'
Starting development server at http://*.*.*.*:8008/
Quit the server with CONTROL-C.
在不同的端口上的django如上所示,在它看起來像它在工作的終端,但我不能連即使使用開發服務器也可以從遠程機器訪問網站。我嘗試了不同的端口號,但只能使用端口8000。但是,當我更改端口號時,爲什麼我可以在本地主機上打開網頁?例如127.0.0.1:8008或127.0.0.1:8080將工作。
我想這可能是防火牆設置,然後我去到/ etc/SYSCONFIG/iptables的,我發現在網絡部分,只有一條線:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8000 -j ACCEPT
然後我又增加了線測試:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8001 -j ACCEPT
然後用端口8001再次試圖發展再次,它看起來像是沃金的遠程服務器上,但不能從遠程計算機訪問。
對不起,如果我把這個問題弄糊塗了,如果我問了一些非常愚蠢的問題。現在,我有三個問題,我真的不明白。首先,503錯誤真的讓我惱火。即使它顯示Apache服務器正在運行(重啓httpd是OK),實際上沒有任何顯示......其次,當使用開發服務器時,爲什麼我只能使用端口8000而不是其他任何東西?最後,在503錯誤消息中,即使在配置文件中將偵聽端口更改爲8000後,它仍顯示apache在端口80上運行,爲什麼?
感謝任何幫助!
mod_wsgi和FASTCGI機制是完全分離的。您不需要配置兩者,而應該只選擇一個。 FASTCGI雖然是最不喜歡的選項,mod_wsgi通常是更好的選擇。開發服務器不需要運行。對不起,但發現答案混亂,所以我想澄清。 – 2014-09-04 16:01:53
@GrahamDumpleton,謝謝!添加缺少的「或」字:) – 2014-09-04 17:23:44