linux系统中部署apache服务(为个人网站设置密码)
实验环境接“ linux系统中部署apache服务(个人用户主页功能)”。
1、在PC1服务器端为用户usertest1创建密码库
[root@PC1 ~]# htpasswd -c /etc/httpd/passwd usertest1 ## 这个usertest1不必是系统已经存在的账户,只是用于登录用
New password:
Re-type new password:
Adding password for user usertest1
2、在PC1主机中修改个人用户主页功能的配置文件
…………
28 # Control access to UserDir directories. The following is an example
29 # for a site where these directories are restricted to read-only.
30 #
31 <Directory "/home/*/public_html">
32 AllowOverride all
33 authuserfile "/etc/httpd/passwd"
34 authname "My privately website"
35 authtype basic
36 require user usertest1 ## 这个账户不必是已经存在的用户,只是一个登录账号
37 </Directory>
38
3、 在PC1服务器端重启httpd服务
[root@PC1 ~]# systemctl restart httpd
[root@PC1 ~]# systemctl enable httpd
[root@PC1 ~]# systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Thu 2020-12-17 00:04:07 CST; 19s ago
Main PID: 4861 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─4861 /usr/sbin/httpd -DFOREGROUND
├─4862 /usr/sbin/httpd -DFOREGROUND
├─4863 /usr/sbin/httpd -DFOREGROUND
├─4864 /usr/sbin/httpd -DFOREGROUND
├─4865 /usr/sbin/httpd -DFOREGROUND
└─4866 /usr/sbin/httpd -DFOREGROUND
Dec 17 00:04:07 PC1 systemd[1]: Starting The Apache HTTP Server...
Dec 17 00:04:07 PC1 httpd[4861]: AH00557: httpd: apr_sockaddr_info_get() failed for PC1
Dec 17 00:04:07 PC1 httpd[4861]: AH00558: httpd: Could not reliably determine the s...age
Dec 17 00:04:07 PC1 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
3、在PC2客户端测试配置效果
注:这个账户就是普通的账户,不必是系统已经存在的账户
以上实验实现了对个人主页功能登录账号和密码的设置。