要求:    (1) 三者分离于两台主机;
    (2) 一个虚拟主机用于提供phpMyAdmin;另一个虚拟主机用于提供wordpress;
    (3) xcache
    (4) 为phpMyAdmin提供https虚拟主机;

HTTPD AND PHP-module: 192.168.8.16

MariDB : 192.168.8.17

(1)192.168.8.16 配置

  yum install httpd php php-mysql   (安装apache程序及php模块)

  vim /etc/httpd/conf/httpd.conf

  Listen 80   (设定监听地址及端口,格式:192.168.8.x:80  ,不输入地址默认监听本机所有端口)

  ServerName 80   (指定httpd应用程序服务域名或地址,不输入默认为本地地址80端口)  注:此处如不修改会提示serverName错误

  DocumentRoot "/var/www/html"   (指定URL映射路径)

  wq

  vim /etc/httpd/conf.d/Virtual1.conf    (添加虚拟主机1配置文件,域名为 pma.vhosts.com , 作为 phpMyAdmin 服务器)

  

 0 <VirtualHost *:80>   (监听80端口)
1 ServerName "pma.vhosts.com" (指定服务域名,也可以理解为监听的域名,当客户端访问该域名时将URL路径映射到配置文件中指定的路径下)
DocumentRoot "/web/vhosts/www1"   (指定URL映射路径)
<Directory "/web/vhosts/www1">   (权限设置允许客户端通过URL访问该目录)
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory "/tmp/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>  
ErrorLog /var/log/httpd/pma/error_log   (指定服务器错误日志路径)
CustomLog /var/log/httpd/pma/access_log combined   (指定访问日志路径及日志格式:combined)
</VirtualHost>

  

  vim /etc/httpd/conf.d/Virtual2.conf   (新增虚拟主机2配置文件,域名为 wp.vhosts.com ,做为wordpress 服务器)

  

 <VirtualHost *:>
ServerName "wp.vhosts.com"
DocumentRoot "/web/vhosts/www2"
<Directory "/web/vhosts/www2">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog "/var/log/httpd/wp/error_log"
CustomLog "/var/log/httpd/wp/access_log" combined
</VirtualHost>

  创建相关目录:

  mkdir /web/vhosts/{www1,www2} -pv

  mkdir /var/log/httpd/{wp,pma} -pv

下载 phpMyAdmin-4.0.10.20-all-languages.zip

  unzip  phpMyAdmin-4.0.10.20-all-languages.zip    (解压)

  cp -a phpMyAdmin-4.0.10.20-all-languages  /web/vhosts/www1/

  cd /web/vhosts/www1/

  ln -sv phpMyAdmin-4.0.10.20-all-languages pma   (指定软链接,客户端端通过软链接目录访问应用服务,便于日后版本更新等操作)

  cd pma

  cp config.sample.inc.php  config.inc.php

  openssl rand -base64 20    (生成20位随机字符串) 

  vim config.inc.php

  

$cfg['blowfish_secret'] = 'AzNv9me9gqEfC9Ya4rkTSHu598I'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH!  (将生成的20位字符串放入 = '此处')
*/
$cfg['Servers'][$i]['host'] = '192.168.20.243'; (指定mariadb 服务器地址) 注:需在mariadb服务器开通指定用户账号访问权限

测试:  客户端访问  pma.vhosts.com/pma   (successd)

下载 wordpress -5.0.2

  unzip wordpress-5.0.2.zip   (解压)

  cp wordpress /web/vhosts/www2/

  cd /web/vhosts/www2/

  ln -sv wordpress wp

  cd wordpress

  cp wp-config-sample.php wp-config.php

  vim wp-config.php

  

define( 'DB_NAME', '192.168.8.17' );     (指定数据库名称)

/** MySQL database username */
define( 'DB_USER', 'tom' );   (指定连接数据库用户) /** MySQL database password */
define( 'DB_PASSWORD', '' );   (指定数据库密码) /** MySQL hostname */
define( 'DB_HOST', '192.168.8.17' );   (指定数据库地址) /** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );   (数据库字符集)

测试: http://wp.vhosts.com/wp   (successd)

192.168.8.17 配置

  yum install mariadb-server

  vim /etc/my.cnf      (插入以下行)

  

 skip_name_resolve=ON
innodb_file_per_table=ON

 mysql     进入mariadb管理界面

 

grant all on *.* to 'tom'@'192.168.8.%' identified by '';     (创建用户tom,允许通过192.168.8.* 网段访问)

  如有需要可创建数据库及表

ss -tnl   :检查3306端口是否监听

压测: ab -n 100000 -c 200 http://pma.vhosts.com/pma/index.php

  

 Server Software:        Apache/2.4.6    (请求的服务版本)
Server Hostname: pma.vhosts.com  (请求的服务名称)
Server Port: 80   (请求的端口号) Document Path: /pma/index.php   (URL路径映射)
Document Length: bytes   (page size) Concurrency Level: 200    (请求并发数)
Time taken for tests: 92.017 seconds   (共使用 秒数)
Complete requests: 4992    (请求的次数)
Failed requests: 0     (失败的请求)
Write errors: 0     (网络连接写入错误数)
Total transferred: bytes   (完全传输page size)
HTML transferred: bytes   (实际传输的 page size)
Requests per second: 54.25 [#/sec] (mean)   (每 秒 多少个请求)
Time per request: 3686.596 [ms] (mean)   (平均每个用户等待多长时间)
Time per request: 18.433 [ms] (mean, across all concurrent requests)   (服务器平均用时多长时间处理)
Transfer rate: 540.61 [Kbytes/sec] received   (每秒获取多少数据) Connection Times (ms)
min mean[+/-sd] median max
Connect: 92.5
Processing: 898.9
Waiting: 784.7
Total: 901.7 Percentage of the requests served within a certain time (ms)
% 3582     (%50的用户请求 3582ms内返回)
%
%
%
%
%
%
%
% (longest request)

192.168.1.16 安装xcache

  yum install php-xcache

  vim /etc/php.d/xcache

  

 xcache.size  =               60M     (指定缓存用内存空间大小,越大缓存越多,速率越快)

  systemctl restart httpd

附录: DNS and Bind 解析配置

  yum install bind bind-utils

  vim /etc/named.conf

  

 options {
listen-on port { 192.168.20.243; 127.0.0.1; };   (指定监听地址与端口,可指定多个)
listen-on-v6 port { ::; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };   (指定允许接收的请求,any为所有) /*
- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;   (递归查询) dnssec-enable no;   (关闭dns校验)
dnssec-validation no;   (关闭dns校验)

 

  vim /etc/named.rfc1912.zone   (添加下面的行,区域配置)

  

zone "vhosts.com" IN {
type master;
file "vhosts.com.zone";
};

  vim /var/named/vhosts.com.zone     (新增解析库文件)

  

 $TTL
$ORIGIN vhosts.com.
@ IN SOA ns1.vhosts.com. admin.vhosts.com ( 2H
10M
1W
1D
)
@ IN NS ns1.vhosts.com.
ns1 IN A 192.168.20.244
pma IN A 192.168.20.242
wp IN A 192.168.20.242

  测试配置文件

[root@test ~]# named-checkconf
[root@test ~]# named-checkzone vhosts.com /var/named/vhosts.com.zone
zone vhosts.com/IN: loaded serial
OK

  启动并测试

  

 [root@test ~]# systemctl start named
[root@test ~]# dig -t A pma.vhosts.com ; <<>> DiG 9.11.-P2-RedHat-9.11.-.P2.el7 <<>> -t A pma.vhosts.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id:
;; flags: qr aa rd ra; QUERY: , ANSWER: , AUTHORITY: , ADDITIONAL: ;; OPT PSEUDOSECTION:
; EDNS: version: , flags:; udp:
;; QUESTION SECTION:
;pma.vhosts.com. IN A ;; ANSWER SECTION:
pma.vhosts.com. IN A 192.168.20.242 ;; AUTHORITY SECTION:
vhosts.com. IN NS ns1.vhosts.com. ;; ADDITIONAL SECTION:
ns1.vhosts.com. IN A 192.168.20.244 ;; Query time: msec
;; SERVER: 192.168.20.243#(192.168.20.243)
;; WHEN: Tue Feb :: EST
;; MSG SIZE rcvd:

192.168.8.16    为phpmyadmin 提供https虚拟主机

  (模拟  CA服务器:192.168.8.18)

  cd /etc/pki/CA/

  

 [root@test]# (umask 077;openssl genrsa -out private/cakey.pem 4096)   (生成4096位私钥文件 cakey.pem)
Generating RSA private key, bit long modulus
......................................................................................................................++
...........................................................................................................++
e is (0x10001)
[root@test ]# openssl req -new -key private/cakey.pem -out httpd.csr -days 365   (生成证书签署请求文件) 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 ( letter code) [XX]:CN
State or Province Name (full name) []:GD
Locality Name (eg, city) [Default City]:SZ
Organization Name (eg, company) [Default Company Ltd]:DaWanQu
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:pma.vhosts.com   (此处指定服务域名一定要与指定访问的域名一致,否则客户端会验证不通过)
Email Address []: Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@centos7 CA]# scp httpd.csr root@192.168.8.18:/etc/pki/CA/   (将证书签署请求拷贝到CA服务器/etc/pki/CA/ 目录下)
The authenticity of host '192.168.8.18 (192.168.8.18)' can't be established.
ECDSA key fingerprint is SHA256:FKhie5UQHlmOtTV/TZol/k7UIf0nfDRosf2smlFoXak.
ECDSA key fingerprint is MD5:1b::4c:eb:5f::7d:a8::d3:be::b1:::.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.8.18' (ECDSA) to the list of known hosts.
root@192.168.8.18's password:
httpd.csr % .4MB/s :
[root@test ]#

 192.168.8.18

  CA 主机上配置

  cd /etc/pki/CA/

  

 [root@bogon CA]# (umask ;openssl genrsa -out private/cakey.pem )   (生成4096位私钥文件)
Generating RSA private key, bit long modulus
...........................++
......................................................................................................................................................................................................................................................................................++
e is (0x10001)
[root@bogon CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 365   (生成CA服务器自签证书, -days为证书有效期天数)
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 ( letter code) [XX]:CN
State or Province Name (full name) []:GD
Locality Name (eg, city) [Default City]:SZ
Organization Name (eg, company) [Default Company Ltd]:DaWanQu
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:DaWanQu
Email Address []: [root@bogon CA]# touch ./{serial,index.txt}   (创建签署证书必需文件)
[root@bogon CA]# echo > serial   (写入序列号01) [root@bogon CA]# openssl ca -in httpd.csr -out httpd.crt -days   (签署httpd.csr 证书 ,输出为 httpd.crt)
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: (0x1)
Validity
Not Before: Feb :: GMT
Not After : Feb :: GMT
Subject:
countryName = CN
stateOrProvinceName = GD
organizationName = DaWanQu
organizationalUnitName = Ops
commonName = pma.vhosts.com
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
CA:A9::E2:::4C:::EE::D3::C1:B6:0B::::
X509v3 Authority Key Identifier:
keyid:E7::::::6E:5A::ED:6A:FF::D3:F4:::C5:B6:CE Certificate is to be certified until Feb :: GMT ( days)
Sign the certificate? [y/n]:yes out of certificate requests certified, commit? [y/n]yes
Write out database with new entries
Data Base Updated
67 [root@bogon CA]# scp httpd.crt root@192.168.8.16:/etc/pki/CA/   (将签署完成的证书文件拷贝到httpd服务器)
The authenticity of host '192.168.8.16 (192.168.8.16)' can't be established.
ECDSA key fingerprint is SHA256:I9f09gGvg6Zr5JFDYPLO5VKiAZ/Fzmy1F37f1SLgzkI.
ECDSA key fingerprint is MD5::::9f:f0:b0:9e::c0::ad::3f:be::.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.8.16' (ECDSA) to the list of known hosts.
root@192.168.8.16's password:
/etc/profile.d/vimrc.sh: line : autocmd: command not found
/etc/profile.d/vimrc.sh: line : syntax error near unexpected token `('
/etc/profile.d/vimrc.sh: line : `func SetTitle()'
httpd.crt % .9MB/s :
[root@bogon CA]#

  

192.168.8.16  httpd主机配置

  yum install mod_ssl    (安装ssl支持模块)

  vim /etc/httpd/conf.d/ssl.conf   

  

Listen  https   (默认监听443端口)

#
DocumentRoot "/web/vhosts/www1"   (SSL 连接URL映射路径)
ServerName "pma.vhosts.com"   (服务域名) <Directory "web/vhosts/www1">     (授权URL映射路径允许访问)
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory> SSLCertificateFile /etc/pki/CA/httpd.crt   (指定证书文件路径)
SSLCertificateKeyFile /etc/pki/CA/private/cakey.pem   (指定私钥文件路径)

 

客户机配置

  将ca服务器自签证书导入到浏览器受信根证书中

 测试: https://pma.vhosts.com/pma/        (google浏览器测试不成功,火狐浏览器与IE测试成功)

  

  

   

lamp-module的更多相关文章

  1. LAMP 搭建练习

    目录 LAMP 搭建 1:CentOS 7, lamp (module): http + php + phpMyAdmin + wordpress 192.168.1.7 配置虚拟主机 xcache ...

  2. LAMP的搭建与简易配置(apache,php已module方式结合)

    测试所用环境:centos7.2 apache php 所在主机IP:9.110.187.120 mariadb 所在主机IP:9.110.187.121 第一部分:环境搭建 yum安装软件包 其中a ...

  3. LAMP.md

    LAMP Linux+Apache+Mysql/MariaDB+Perl/PHP/Python一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越 ...

  4. CentOS6.3 编译安装LAMP(2):编译安装 Apache2.2.25

    所需源码包: /usr/local/src/Apache-2.2.25/httpd-2.2.25.tar.gz 编译安装 Apache2.2.25 #切换到源码目录 cd /usr/local/src ...

  5. 再不写,我怕就再也不写了-LAMP基础

    hi 经历了4天大餐的洗礼,整个人都思密达了...昨天的懒,是没有原因的懒,总之就是该提笔了亲 1.Ubuntu下的LAMP配置 -----Ubuntu基础知识----- ----管理员权限 出于安全 ...

  6. 年终福利,PHP7+Apache2.4+MySQL5.6 源码编译安装,环境配置,搭建你自己的LAMP环境

    PHP7 都出来了,你还在玩PHP5吗? MySQL5.6 早都出来了,你还在玩MySql5.2吗? Apache2.4 早都出来了,你还在玩Apache2.2吗? 笔者不才,愿意亲自搭建环境,供搭建 ...

  7. 部署lamp服务器

    系统:CentOS 6.5 64位 1.卸载旧版本软件 rpm -qa | grep mysql #查询是否已经安装MySQL,如有执行下面的操作将其全部删除 rpm -e mysql --nodep ...

  8. (原创)LAMP搭建之二:apache配置文件详解(中英文对照版)

    LAMP搭建之二:apache配置文件详解(中英文对照版) # This is the main Apache server configuration file. It contains the # ...

  9. 在Debian下安装LAMP

    准备工作: 1 sudo apt-get install build-essential 第一步:安装Apache 1 sudo apt-get install apache2 第二步:安装MySQL ...

  10. lamp环境centos6.4

    http://www.centos.bz/2011/09/centos-compile-lamp-apache-mysql-php/comment-page-1/#comments 编译安装: 首先卸 ...

随机推荐

  1. 用Jackson进行Json序列化时的常用注解

    Jackson时spring boot默认使用的json格式化的包,它的几个常用注解: @JsonIgnore 用在属性上面,在序列化和反序列化时都自动忽略掉该属性 @JsonProperty(&qu ...

  2. struts标签 解析html标签

    参考:http://blog.csdn.net/shuangrenyu1234/article/details/24527745

  3. IDEA 在同一工作空间创建多个项目

    1.创建项目 二..创建工作空间 JavaWorkspace 1.File-> New Project -> 创建工作空间 JavaWorkspace,并 顺便创建项目 JavaOne 2 ...

  4. [经验] Java Web 项目怎么部署到 Linux 系统上

    废话少说, 直奔主题 第一步: 将 web 项目打成 war 包 1: 打开项目的 pom.xml 文件 如果是迭代后的项目, 记得修改项目的版本号, 这里我的是第二版所有就把 1 改成了 2 2: ...

  5. 常用的sql指令

    一,关于数据库中表的一些介绍 1,表的每一行表示关系的一个元组,又称记录: 2,表的每一列表示关系的一个字段,又称属性(例如:id.name.password........): 3,  表结构:表的 ...

  6. 在Centos 7.7下用minikube部署单节点kubernetes.

    centos8 下用yum安装docker-ce会报错,说明docker-ce对centos8支持还不太好.所以在centos7.7下安装 先更新一下系统 yum update 安装 yum工具,   ...

  7. 定位(left 、right 、top 、 bottom)、padding、margin 值设为百分比值时

    定位(left .right .top . bottom): top 为例 right 为例 padding.margin : 当padding.margin 值设为百分比值时,其百分比会相对于父元素 ...

  8. shell脚本中执行sql脚本(mysql为例)

    1.sql脚本(t.sql) insert into test.t value ("LH",88); 2.shell脚本(a.sh     为方便说明,a.sh与t.sql在同一目 ...

  9. 与Python的第一次见面

    1.Python的起源 Python的作者,Guido von Rossum,确实是荷兰人.1982年,Guido从阿姆斯特丹大学(University of Amsterdam)获得了数学和计算机硕 ...

  10. oracle中 lob类型

    LOB大型对象(大数据字段类型) 分为:-BLOB: Binary 二进制大型对象 ,适用于存非文本型数据(程序,图像,影音) -CLOB:Character  字符型大型对象,适用于存储文本型数据( ...