Apache虚拟目录的配置

我直接说我的习惯吧,我一般在/etc/httpd/conf.d/目录下创建对应得文件比如我创建一个demo.com的虚拟目录执行命令如下

vim /etc/httpd/conf.d/demo.conf

写入下面内容

<VirtualHost *:80>  
 ServerName demo.com  
 DocumentRoot "/home/www/demo"  
 DirectoryIndex index.html index.php  
  
 <Directory "/home/www/demo">  
  Options -Indexes +FollowSymlinks  
  AllowOverride All  
  Require all granted  
 </Directory>  
  
</VirtualHost>

保存重启 systemctl restart httpd
OK 搞定
apache版本2.4.*

推荐阅读更多精彩内容