CentOS6修改Apache默认根目录

来源:互联网 发布:java多线程查询数据库 编辑:程序博客网 时间:2024/05/16 07:55

操作目的:将apache的默认根目录/var/www/html修改为:/home/www/html

步骤:

1、以root登录,并进入home目录

2、创建目录www

# mkdir www

3、修改目录权限

# chmod 755 www

4、修改目录的SELinux策略:

由于CentOS开启了SELinux,即使是将目录权限设置为所有人都可以访问,apache用户一样不可以访问,有网友建议关闭SELinux策略,我个人不建议这样做,我们只需修改/home/www这个目录的SELinux策略即可:

# chcon -t httpd_sys_content_t www

5、查看SELinux策略


6、创建/home/www/html目录

mkdir html

7、修改apache配置/etc/httpd/conf/httpd.conf

将其中的

DocumentRoot “/var/www/html”

修改为

DocumentRoot “/home/www/html”

<Directory “/var/www/html”>

修改为

<Directory “/home/www/html”>

如果启用了NameHost,则要修改网站指向:

<VirtualHost *:80>  ServerName example.com  ServerAlias www.example.com  DocumentRoot /home/www/html</VirtualHost>

8、重启Apache服务



原创粉丝点击