我有2个vps.一个vps上,安装的apache2的版本为apache2.2:
root@AR:~# apache2 -v
Server version: Apache/2.2.22 (Debian)
Server built: Jul 24 2014 16:20:38
root@AR:~#
另一个vps上,安装的apache2的版本为apache2.4:
root@ary:~# apache2 -v
Server version: Apache/2.4.10 (Debian)
Server built: Nov 28 2015 14:05:48
root@ary:~#
配置APACHE2.4的虚拟主机要注意的一点是:
要在virtualhost段里,加上Require all granted一行。否则虚拟主机网站不会成功显示。
root@ary:~# cat /etc/apache2/sites-available/default
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName 0.0.0.0
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /usr/local/blakeembrey.com-site/build
ServerName be.bright.biz.st
<Directory /usr/local/blakeembrey.com-site/build>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
root@ary:~#
而配置APACHE2.2的虚拟主机,则无需加上Require all granted一行。
root@AR:~# cat /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /usr/local/peanut-blog
<Directory /usr/local/peanut-blog>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName pn.bright.biz.st
</VirtualHost>
root@AR:~#