第一步:挂载,安装,关闭防火墙和selinux
[root@localhost hh]# mount /dev/sr0 /mnt
[root@localhost hh]# yum install httpd
[root@localhost hh]# systemctl stop firewalld
[root@localhost hh]# setenforce 0
第二步:更改配置,实现自定义设置
[root@localhost hh]# cd /etc/httpd/conf.d
[root@localhost conf.d]# vim hhh.conf
<VirtualHost 192.168.233.131:80>
Servername www.openlab.com
DocumentRoot /www/openlab
</VirtualHost>
<Directory /www/>
AllowOverride none
Require all granted
</Directory>
手动建立连接
[root@localhost conf.d]# cd /etc
[root@localhost etc]# vim hosts
192.168.233.131 www.openlab.com
创建目录
[root@localhost etc]# mkdir /www/openlab
[root@localhost etc]# echo welcome to openlab > /www/openlab/index.html
测试:
[root@localhost etc]# curl http://www.openlab.com
welcome to openlab
第一步:创建目录
[root@localhost etc]# cd /root
[root@localhost ~]# mkdir {student,data,money}
修改权限:[root@localhost ~]# chmod /root 777
第二步:添加内容
[root@localhost ~]# echo who is money > /root/money/index.html
[root@localhost ~]# echo who is data > /root/data/index.html
[root@localhost ~]# echo who is student > /root/student/index.html
第一步:创建用户
[root@localhost ~]# htpasswd -c /etc/httpd/users song
New password:
Re-type new password:
htpasswd: password verification error
[root@localhost ~]# htpasswd /etc/httpd/users tian
New password:
Re-type new password:
Adding password for user tian
第二步:用户访问控制
<Directory /www/openlab/student>
AllowOverride none
AuthType Basic
AuthName "Please Login..."
AuthUserfile /etc/httpd/users
Require user song tian
</Directory>
测试:
SSL:
装包:[root@localhost ~]# yum install mod_ssl
生成证书:
[root@localhost ~]# openssl req -newkey rsa -nods -keyout openlab.key -x509 -days 365 -out openlab.crt
Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:jiangsu
Locality Name (eg, city) [Default City]:nanjing
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:ce
Common Name (eg, your name or your server's hostname) []:localhost
Email Address []:admin
添加信息:(所有)
<VirtualHost 192.168.233.131:80>
Servername www.openlab.com
DocumentRoot /www/openlab
Alias /student /root/student
Alias /data /root/data
</VirtualHost>
<Directory /www/>
AllowOverride none
Require all granted
</Directory>
<Directory /root/data>
AllowOverride none
Require all granted
</Directory>
<Directory /root/money>
AllowOverride none
Require all granted
</Directory>
<Directory /root/student>
AllowOverride none
AuthType Basic
AuthName "Please Login..."
AuthUserfile /etc/httpd/users
Require user song tian
</Directory>
<VirtualHost 192.168.233.131:443>
ServerName www.openlab.com
DocumentRoot /www/openlab
Alias /money /root/money
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
</VirtualHost>