http://kvm5.deyu.wang/~deyu1
,查看模組有沒有載入,沒有的話要自行載入。
[root@kvm5 ~]# grep userdir /etc/httpd/conf.modules.d/00-base.conf LoadModule userdir_module modules/mod_userdir.so
[root@kvm5 ~]# vim /etc/httpd/conf.d/userdir.conf <IfModule mod_userdir.c> # # UserDir is disabled by default since it can confirm the presence # of a username on the system (depending on home directory # permissions). # #UserDir disabled <= 註解這一行 # # To enable requests to /~user/ to serve the user's public_html # directory, remove the "UserDir disabled" line above, and uncomment # the following line instead: # UserDir public_html <= 取消註解這行,個人網頁根目錄為 public_html </IfModule>
[root@kvm5 ~]# tail /etc/httpd/conf.d/userdir.conf # # Control access to UserDir directories. The following is an example # for a site where these directories are restricted to read-only. # <Directory "/home/*/public_html"> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS </Directory>
[root@kvm5 ~]# systemctl enable httpd.service ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service' [root@kvm5 ~]# systemctl reload httpd.service
[root@kvm5 ~]# useradd deyu1 [root@kvm5 ~]# echo '123qwe' | passwd --stdin deyu1 Changing password for user deyu1. passwd: all authentication tokens updated successfully.
[root@kvm5 ~]# su - deyu1
[deyu1@kvm5 ~]$ mkdir public_html [deyu1@kvm5 ~]$ echo 'userdir test' > public_html/index.html
[deyu1@kvm5 ~]$ exit logout
[root@kvm5 ~]# curl http://kvm5.deyu.wang/~deyu1/ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access /~deyu1 on this server.</p> </body></html>
[root@kvm5 ~]# ll /home/deyu1/ -d drwx------. 3 deyu1 deyu1 1024 May 22 21:04 /home/deyu1/
[root@kvm5 ~]# chmod 755 /home/deyu1/
[root@kvm5 ~]# curl http://kvm5.deyu.wang/~deyu1/ userdir test