简体   繁体   English

在 apache 服务器上运行多个烧瓶应用程序

[英]Running multiple flask application on apache server

I have multiple flask application in var/www/html like var/www/html/website , var/www/html/summary , var/www/html/sentiment我在var/www/html中有多个烧瓶应用程序,如var/www/html/websitevar/www/html/summaryvar/www/html/sentiment

Once I run all application successfully.一旦我成功运行所有应用程序。

Then I added one more application for which I created conf file and restarted server.然后我又添加了一个应用程序,我为其创建了 conf 文件并重新启动了服务器。

After that all application stopped working, only var/www/html/sentiment opens.之后所有应用程序停止工作,只有var/www/html/sentiment打开。

I checked code in python, wsgi and conf file for other application is same as it is in sentiment.我在 python、wsgi 和 conf 文件中检查了其他应用程序的代码,这与它在情感中是一样的。

Sentiment application code情感应用代码

flaskapp.py烧瓶应用程序

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 file - /etc/apache2/sites-available/sentiment.conf conf 文件 - /etc/apache2/sites-available/sentiment.conf

<VirtualHost *:80>
                ServerName IP
                ServerAdmin admin@mywebsite.com
                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>

Summary application code flaskapp.y总结应用代码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 /etc/apache2/sites-available/summary.conf

<VirtualHost *:80>
                ServerName IP
                ServerAdmin admin@mywebsite.com
                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>

Still when I open ip/sentiment it works but ip/summary gives仍然当我打开 ip/sentiment 它工作但 ip/summary 给出

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

Any suggestion for this?对此有何建议?

The issue is with your WSGIScriptAlias name.问题在于您的WSGIScriptAlias名称。

/ points to everything in the directory. /指向目录中的所有内容。

Give unique alias names to all applications.为所有应用程序提供唯一的别名。

Example:例子:

Change / to /app1 for WSGIScriptAlias更改//app1WSGIScriptAlias

Change / to /app2 for WSGIScriptAlias更改//app2WSGIScriptAlias

in both the files.在这两个文件中。

Restart the server then.然后重启服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM