mod_wsgi
का उपयोग करके अपाचे पर चलाने के लिए मेरे फ्लास्क एप्लिकेशन को प्राप्त करने के लिए मेरी खोज में बार-बार विफल होने के बाद मैंने hello world example चलाने का प्रयास करने का निर्णय लिया। यहाँ मैं क्या है -mod_wsgi में हैलो वर्ल्ड
निर्देशिका संरचना
- public_html
- wsgi-scripts
- test_wsgi.wsgi
- test_wsgi
- test_wsgi.wsgi
test_wsgi.wsgi फ़ाइल (मैं अपाचे डिफ़ॉल्ट ~/public_html
को /var/www
बदल)
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]
VirtualHost विन्यास फ़ाइल (बुलाया testwsgi) - यह बसता था /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>
जब मैं ब्राउज़र पर localhost/wsgi
पर जाने का प्रयास करता हूं तो मुझे 404 नहीं मिला त्रुटि मिलती है। मैं क्या गलत कर रहा हूं? यह पहली बार है जब मैं एक उत्पादन सर्वर पर एक ऐप तैनात करने की कोशिश कर रहा हूं। अब तक मैंने Google App Engine का उपयोग करने का आसान तरीका लिया है। जब तक यह ऊपर और चलने तक मैं अपने फ्लास्क ऐप को तैनात करने के लिए आगे नहीं बढ़ सकता। आपका बहुत बहुत धन्यवाद!