我正試圖在EC2上部署一個簡單的Flask應用程序。 一切工作正常,但是當我嘗試訪問我的網站,我收到了404錯誤,說:在AWS EC2上部署Flask應用程序
請求的URL /flaskapp.py/flaskapp.wsgi/此服務器上找到。
flaskapp.py代碼:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "hello"
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0', port=80)
flaskapp.wsgi:
import sys
sys.path.insert(0, '/var/www/html/flaskapp')
from flaskapp import app as application
最後文件000-default.conf
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName myServerHostname
DocumentRoot /var/www/
WSGIDaemonProcess flaskapp threads=5
WSGIScriptAlias//var/www/html/flaskapp/flaskapp.wsgi
<Directory flaskapp>
WSGIProcessGroup flaskapp
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have/go to the right place
#RedirectMatch ^/$ /apache2-default/
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
這段代碼錯了嗎? 我能做些什麼來解決它? 感謝大家!
那麼,這不是問題的正確答案,是嗎? –
當然不是,只是一種解決方法,我會編輯我的答案以便更清楚 –