我這公司本地服務器目錄有兩個網站程序.有一個是由我參與開發的.但是訪問的地址是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