#下面我们要给第2台物理主机的第2个虚拟主机上的php-myadmin提供https服务;
#签署CA证书并为phpmyadmin提供https服务;
#在第一台主机上安装mod_ssl模块 因为需要http来加载模块并启动443端口
[root@localhost CA]# yum install mod_ssl.x86_64
#然后在第2台主机上生成CA自签名证书;
1、生成密钥
#首先进入CA目录下
[root@1 wordpress]# cd /etc/pki/CA/
#在CA目录下生成密钥
[root@1 CA]# (umask 077; openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus
............................................................................+++
...............+++
e is 65537 (0x10001)
2、生成自签证书
[root@1 CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:beijing
Locality Name (eg, city) [Default City]:beijing
Organization Name (eg, company) [Default Company Ltd]:wufeng
Organizational Unit Name (eg, section) []:ops
Common Name (eg, your name or your server's hostname) []:ca.wufeng.com
Email Address []:admin@wufeng.com
补充文件
[root@1 CA]# touch index.txt
[root@1 CA]# echo 01 > serial
、
#然后在去第1台主机上生成请求签署文件以及密钥
在/etc/httpd/目录下创建一个目录
~]# mkdir ssl
~]# cd ssl
生成密钥
[root@1 ssl]# (umask 077; openssl genrsa -out httpd.key 1024)
Generating RSA private key, 1024 bit long modulus
.++++++
........................................++++++
e is 65537 (0x10001)
生成签署请求文件:
[root@1 ssl]# openssl req -new -key httpd.key -out httpd.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:beijing
Locality Name (eg, city) [Default City]:beijing
Organization Name (eg, company) [Default Company Ltd]:wufeng
Organizational Unit Name (eg, section) []:ops
Common Name (eg, your name or your server's hostname) []:www2.wufeng.com 这个要和客户访问要加密的主机名一样
Email Address []:www1admin@wufeng.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
复制给CA主机签署证书
[root@1 ssl]# scp httpd.csr 172.16.100.32:/tmp
然后到centos7主机上签署文件
[root@2 CA]# openssl ca -in /tmp/httpd.csr -out /etc/pki/CA/certs/httpd.crt
连续2个yes 简写y
最后可以做个压力测试
首先做httpd主机的静态数据测试:html
[root@localhost ~]# ab -c 100 -n 1000 http://www1.wufeng.com/data/vhost/www1/index.html 静态数据
Time per request: 21.244 [ms] (mean) 十次的测试数据稳定在这个数值
Time per request: 0.212 [ms] (mean, across all concurrent requests)
Transfer rate: 1995.00 [Kbytes/sec] received
#动态数据测试info() php
[root@localhost ~]# ab -c 100 -n 1000 http://www1.wufeng.com/data/vhost/www1/index.php
Concurrency Level: 100
Time taken for tests: 0.523 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 226000 bytes
HTML transferred: 16000 bytes
Requests per second: 1913.59 [#/sec] (mean)
Time per request: 52.258 [ms] (mean) 十次的测试数据稳定在这个数值
Time per request: 0.523 [ms] (mean, across all concurrent requests)
Transfer rate: 422.33 [Kbytes/sec] received
#测试wordpress动态数据
[root@localhost ~]# ab -c 100 -n 1000 http://www1.wufeng.com/data/vhost/www1/wordpress/index.php
Concurrency Level: 100
Time taken for tests: 0.517 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 226000 bytes
HTML transferred: 16000 bytes
Requests per second: 1934.61 [#/sec] (mean)
Time per request: 51.690 [ms] (mean) 十次的测试数据稳定在这个数值
Time per request: 0.517 [ms] (mean, across all concurrent requests)
Transfer rate: 426.97 [Kbytes/sec] received
#动态测试myadmin数据
[root@localhost ~]# ab -c 100 -n 1000 http://www2.wufeng.com/data/vhost/www2/myadmin/index.php
Document Path: /data/vhost/www2/myadmin/index.php
Document Length: 16 bytes
Concurrency Level: 100
Time taken for tests: 0.520 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 226000 bytes
HTML transferred: 16000 bytes
Requests per second: 1923.43 [#/sec] (mean)
Time per request: 51.990 [ms] (mean) 十次的测试数据稳定在这个数值
Time per request: 0.520 [ms] (mean, across all concurrent requests)
Transfer rate: 424.51 [Kbytes/sec] received
#友情提示不要太奔放 比如:
[root@localhost ~]# ab -c 1000 -n 10000 http://www2.wufeng.com/data/vhost/www2/index.php
然后第2台 php主机就挂了