小白CE进阶,使用ssl访问a‘p‘ache服务器,nfs挂载,访问cgi程序

目录

1.配置使用ssl完成https访问apache服务器

2.配置访问apache的cgi程序

3.nfs挂载

4.autofs自动挂载

5.使用https来访问的web服务器:要求使用自签名的CA签名证书(openssl, x.509) .crt以及私钥


1.配置使用ssl完成https访问apache服务器

[root@localhost conf.d]# systemctl status firewalld

[root@localhost conf.d]# systemctl stop firewalld
[root@localhost conf.d]# setenforce 0                            #设置为宽容模式

[root@localhost ~]# yum install mod_ssl -y

[root@localhost /]# mkdir /www/myssl

[root@localhost www]# echo 'this is my first https page.' > ./myssl/index.html
[root@localhost ~]# cd /etc/httpd/conf.d
[root@localhost conf.d]# vim myssl.conf

 [root@localhost conf.d]# systemctl restart httpd

2.配置访问apache的cgi程序

[root@localhost conf.d]# cd /var/www/cgi-bin/
[root@localhost cgi-bin]# vim test.cg

  [root@localhost cgi-bin]# chmod +x test.cgi   


3.nfs挂载


a、开放/nfs/shared目录,供所有用户查询资料;

[root@localhost ~]# systemctl stop firewalld.service  关闭防火墙
                                                                       
[root@localhost ~]# setenforce 0                      开启兼容模式     
[root@localhost ~]# systemctl start rpcbind           开启rpcbind 
 注:在启动NFS之前,要先启动RPC,否则NFS会无法向RPC注册。另外,RPC若重新启动,原来注册的数据会消失不见,因此RPC重启后,它管理的所有服务都需要重新启动以重新向RPC注册。
[root@localhost ~]# systemctl start nfs-server        开启nfs服务
[root@localhost ~]# vim /etc/exports
/nfs/shared *(ro)
[root@localhost ~]# mkdir /nfs/shared -p
[root@localhost ~]# touch /nfs/shared/file{a..e}
[root@localhost ~]# exportfs -r
 

b、开放/nfs/upload目录,该目录为192.168.xxx.0/24网段的主机的数据上传目录,
并将所有该网段主机上传文件的所属者和所属组映射为nfs-upload,其UID和GID为2001;

 [root@localhost ~]# cd /nfs/shared
[root@localhost shared]# vim /etc/exports


[root@localhost shared]# mkdir /nfs/upload -p
[root@localhost shared]# chmod o+w /nfs/upload/
[root@localhost shared]# cd /nfs
[root@localhost nfs]# ll
total 0
drwxr-xr-x. 2 root root 71 Jul 31 13:50 shared
drwxr-xrwx. 2 root root  6 Jul 31 18:54 upload
[root@localhost nfs]# touch /nfs/upload/test{a..c}
[root@localhost nfs]# cd upload/
[root@localhost upload]# ll
total 0
-rw-r--r--. 1 root root 0 Jul 31 18:55 testa
-rw-r--r--. 1 root root 0 Jul 31 18:55 testb
-rw-r--r--. 1 root root 0 Jul 31 18:55 testc
[root@localhost upload]# useradd -u 2001 nfs-upload
[root@localhost upload]# groupmod -g 2001 nfs-upload
[root@localhost upload]# id nfs-upload 
uid=2001(nfs-upload) gid=2001(nfs-upload) groups=2001(nfs-upload)
[root@localhost upload]# exportfs -r 


c、将/home/tom(该目录为uid=1111,gid=1111的tom用户的家目录)目录仅共享
给192.168.xxx.128这台主机上的jerry用户,jerry对该目录具有访问、新建和
删除文件的权限。

服务端

[root@localhost ~]# useradd -u 1111 tom  创建uid和gid为111的用户tom
[root@localhost ~]# id tom

[root@localhost ~]# vim /etc/exports   编辑配置文件
/home/tom   192.168.136.144(rw)
[root@localhost ~]# exportfs -ar     重新加载服务

客户端创建uid和gid为1111的用户Jerry

[root@client upload]# useradd jerry -u 1111
[root@client upload]# id jerry
uid=1111(jerry) gid=1111(jerry) groups=1111(jerry

                                        
[root@client ~]# mkdir /tom                 创建目录挂载测试                            
[root@client ~]# mount 192.168.136.138:/home/tom /tom
[root@client ~]# df -h

[root@client ~]# su - jerry        切换到jerry目录下
[jerry@client ~]$ cd /tom/
[jerry@client tom]$ ll
total 0
[jerry@client tom]$ touch jerry
[jerry@client tom]$ ll -d

[root@localhost ~]# ll /home/tom/ -d            到服务器端查看,uid相同看到的也是tom
drwx------. 3 tom tom 91 Aug  8 09:33 /home/tom/


4.autofs自动挂载


远程nfs服务器要的目录为/nfs/autofs
客户端的的挂载目录/data/autofs
且设置自动卸载时间为60秒

服务端

[root@localhost ~]# vim /etc/exports


[root@localhost ~]# mkdir /nfs/autofs -p
[root@localhost ~]# chmod o+w /nfs/autofs/
 

 

客户端

[root@localhost ~]# mkdir /data/autofs -p
[root@localhost ~]# vim etc/auto.master


[root@localhost ~]# vim /etc/auto.data


[root@localhost ~]# vim /etc/auto.master

 


[root@localhost ~]# vim /etc/autofs.conf


[root@localhost ~]# systemctl restart autofs

然后等待一分钟后自动卸载。

 


5.使用https来访问的web服务器:
要求使用自签名的CA签名证书(openssl, x.509) .crt
以及私钥

 

生成私钥

openssl genrsa -des3 -out myCA.key 2048
##openssl genrsa 用于生成RSA私钥,不会生成公钥,因为公钥提取自私钥 
## -des3为加密方式 
## 2048为生成秘钥长度 
## 可以加上-nodes参数,禁止进行加密,即可不运行下面的消除密码
 

创建CA签名证书 

生成私钥
openssl genrsa -out server.key 2048

创建证书签名请求

openssl req -new -key server.key -out server.csr
##Common Name应该与域名保持一致,否则会引起浏览器警告
为扩展创建一个配置文件

>server.ext cat <<-EOF 
authorityKeyIdentifier=keyid,issuer 
basicConstraints=CA:FALSE 
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment 
subjectAltName = @alt_names 
[alt_names] 
DNS.1 = www.baidu.com # Be sure to include the domain name here because Common Name is not so commonly honoured by itself 
DNS.2 = www.sougou.com # Optionally, add additional domains (I've added a subdomain here) 
IP.1 = 192.168.1.1  # Optionally, add an IP address (if the connection which you have planned requires it) EOF 
 

创建签名证书
l x509 -req -in server.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial -out server.crt -days 3650 -sha256 -extfile server.ext 

server.crt
server.key 
 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值