Example of Config Apache (Xampp) To code other than htdocs

1. Locate to C:\Windows\System32\drivers\etc and open hosts using text editor.
Add line to C:\Windows\System32\drivers\etc\host 
(this file need save to outside this directory due to access forbidden and then replace this file by pasting to this directory)


127.0.0.1 localhost ::1 localhost

127.0.0.1       yii.hd  (this is the example name)

2.Open the main Apache configuration file, httpd.conf, in a text editor. It's in the Apache conf folder. 
If you're using XAMPP, the file is located at xampp setup director \apache\conf\httpd.conf. 
Scroll down to the Supplemental configuration section at the end, 
and locate the following section (around line 500):


#Virtual hosts
#Include conf/extra/httpd-vhosts.conf


Remove the # from the beginning of the second line so the section now looks like this:


#Virtual hosts
Include conf/extra/httpd-vhosts.conf


Save httpd.conf and close it.


3.Add line to httpd-vhost.conf (located at xampp setup director \apache\conf\extra\httpd-vhosts.conf. ),example


<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "E:\YII\basic"
    ServerName yii.hd
</VirtualHost>

4. Add line to httpd.conf files, example list below:
<Directory "E:/YII/basic">
    AllowOverride All
    Options None
    Require all granted
</Directory>

猜你喜欢

转载自blog.csdn.net/frank120120/article/details/80494166