2012-08-29 27 views
16

mod_wsgi numaralı telefonu kullanarak Apache üzerinde çalışmam için flask uygulamamı alma görevimde defalarca başarısız olduktan sonra, hello world example'u çalıştırmayı denemeye karar verdim. İşte ne var -Hello World in mod_wsgi

Dizin Yapısı

- public_html  
    - wsgi-scripts 
     - test_wsgi.wsgi 
    - test_wsgi 
     - test_wsgi.wsgi 

test_wsgi.wsgi dosyası (ben apache varsayılan ~/public_html için /var/www değişti)

def application(environ, start_response): 
    status = '200 OK' 
    output = 'Hello World!' 

    response_headers = [('Content-type', 'text/plain'), 
         ('Content-Length', str(len(output)))] 

    start_response(status, response_headers) 

    return [output] 

Sanal Ana Yapılandırma dosyası (denilen testwsgi) - Bu bulunduğu Tarayıcıda localhost/wsgi'a gitmeyi denediğimde 404 Bulunamadı hatasıyla karşılaşıyorum. Neyi yanlış yapıyorum? Bu, bir uygulamayı bir uygulama sunucusuna dağıtmaya çalıştığım ilk sefer. Şimdiye kadar Google App Engine'i kullanmanın kolay yolunu aldım. Bu kadar ve çalışıyor olana kadar benim flask uygulamasını dağıtmak için devam edemez. Çok teşekkürler!

cevap

12

Mutlak bir yol kullanmanız gerekir, yani ~'u kullanmayın. ...

[[email protected] public_html]$ grep wsgihost /etc/hosts 
127.0.1.1  tsunami.foo.net tsunami wsgihost 
[[email protected] public_html]$ 

Yeniden apache Bu

[[email protected] public_html]$ sudo cat /etc/apache2/sites-available/wsgi_test 
<VirtualHost *:80> 
    ServerName wsgihost 
    DocumentRoot /home/mpenning/public_html 
    WSGIScriptAlias//home/mpenning/public_html/test.wsgi 
</VirtualHost> 
[[email protected] public_html]$ 

Önce /etc/hosts bir hostname kurmak ... benim için çalışıyor, bu yüzden sorguda ana makine adına mux sağlamak olabilir ... ve bir wget ...

[[email protected] public_html]$ wget http://wsgihost/ 
--2012-08-29 05:50:26-- http://wsgihost/ 
Resolving wsgihost... 127.0.1.1 
Connecting to wsgihost|127.0.1.1|:80... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 12 [text/plain] 
Saving to: âindex.html.3â 

100%[======================================>] 12   --.-K/s in 0s 

2012-08-29 05:50:26 (1.48 MB/s) - âindex.html.3â 

[[email protected] public_html]$ cat index.html 
Hello World![[email protected] public_html]$ # <------ 
İlgili konular