Sau khi thất bại nhiều lần trong nhiệm vụ của tôi để có được ứng dụng bình của tôi chạy trên Apache sử dụng mod_wsgi
Tôi quyết định thử chạy hello world example. Dưới đây là những gì tôi có -Xin chào thế giới trong mod_wsgi
mục Structure (Tôi đã thay đổi apache mặc định /var/www
để ~/public_html
)
- public_html
- wsgi-scripts
- test_wsgi.wsgi
- test_wsgi
- test_wsgi.wsgi
tập tin test_wsgi.wsgi
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]
tập tin VirtualHost cấu hình (gọi tắt là testwsgi) - cư trú này in /etc/apache2/sites-enabled/
<VirtualHost *:80>
DocumentRoot ~/public_html/test_wsgi
<Directory ~/public_html/test_wsgi>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias /wsgi ~/public_html/wsgi-scripts/test_wsgi.wsgi
<Directory ~/public_html/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Khi tôi thử truy cập localhost/wsgi
trên trình duyệt, tôi nhận được lỗi 404 Not Found. Tôi đang làm gì sai? Đây là lần đầu tiên tôi cố gắng triển khai một ứng dụng trên một máy chủ sản xuất. Cho đến bây giờ, tôi đã sử dụng Google App Engine một cách dễ dàng. Tôi không thể tiếp tục triển khai ứng dụng bình của mình cho đến khi nó hoạt động. Cảm ơn rất nhiều!