2016-08-31 137 views
0

我想在Google Compute Engine Debian8 VM上設置我的Django-python項目。我在/etc/apache2/sites-available/000-default.conf & /etc/apache2/sites-available/default-ssl.conf文件中做了幾個配置更改 然後嘗試重新啓動服務器。我得到以下錯誤。卸載&重新安裝apache2也沒有解決此錯誤。有任何建議來解決這個問題?Django Python項目的Apache&mod_wsgi設置

命令:

sudo service apache2 restart 

錯誤:

Job for apache2.service failed. See 'systemctl status apache2.service' and 'journalctl -xn' for details. 

命令:

sudo systemctl status apache2.service -l 

錯誤:

apache2.service - LSB: Apache2 web server 
    Loaded: loaded (/etc/init.d/apache2) 
    Active: active (exited) since Wed 2016-08-31 05:08:43 UTC; 3min 37s ago 
    Process: 3539 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS) 
    Process: 3521 ExecReload=/etc/init.d/apache2 reload (code=exited, status=1/FAILURE) 
    Process: 3546 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS) 

Unit apache2.service entered failed state. 
Starting LSB: Apache2 web server... 
Starting web server: apache2(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 
no listening sockets available, shutting down 
AH00015: Unable to open logs 
Action 'start' failed. 
The Apache error log may have more information. 
. 
Started LSB: Apache2 web server. 

謝謝,

回答

0

你看過錯誤嗎?它明確指出失敗的原因:

Cannot load /usr/lib/apache2/modules/mod_wsgi.so into server: /usr/lib/apache2/modules/mod_wsgi.so: cannot open shared object file: No such file or directory

你有libapache2-mod-wsgilibapache2-mod-wsgi-python3安裝?如果你有機會到外殼可以用

sudo apt-get install libapache2-mod-wsgi 
# or for python 3 
sudo apt-get install libapache2-mod-wsgi-python3 
0

運行該命令安裝它,看看端口80上運行的進程:

sudo netstat -ltnp | grep ':80' 

輸出:

tcp  0  0 0.0.0.0:80    0.0.0.0:*    LISTEN  24482/nginx -g daem 
tcp6  0  0 :::80     :::*     LISTEN  24482/nginx -g daem 

運行接下來的兩個命令然後解決問題:

sudo kill -9 24482 
sudo service apache2 restart 

希望它可以有所幫助。

感謝,

+0

如果nginx的是作爲一種服務進行管理,你會發現它回來了啓動和nginx的和Apache會爭取拿到80端口的每個主機重新啓動的時間。你應該確保nginx沒有設置爲自動作爲服務啓動。 –

+0

好的。這怎麼能保證? – Naveen

+0

不知道。取決於您的Linux變體正在使用的管理系統。 –