I installed apache with brew and changed port 8080
to 80
. when I accessed localhost
this shown me a page "it works!" and that page is located in /usr/local/var/www
directory with file name index.html but when I added a virtual host in /usr/local/etc/httpd/extra/httpd-vhosts.conf
file.
<VirtualHost *:80>
DocumentRoot "/Users/ranaamir/projects/sample/yii2/backend/web"
ServerName yii2.example.be
ServerAlias yii2.example.be
<directory "/Users/ranaamir/projects/sample/yii2/backend/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</directory>
ErrorLog "/usr/local/var/log/httpd/vjfBackenderror.log"
CustomLog "/usr/local/var/log/httpd/vjfBackendaccess.log" common
</VirtualHost>
and restart the service with sudo apachectl -k restart
command and this host also added in /etc/hosts
.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 yii2.example.be
Then I access localhost
or yii2.example.be
both are showing a page where only one line mentioned Index of /
.
if I remove code of block <VirtualHost *:80>
from httpd-vhosts.conf
then again localhost
host showing correct index.html
.
why my project not running on the virtual-host url instead of index of /
?
Any help would be so appreciated!!
I have resolved this issue, I made little change in httpd.conf
file where we have to mentioned which type of file they will be process first so I just added index.php
in the code block of dir_module
.
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
I hope this will save your time and minimize your stress. :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.