http作业
搭建web服务器:
[root@localhost ~]# mkdir /www
[root@localhost ~]# echo 小胖,你怎么这么胖 > /www/index.html
[root@localhost ~]# systemctl restart httpd
基于域名访问:
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# mkdir /openlab
[root@localhost ~]# echo welcome to openlabd! > /openlab/index.html
使用域名访问大胖小胖
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# mkdir /openlab/{xiaopang,dapang}
[root@localhost ~]# echo this is xiaopang > /openlab/xiaopang/index.html
[root@localhost ~]# echo this is dapang > /openlab/dapang/index.html
[root@localhost ~]# systemctl restart httpd
创建虚拟目录真实目录在/usr/local/hehe:
[root@localhost ~]# mkdir /usr/local/hehe
[root@localhost ~]# echo this is hehe > /usr/local/hehe/index.html
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# mkdir /usr/local/maomao
[root@localhost ~]# echo this is maomao > /usr/local/maomao/index.html
加密
[root@localhost maomao]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost maomao]# htpasswd -c /etc/httpd/userfile abc
New password:
Re-type new password:
Adding password for user abc
[root@localhost maomao]# htpasswd /etc/httpd/userfile xyz
New password:
Re-type new password:
Adding password for user xyz
[root@localhost maomao]# vim /etc/httpd/userfile
[root@localhost ~]# mkdir -pv /openlab/128/2/f/file/newfile/
mkdir: created directory ‘/openlab/128/2’
mkdir: created directory ‘/openlab/128/2/f’
mkdir: created directory ‘/openlab/128/2/f/file’
mkdir: created directory ‘/openlab/128/2/f/file/newfile/’
[root@localhost ~]# echo this is openlab.data > /openlab/128/2/f/file/newfile/index.html
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
[root@localhost ~]# mkdir -pv /openlab/128/3/f/file/newfile
mkdir: created directory ‘/openlab/128/3’
mkdir: created directory ‘/openlab/128/3/f’
mkdir: created directory ‘/openlab/128/3/f/file’
mkdir: created directory ‘/openlab/128/3/f/file/newfile’
[root@localhost ~]# echo this is openlab.money > /openlab/128/3/f/file/newfile/index.html
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# cd /student
[root@localhost student]# htpasswd -c /etc/httpd/userfile song
New password:
Re-type new password:
Adding password for user song
[root@localhost student]# htpasswd /etc/httpd/userfile tian
New password:
Re-type new password:
Adding password for user tian
[root@localhost student]# vim /etc/httpd/userfile
[root@localhost student]# systemctl restart httpd
[root@localhost money]# yum install mod_ssl -y
[root@localhost certs]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout …/private/openlab.key -x509 -days 365 -out openlab.crt
Generating a RSA private key
Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:shannxi
Locality Name (eg, city) [Default City]:xian[[D[[DHH^H
Organization Name (eg, company) [Default Company Ltd]:xianopeng
Organizational Unit Name (eg, section) []:ce
Common Name (eg, your name or your server’s hostname) []:localhs^H
Email Address []:admin@admin.com
[root@localhost certs]# ll
total 8
lrwxrwxrwx. 1 root root 49 Oct 19 2019 ca-bundle.crt -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
lrwxrwxrwx. 1 root root 55 Oct 19 2019 ca-bundle.trust.crt -> /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
-rw-r–r--. 1 root root 3980 Mar 26 15:39 localhost.crt
-rw-r–r--. 1 root root 2130 Mar 26 20:45 openlab.crt