[英]Running a flask website in a subdirectory with apache
I'm using apache on my personal server, and I'm trying to run a 'main' website made with Silex
on www.mydomain.com/
and another one made using Flask
on www.mydomain.com/something
我在我的个人服务器上使用apache,我正在尝试运行一个在
www.mydomain.com/
上使用Silex
制作的“主”网站,另一个在www.mydomain.com/something
上使用Flask
制作的网站
To run the Flask
website I'm using mod_wsgi as explained on their official website (http://flask.pocoo.org/docs/deploying/mod_wsgi/). 要运行
Flask
网站,我正在使用mod_wsgi,如其官方网站(http://flask.pocoo.org/docs/deploying/mod_wsgi/)所述。
It works just fine, I can reach my website at www.mydomain.com/something
, but when I go back to www.mydomain.com/
I get a Flask
404 error message. 它运行得很好,我可以访问我的网站
www.mydomain.com/something
,但是当我回到www.mydomain.com/
我收到一条Flask
404错误消息。
I've tried checking the apache
doc about virtual hosts but I can't make sense of it, here is my current 'sites-enabled/defaults'
configuration file : 我已经尝试检查有关虚拟主机的
apache
文档,但我无法理解它,这是我当前的'sites-enabled/defaults'
配置文件:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess bc user=bc group=bc threads=5
WSGIScriptAlias / /var/www/bc/bc.wsgi
<Directory /var/www/bc>
WSGIProcessGroup bc
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
my /var/www
directory looks like this : 我的
/var/www
目录如下所示:
./index.php
./bc/
./bc/index.py
How can I get the python website to only work in www.mydomain.com/something and let the PHP one run on www.mydomain.com/ ? 我怎样才能让python网站只在www.mydomain.com/something上工作,让PHP一个在www.mydomain.com/上运行?
The first parameter to WSGIScriptAlias
is the url path , by specifying WSGIScriptAlias / <foo>
you're telling apache to send all requests to the WSGI app. WSGIScriptAlias
的第一个参数是url路径 ,通过指定WSGIScriptAlias / <foo>
您告诉apache将所有请求发送到WSGI应用程序。 Try WSGIScriptAlias /something <foo>
尝试
WSGIScriptAlias /something <foo>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.