码迷,mamicode.com
首页 > Web开发 > 详细

linux[基础]-29-[Apache服务]-[个人用户主页功能]-[03]

时间:2017-09-27 20:42:36      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:验证   加密   style   支持   es2017   gets   ftp   pac   require   

Apache服务

  top3:个人用户主页功能

 

开启个人用户主页功能:

[root@CnBlogs ~]# vim /etc/httpd/conf.d/userdir.conf

将第17行的UserDir disabled前面加一个#,代表改行注释

将第23行的UserDir public_html 前面的#去掉,表示启用

 

重启httpd服务:

[root@CnBlogs ~]# systemctl restart httpd.service

创建个人用户网站数据:

创建一个用户:

[root@CnBlogs ~]# useradd linuxs

[root@CnBlogs ~]#echo " 123" | passwd --stdin linuxs

切换至用户:

[root@CnBlogs ~]# su - linuxs

[linuxs@CnBlogs ~]$

创建一个public_html目录:

[linuxs@CnBlogs ~]$ mkdir public_html

写入个人网站主页数据:

[linuxs@CnBlogs ~]$ echo $(id linuxs) >> public_html/index.html

结果:

 技术分享

 

原因分析:

  原因是因为selinux不支持apache服务个人用户主页

 

getsebool命令用于查询所有selinux规则的布尔值

  格式为:getsebool -a

 

selinux策略布尔值:0为off禁止  1为on开启

 

setsebool命令用于修改selinux策略内各项规则的布尔值

格式为:setsebool [选项] 布尔值=[0|1]

  参数:-P 永久生效

 

查看并且搜索所有与家目录有关的selinux策略:

[root@CnBlogs ~]# getsebool -a | grep "home"

  ftp_home_dir --> off

  git_cgi_enable_homedirs --> off  

  git_system_enable_homedirs --> off

  httpd_enable_homedirs --> off

  mock_enable_homedirs --> off

  mpd_enable_homedirs --> off

  openvpn_enable_homedirs --> on

  samba_create_home_dirs --> off

  samba_enable_home_dirs --> off

  sftpd_enable_homedirs --> off

  sftpd_write_ssh_home --> off

  spamd_enable_home_dirs --> on

  ssh_chroot_rw_homedirs --> off

  tftp_home_dir --> off

  use_ecryptfs_home_dirs --> off

  use_fusefs_home_dirs --> off

  use_nfs_home_dirs --> off

  use_samba_home_dirs --> off

  xdm_write_home --> off

[root@CnBlogs ~]#

将个人用户网站功能策略设置为允许:

[root@CnBlogs ~]# setsebool -P httpd_enable_homedirs=on

[root@CnBlogs ~]# getsebool -a | grep "httpd_enable_homedirs"

httpd_enable_homedirs --> on

设置linuxs目录的权限为755:

[root@CnBlogs ~]# chmod -Rf 755 /home/linuxs/

结果:

 技术分享

 

可选的为自己的个人主页增加密码安全验证:

[root@CnBlogs ~]# htpasswd -c /etc/httpd/passwd linuxs

New password:

Re-type new password:

Adding password for user linuxs

[root@CnBlogs ~]# vim /etc/httpd/conf.d/userdir.conf

<Directory “/home/*/public_html”>

  AllowOverride all

  authuserfile /etc/httpd/passwd

  authname “My Privately Website”

  authtype basic

  require user linuxs

</Directory>

重启httpd服务:

[root@CnBlogs ~]# systemctl restart httpd.service

结果:

 技术分享

技术分享

 

 

 

 

linux[基础]-29-[Apache服务]-[个人用户主页功能]-[03]

标签:验证   加密   style   支持   es2017   gets   ftp   pac   require   

原文地址:http://www.cnblogs.com/msl23/p/7603346.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!