43459


下記を試しても画面が白いままなのですが、どう修正したら良いでしょうか？  
・Nginxエラーは何も書き込まれていませんでした

**Q1.HTTP/1.1 200が返ってきているみたいなのですが、なぜ画面に何も表示されないのでしょうか？**

**Q2.rebuild with pcre と表示されていますが、何か関係しているでしょうか？**

* * *

**Nginxのconfファイル**

[code]

    server {
        listen       80;
        //中略
    
        location /hoge {
            include uwsgi_params;
            uwsgi_pass unix:/var/run/uwsgi/app/app.sock;
        }
    
[/code]

* * *

**hoge/hoge.ini**

[code]

    [uwsgi]
    uid = nginx
    gid = nginx
    socket = /var/run/uwsgi/app/app.sock
    chmod-socket = 777
    chdir = /var/www/中略/hoge/
    callable = application
    wsgi-file = /var/www/中略/hoge/hoge.py
    
[/code]

* * *

**hoge/hoge.py**

[code]

    def application(environ, start_response):
        start_response('200 OK', [('Content-type', 'text/html')])
        return "<html><head><title>Test</title></head><body><div>Hello</div></body></hetml>"
    
[/code]

* * *

**hoge/で下記実行**

[code]

    $ uwsgi --ini hoge.ini 
    
[/code]

・実行結果

[code]

    [uWSGI] getting INI configuration from uwsgi.ini
    *** Starting uWSGI 2.0.17 (64bit) ***
    //中略
    current working directory: /var/www/中略/hoge
    detected binary path: /usr/bin/uwsgi
    !!! no internal routing support, rebuild with pcre support !!!
    chdir() to /var/www/中略/hoge/
    *** WARNING: you are running uWSGI without its master process manager ***
    //中略
    lock engine: pthread robust mutexes
    thunder lock: disabled (you can enable it with --thunder-lock)
    uwsgi socket 0 bound to UNIX address /var/run/uwsgi/app/app.sock fd 3
    Python version: 3.6.4
    *** Python threads support is disabled. You can enable it with --enable-threads ***
    //中略
    *** Operational MODE: single process ***
    WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xe8e200 pid: 27939 (default app)
    *** uWSGI is running in multiple interpreter mode ***
    spawned uWSGI worker 1 (and the only) (pid: 27939, cores: 1)
    [pid: 27939|app: 0|req: 1/1] IPアドレス () {44 vars in 883 bytes} [日時] GET /hoge/hoge.py => generated 0 bytes in 0 msecs (HTTP/1.1 200) 1 headers in 44 bytes (75 switches on core 0)
    [pid: 27939|app: 0|req: 2/2] IPアドレス () {44 vars in 883 bytes} [日時] GET /hoge/hoge.py => generated 0 bytes in 0 msecs (HTTP/1.1 200) 1 headers in 44 bytes (75 switches on core 0)
    
[/code]


CC BY-SA 3.0
2018-04-21T10:35:54.200
43456
2018-05-19T09:40:07.103
2018-05-19T09:40:07.103
3060
7886
question
python nginx uwsgi
CentOS7 と uWSGI で、Hello world


Python 3ですよね? application関数の戻り値を文字列ではなくバイト列にしてください。

[code]

    return b'<html><body>Hello, world</body></html>'
    
[/code]


CC BY-SA 3.0
2018-04-21T17:27:35.197
43459
2018-04-21T17:27:35.197
9464
43456
answer