一台服务器上本来只设了一个虚拟目录,但是后来挂载了一块新的硬盘,想把一些东西放在新的硬盘上,并且让访问网站的人能够访问到这些东西,想多设一个虚拟目录,经过一番研究,步骤如下:
1 打开Apache 下的httpd.conf。在Listen下增加监听的端口号,想要几个加几个。
Listen 8686
Listen 8989
ServerName localhost:8686(比如这个是原本的端口,现在需要增加一个新的端口8989)
ServerName localhost:8989
2 还是在上一个文件里,在文件末尾端加以下几行,表示增加一个虚拟目录
<VirtualHost xxx.xx.xxx.xxx:8989>
ServerName xxx.xx.xxx.xxx:8989(服务器外网ip)
DocumentRoot "E:/public"(新的虚拟目录的路径)
</VirtualHost>
<Directory "E:/public">
#Options Indexes FollowSymLinks Multiviews
#AllowOverride All
#Order Allow,Deny
#Allow from all
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
3 最后打开vhost.conf文件,增加以下
<VirtualHost *:8989>
ServerAdmin administrator@localhost
DocumentRoot "E:/public"
#ServerName li515-107.members.linode.com
#ServerName xxx.xx.xxx.xxx(你服务器的外网ip)
<Directory "E:/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory "E:/public">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
重启apache,即可。
不过,访问不同目录需要使用不同的端口号。