First edit httpd.conf
Comment out the following places
#ServerAdmin [email protected]
#ServerName www.example.com:80
#DocumentRoot "/usr/local/apache2/htdocs"
#<directory/>
# Options FollowSymLinks
# allowoverride None
# Order Deny,allow
# Deny from all
#</directory>
#<directory "/usr/local/apache2/htdocs" >
#
# Possible values for the Options directive is "None", "all",
# or any combination of:
# Indexes includes followsymlinks symlinksifownermatch execcgi multiviews
#
# Note that "MultiViews" must is named *explicitly*---"Options all"
# doesn ' t give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
# Options Indexes followsymlinks
#
# AllowOverride Controls What directives is placed in. htaccess files.
# It can be ' all ', ' None ', or any combination of the keywords:
# Options FileInfo authconfig Limit
#
# allowoverride None
#
# Controls who can get stuff from the this server.
#
# Order Allow,deny
# Allow from all
#</directory>
Turn on the httpd-vhosts.conf configuration to cancel the comments in the previous include
# Virtual Hosts
Include conf/extra/httpd-vhosts.conf
Configuring the Extra/httpd-vhosts.conf File
Configuration example, how many subwebs there are, configure several
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/A"
ServerName www.a.com
#ServerAlias www.dummy-host.example.com
errorlog "Logs/a-error.log"
customlog "logs /a-access.log "Common
<directory"/a ";
Options Indexes followsymlinks
allowoverride None
Order Allow,deny
allow from all
</directory>
</virtualhost>
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/b"
ServerName www.b.com
#ServerAlias www.dummy-host.example.com
Errorlog "Logs/b-error.log"
Customlog "Logs/b-access.log" common
<directory "/b" >
Options Indexes FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
</VirtualHost>
According to the actual need to configure
About directory Permissions
Chown-r www-data:www-data/a
Chmod-r 755/a
Restart Apache to make configuration effective
/etc/init.d/apache2 restart
Apache 2.2 Single IP multi-domain virtual host access settings for different directories