2016-11-27 116 views
0

我在設置apache2後面的uwsgi時遇到問題。 這裏是我的系統: 「你好」uwsgi和apache2問題

$ lsb_release -a 
No LSB modules are available. 
Distributor ID: Ubuntu 
Description: Ubuntu 12.04.5 LTS 
Release:  12.04 
Codename:  precise 

$ apache2 -v 
Server version: Apache/2.4.20 (Ubuntu) 

$ uwsgi --version 
2.0.14 

$ cat /etc/init/uwsgi.conf 
description "uWSGI Emperor" 
start on runlevel [2345] 
stop on runlevel [!2345] 
respawn 
exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals/ --logto /var/log/uwsgi.log 

$ python --version 
Python 2.7.3 

隨着

$ cat ~/myapp/wsgi.py 
def application(environ, start_response): 
    start_response('200 OK', [('Content-Type', 'text/html')]) 
    return ["<h1 style='color:blue'>Hello There!</h1>"] 

$ cd ~/myapp 
$ uwsgi --socket 0.0.0.0:8081 --protocol=http -w wsgi 

我可以瀏覽到http://example.com:8081,看到了測試頁面。所以,我假設uwsgi工作正常。不過,我希望把uwsgi背後的Apache2,但whenenver我嘗試

$ a2enmod uwsgi 

,並重新啓動的Apache2我得到一個錯誤,我不能做的意義:

$ service apache2 restart 
* Restarting Apache httpd web server apache2     [fail] 
* The apache2 configtest failed. 
Output of config test was: 
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: 
Syntax error on line 1 of /etc/apache2/mods-enabled/uwsgi.load: 
Cannot load /usr/lib/apache2/modules/mod_uwsgi.so into server: 
/usr/lib/apache2/modules/mod_uwsgi.so: cannot open shared object file: 
No such file or directory 
Action 'configtest' failed. 
The Apache error log may have more information. 

誰能幫我這個?我已經搜索了幾個小時,但我無法找到幫助我的合成..

非常感謝您提前。

PS:哦,我在apache錯誤日誌中找不到任何相關信息。

回答

0

如果有人有興趣,這裏就是我得到了它的工作:

而不是使用uwsgi_mod,我只是代理一切都在我的Apache配置:

<VirtualHost *:80> 
    ... 
    ProxyPreserveHost On 
    ProxyRequests Off 
    ProxyVia Off 
    ProxyPass/http://127.0.0.1:8081/ 
    ProxyPassReverse/http://127.0.0.1:8081/ 
</VirtualHost> 

的uwsgi命令將與運行uwsgi --ini uwsgi.ini其中uwsgi.ini將包含以下行

[uwsgi] 
chdir = path/to/my/project 
http-socket = :8081 
module = wsgi:application 
... 

這樣,我並不需要運行uwsgi_mod和一切正常。希望有一天能幫助任何人。