我正在尝试在Apache服务器上部署两个Django应用程序,在Ubuntu-16.04上运行。我的000-default.conf文件如下所示:
更新:(不同端口) 我使用的IP是172.16.16.68
当我运行单个应用程序pep_web时,我可以通过浏览器连接此应用程序
172.16.16.68/pep_learn
和MyApp通过这样的浏览器
172.16.16 / MyApp的
<VirtualHost *:80>
<Directory /home/bic/MyApp/MyApp>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess MyApp python-path=/home/bic/MyApp:/usr/lib/python2.7/dist-packages
WSGIProcessGroup MyApp
WSGIScriptAlias /MyApp /home/bic/MyApp/MyApp/wsgi.py
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
</VirtualHost>
<VirtualHost *:8080>
Alias /static /home/bic/pep_web/protocol/static
<Directory /home/bic/pep_web/protocol/static>
Require all granted
</Directory>
<Directory /home/bic/pep_web/pep_learn>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess pep_web python-path=/home/bic/pep_web:/usr/lib/python2.7/dist-packages
WSGIProcessGroup pep_web
WSGIScriptAlias /pep_learn /home/bic/pep_web/pep_learn/wsgi.py
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
使用此设置“MyApp”正在运行,但不是其他应用程序“pep_web” 我怎么解决这个问题?
答案 0 :(得分:1)
因为两者都在同一个端口80
中运行。您需要在每个ServerName
VirtualHost
了解更多doc
<VirtualHost *:80>
<Directory /home/bic/MyApp/MyApp>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess MyApp python-path=/home/bic/MyApp:/usr/lib/python2.7/dist-packages
WSGIProcessGroup MyApp
WSGIScriptAlias /MyApp /home/bic/MyApp/MyApp/wsgi.py
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName myapp.com
</VirtualHost>
<VirtualHost *:80>
Alias /static /home/bic/pep_web/protocol/static
<Directory /home/bic/pep_web/protocol/static>
Require all granted
</Directory>
<Directory /home/bic/pep_web/pep_learn>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess pep_web python-path=/home/bic/pep_web:/usr/lib/python2.7/dist-packages
WSGIProcessGroup pep_web
WSGIScriptAlias /pep_learn /home/bic/pep_web/pep_learn/wsgi.py
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName mypepapp.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
然后在/etc/hosts
127.0.0.1 localhost
::1 localhost
#your local domains
127.0.0.1 myapp.com
127.0.0.1 mypepapp.com