mac配置apache虚拟主目录

来源:互联网 发布:java web 日志 编辑:程序博客网 时间:2024/06/04 00:37
本文以apache为例,叙述如何配置虚拟主目录。
他有什么作用呢,配置了他,访问标好的域名时,可以访问特定的目录层级,比如直接访问/www下的某个文件夹.
步骤:
1.打开相关配置;
2.对vhost配置文件进行参数配置,复制即可
3.重启apache



1. sudo vim /etc/apache2/httpd.conf
开启php模块,去掉前边的分号
2。打开引入vhost文件.
sudo vi /etc/apache2/extra/httpd-vhosts.conf

输入下面代码:
<VirtualHost *:80>     ServerName www.mall.com  [此处需修改成你的]     DocumentRoot "/Library/WebServer/Documents/mall"[此处需修改成你的]    <Directory "/Library/WebServer/Documents/mall">[此处需修改成你的]         Options FollowSymLinks IncludesNOEXEC Indexes         DirectoryIndex index.html index.htm index.php         AllowOverride all         Order Deny,Allow         Allow from all         Require all granted    </Directory></VirtualHost><VirtualHost *:80>     ServerName localhost     DocumentRoot "/Library/WebServer/Documents"[此处需修改成你的]    <Directory "/Library/WebServer/Documents/mall">[此处需修改成你的]         Options FollowSymLinks IncludesNOEXEC Indexes         DirectoryIndex index.html index.htm index.php         AllowOverride all         Order Deny,Allow         Allow from all         Require all granted    </Directory></VirtualHost>

3.重启apache
sudo apachectl restart


0 0
原创粉丝点击