CentOS Linux系统下更改Apache默认网站目录

CentOS Linux系统下更改Apache默认网站目录
2011年11月03日 ⁄ Apache ⁄ 暂无评论 ⁄ 被围观 11,351次+
 


引言:
Apache默认的网站目录是在/var/www/html,我们现在要把网站目录更改到/home/wwwroot/web1/htdocs,操作如下
系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接
准备工作:
创建目录:
cd /home
mkdir wwwroot
cd wwwroot
mkdir web1
cd web1
mkdir htdocs
touch index.php
操作步骤:
1、vi /etc/httpd/conf/httpd.conf
   找到 DocumentRoot "/var/www/html" 这一段     #apache的根目录
   把/var/www/html 这个目录改为/home/wwwroot/web1/htdocs
   再找到 <Directory "/var/www/html">   #定义apache /var/www/html这个区域
   把 /var/www/html改成/home/wwwroot/web1/htdocs
   这样我们就把apahce的默认路径改掉了
   service httpd restart  #重启Apache服务器
2、访问localhost的时候,会发现访问拒绝,这是为什么呢?
系统运维  www.osyunwei.com  温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接
主要是因为你的/home/wwwroot/web1/htdocs的权限是750,apache这个用户没有权限访问,你需要更改掉权限,可以这样改
   chmod -R 755 /home/wwwroot/web1/htdocs
然后去访问 发现正常运行了(apache的用户:apache 运行apache的组:apache)
至此,Apache默认网站目录更改成功。

posted @ 2016-03-03 19:10  爱博子  阅读(98)  评论(0编辑  收藏  举报