我这公司本地服务器目录有两个网站程序.有一个是由我参与开发的.但是访问的地址是192.168.2.120/clzv2.
只能打这个地址,要打192.168.2.120 就显示 It Works!
我就配置了虚拟主机.但是还是不能识别自动index.php主入口文件.非要我自己打上去,妈蛋,这不是我想要的,
我在阿里云上面配置虚拟主机为什么都不是这样的.一时,我也没有想到解决方法.就暂时那样用了.
这几天,我因为需要,又把虚拟主机关了,这时,我想,之前这个网站是怎么配置的.
打开httpd.conf 看到
<Directory />
AllowOverride none
Require all denied
</Directory>
<Directory "/usr/local/apache2/htdocs/tycart">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
<Directory "/usr/local/apache2/htdocs/oa">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
DirectoryIndex index.php
这时,我就想,是不是在我配置虚拟主机的.也要加上这句话,
然后我要网上搜了一下这个相关信息
问:如何让Apache能自动运行index.php?
答:编辑httpd.conf文件,找到DirectoryIndex在后面加一个index.php。
例如,我把DirectoryIndex这行改为:DirectoryIndex index.html index.htm index.php index.html.var
保存编辑的内容,重新启动Apache就可以实现了。
<Directory /xxx>
DirectoryIndex index.html index.htm index.php index.php3
</Directory>
说实话,我知道是可以这样配置的,但是我忘了在哪.
于是,我就在猜想本地apache配置文件,应该没有添加index.php
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
于是找到了上面这段配置,就是能识别的索引文件
它只有index.html
我在阿里云上也看了下httpd.conf的配置
</Directory>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
大家请看,阿里云的支持这些.我本地的服务器才一个,
只要添加上就可以了,记得重启Apache