以下是我在/etc/apache2/sites-available 中的虚拟主机:
<VirtualHost *:80>
DocumentRoot "/var/www/roomstays/public"
ServerName roomstays
#This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "/var/www/roomstays/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
它还在/etc/apache2/sites-enabled 文件夹中启用
下面是我的主机文件:
127.0.0.1 localhost
127.0.0.1 roomstays
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
我在 var/www/roomstays 中配置了我的网站。但是当我进入 roomstays 时,它没有打开网站并显示此消息:
有效!
这是该服务器的默认网页。
网络服务器软件正在运行,但尚未添加任何内容。
虚拟主机有什么问题。
最佳答案
如何为 Zend Project 设置虚拟主机:
在位置/var/www/中创建名为“roomstays”的项目(文件夹)
放入文件/etc/hosts 行:
127.0.0.1 roomstays.test
在/etc/apache2/sites-available/中创建名为“roomstays.conf”的文件并将其放入:
<VirtualHost *:80>
ServerName 127.0.0.1
ServerAlias roomstays.test
DocumentRoot /var/www/roomstays/public/
SetEnv APPLICATION_ENV "development"
<Directory /var/www/roomstays/public/>
Options All
AllowOverride All
Order Allow,Deny
Allow From All
</Directory>
</VirtualHost>
将该文件“roomstays.conf”复制到位置/etc/apache2/sites-enabled/
重新启动 apache,打开浏览器并输入“roomstays.test”,这对我有用。
关于apache - 虚拟主机不能在 zend 框架中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11259414/