我在var/www/html
有多个烧瓶应用,如var/www/html/website
,var/www/html/summary
,var/www/html/sentiment
一旦我成功运行所有应用程序。
然后我又添加了一个应用程序,我为其创建了conf文件并重新启动了服务器。
在此之后所有应用程序停止工作,只有var/www/html/sentiment
打开。
我检查了python中的代码,wsgi和conf文件中的其他应用程序与情绪相同。
情绪应用程序代码
flask app.朋友
from flask import Flask
app = Flask(__name__)
@app.route('/sentiment')
def hello_world():
return 'Hello from Sentiment!'
if __name__ == '__main__':
app.run()
flaskapp.wsgi
import sys
sys.path.insert(0, '/var/www/html/sentiment/')
from flaskapp import app as application
conf文件 - /etc/apache2/sites-available/sentiment.conf
<VirtualHost *:80>
ServerName IP
ServerAdmin [email protected]
WSGIScriptAlias / /var/www/html/sentiment/flaskapp.wsgi
<Directory /var/www/html/sentiment/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
摘要应用程序代码flaskapp.y
from flask import Flask
app = Flask(__name__)
@app.route('/summary')
def hello_world():
return 'Hello from Summary!'
if __name__ == '__main__':
app.run()
flaskapp.wsgi
import sys
sys.path.insert(0, '/var/www/html/summary/')
from flaskapp import app as application
/etc/Apache2/sites-available/summary.conf
<VirtualHost *:80>
ServerName IP
ServerAdmin [email protected]
WSGIScriptAlias / /var/www/html/summary/flaskapp.wsgi
<Directory /var/www/html/summary/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
当我打开ip /情绪时它仍然有效,但ip / summary给出了
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
有什么建议吗?
问题出在您的WSGIScriptAlias名称上。
/
指向目录中的所有内容。
为所有应用程序提供唯一的别名。
例:
将/
更改为/app1
以获取WSGIScriptAlias
将/
更改为/app2
以获取WSGIScriptAlias
在两个文件中。
然后重启服务器。