10.4 个人用户主页功能

在系统中为每位用户建立独立的网站,利用httpd服务程序提供的个人用户主页功能实现这个需求

第1步:在httpd 服务程序中,默认没有开启个人用户主页功能。为此,我们需要编辑下 面的配置文件,然后在第17 行的UserDir disabled 参数前面加上井号(#),表示让httpd 服务 程序开启个人用户主页功能;同时再把第24 行的UserDir public_html 参数前面的井号(#) 去掉(UserDir 参数表示网站数据在用户家目录中的保存目录名称,即public_html 目录)。最 后,在修改完毕后记得保存。

# vim /etc/httpd/conf.d/userdir.conf
...省略...
 17     #UserDir disabled
 18 
 19     #
 20     # To enable requests to /~user/ to serve the user's public_html
 21     # directory, remove the "UserDir disabled" line above, and uncomment
 22     # the following line instead:
 23     # 
 24     UserDir public_html
...省略... 

第2步:在用户家目录中建立用于保存网站数据的目录及首页文件,并且把家目录的权限修改为755

# su - linuxprobe
$ mkdir public_html
$ echo "This is linuxprobe website" > public_html/index.html
$ chmod -Rf 755 /home/linuxprobe/

第3步,重启httpd服务

# systemctl  restart httpd

第4步:使用getsebool命令查询并过滤出所有与HTTP协议相关的安全策略,off为禁止状态,on为允许状态

第5步:使用setsebool命令将httpd_enable_homedirs --> off 改为on,参数-P(大写)表示永久生效

第6步:访问测试

方法一:图形界面,浏览器输入以下URL

方法二:在命令行界面输入以下命令

最后更新于