博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
rh333 - 启用apache的UserDir(~user)支持
阅读量:4176 次
发布时间:2019-05-26

本文共 2173 字,大约阅读时间需要 7 分钟。

1. 版本与SELINUX

[root@server120 ~]# cat /proc/version

Linux version 2.6.18-308.el5xen (mockbuild@x86-010.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) #1 SMP Fri Jan 27 17:59:00 EST 2012
[root@server120 ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 21
Policy from config file:        targeted
[root@server120 ~]#

2. 编辑httpd配置文件,启用UserDir支持

[root@server120 ~]# grep -i UserDir /etc/httpd/conf/httpd.conf

LoadModule userdir_module modules/mod_userdir.so
# UserDir: The name of the directory that is appended onto a user's home
<IfModule mod_userdir.c>
    # UserDir is disabled by default since it can confirm the presence
    # UserDir disable
    # directory, remove the "UserDir disable" line above, and uncomment
    UserDir public_html
# Control access to UserDir directories.  The following is an example
[root@server120 ~]#

3. 在用户(eg. student)家目录上给予其他用户执行权限

[root@server120 ~]#
chmod o+x /home/student/
[root@server120 ~]# ls -dl /home/student/
drwx-----x 4 student student 4096 Mar 30 16:59 /home/student/
[root@server120 ~]#
echo student_home > /home/student/public_html/index.html
[root@server120 ~]# cat /home/student/public_html/index.html
student_home
[root@server120 ~]#
4. 开启SELINUX访问家目录的bool值

[root@server120 ~]# setsebool -P httpd_enable_homedirs on

[root@server120 ~]# getsebool -a | grep httpd | grep home
httpd_enable_homedirs --> on
[root@server120 ~]#

5. 更改家目录下public_html文件夹及其下所有文件的SELINUX类型

[root@server120 ~]# chcon -t httpd_sys_content_t /home/student/public_html/ -R

[root@server120 ~]# ls -Z /home/student/ -R
/home/student/:
-rw-------  student student root:object_r:user_home_t        mbox
drwxrwxr-x  student student root:object_r:httpd_sys_content_t public_html
/home/student/public_html:
-rw-rw-r--  student student root:object_r:httpd_sys_content_t index.html
[root@server120 ~]#
6. 测试访问
[root@server120 ~]# elinks -dump server120.example.com/~student
   student_home
[root@server120 ~]#
REF:

1. How to get UserDir (user specific public_html) working for apache in CentOS 6

http://centosforge.com/node/how-get-userdir-user-specific-publichtml-working-apache-centos-6

转载地址:http://jitai.baihongyu.com/

你可能感兴趣的文章
opengl实现任意两点间画圆柱体
查看>>
最新:斐讯K3千兆无线路由器刷官改版固件的详细图文教程
查看>>
Windows基于Apache的svn服务器配置
查看>>
cesium调用天地图服务
查看>>
objTo3d-tiles:将obj模型文件转换为三维瓦片
查看>>
Linux查看硬件信息命令
查看>>
.obj 和 .mtl文件格式
查看>>
CentOS6.5 添加开机自启动脚本
查看>>
Access 和vc6.0 相连,在我indows64 位系统中,出现找不到Microsoft Access Driver(*.mdb) ODBC驱动程序的安装例程。请重新安装驱动
查看>>
Spring框架的基本概念
查看>>
Spring Bean的配置方式及标注(Annotation)配置
查看>>
Spring框架事务管理之一:JavaEE事务与Spring事务
查看>>
java.lang.IllegalArgumentException: FacesContext must not be null 错误分析及解决
查看>>
Spring框架事务管理之四:Spring编程式事务
查看>>
JOSSO入门指南及其与WildFly AS 10的集成
查看>>
为WildFly AS 10中的Liferay Portal 6.2配置JOSSO Agent
查看>>
Spring ORM与Hibernate的集成开发详解
查看>>
WildFly AS 10中基于PicketLink的SAML SSO实现
查看>>
Spring AOP概述
查看>>
Apache Maven入门指南
查看>>