LAMP的搭建:

使用两台虚拟机,一台虚拟机安装httpd及php,把php作为模块编译进httpd中,另一台安装mysql,让php能调用mysql来读取数据。

虚拟机1:172.18.250.76  Centos6.7        安装httpd、php

虚拟机2:172.18.250.10  Centos6.7        安装mysql

利用httpd创建两基于域名的虚拟主机,分别运行wordpress博客和phpmyadmin数据库。

一:yum安装httpd[root@localhost ~]# yum -y install httpd

1、编辑配置文件,注释DocumentRoot[root@localhost ~]# vim /etc/httpd/conf/httpd.conf

#DocumentRoot "/var/www/html"

2、创建虚拟主机文件,编辑文件[root@localhost php]# vim /etc/httpd/conf.d/vhost.conf

NameVirtualHost 172.18.250.76:80

ServerName www.a.com

DocumentRoot "/www/blog"

Options None

Allowoverride None

Order allow,deny

allow from all

ServerName www.b.net

DocumentRoot "/www/php"

Options None

Allowoverride None

Order allow,deny

allow from all

3、启动httpd服务,查看监听端口[root@localhost php]# netstat -ntlp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address       Foreign Address     State     PID/Program name

tcp       0     0    :::80                   :::*           LISTEN      2201/httpd

4、创建虚拟主机路径,并验证能否正常访问[root@localhost conf.d]# mkdir -p /www/blog

[root@localhost conf.d]# mkdir -p /www/php

[root@localhost conf.d]# cd /www/php

[root@localhost php]# echo "

[root@localhost conf.d]# cd /www/blog

[root@localhost blog]# echo "www.a.com">index.html

重启httpd服务,验证:

二、yum安装php[root@localhost php]# yum -y install php

[root@localhost php]# httpd -M    //查看httpd所加载的模块

php5_module (shared)             //php已经编辑进httpd

验证php能否正常加载:[root@localhost php.d]# vim /www/blog/index.php

phpinfo();

?>

三、安装mysql[root@lsj ~]# yum -y install mysql-server

[root@lsj ~]# service mysqld start

授权一个远程账号,让PHP能访问mysqlmysql> grant all on *.* to admin@'172.18.250.76' identified by "admin";

安装mysql驱动,支持php远程[root@localhost modules]# yum -y install php-mysql

[root@localhost modules]# vim /www/blog/index.php

$conn = mysql_connect ('172.18.250.10','admin','admin');

if ($conn)

echo "success";

else

echo "false"

?>

四、安装wordpress和phpmyadmin软件[root@localhost wordpress]# unzip wordpress-4.3.1-zh_CN.zip

[root@localhost blog]# cd wordpress

[root@localhost wordpress]# cp wp-config-sample.php wp-config.php

[root@localhost wordpress]# vim wp-config.php

/** WordPress数据库的名称 */

define('DB_NAME', 'mytest');

/** MySQL数据库用户名 */

define('DB_USER', 'admin');

/** MySQL数据库密码 */

define('DB_PASSWORD', 'admin');

/** MySQL主机 */

define('DB_HOST', '172.18.250.10');

验证能都正常登陆:

登陆博客:

[root@localhost blog]# cd /www/php/

[root@localhost php]# unzip phpMyAdmin-4.4.14.1-all-languages.zip

[root@localhost php]# ln -s phpMyAdmin-4.4.14.1-all-languages pma

生成一段随机数,用作登陆phpmyadmin[root@localhost pma]# cp config.sample.inc.php config.inc.php

[root@localhost pma]# openssl rand -base64 30

d8yhR7wOU5+HzeZjGEusyAmNiQv/+rTzWQuoDiCR

[root@localhost pma]# vim config.inc.php

$cfg['blowfish_secret'] = 'd8yhR7wOU5+HzeZjGEusyAmNiQv/+rTzWQuoDiCR';

$cfg['Servers'][$i]['host'] = '172.18.250.10';

验证网页是否能打开:

安装个php-mbstring,支持中文字符集[root@localhost pma]# rpm -ivh php-mbstring-5.3.3-40.el6_6.x86_64.rpm

刷新页面:

输入刚才授权的账号密码:

。。。。。。

解决思路:1、升级mysql版本。2、降级phpmyadmin版本。

降低版本的方法:[root@localhost pma]# cd libraries/

[root@localhost libraries]# vim common.inc.php

if (PMA_MYSQL_INT_VERSION

改成

if (PMA_MYSQL_INT_VERSION

再次刷新,输入账号密码:

OK,数据库登录成功。

五、安装Xcache对php进行加速[root@localhost libraries]# yum -y install php-xcache

1、先测试没开启加速前的请求速度:[root@localhost setup]# ab -n100 -c10 http://172.18.250.76/wordpress/index.php

Benchmarking 172.18.250.76 (be patient).....done

Server Software:        Apache/2.2.15

Server Hostname:        172.18.250.76

Server Port:            80

Document Path:          /wordpress/index.php

Document Length:        0 bytes

Concurrency Level:      10

Time taken for tests:   4.792 seconds

Complete requests:      100

Failed requests:        0

Write errors:           0

Non-2xx responses:      100

Total transferred:      36800 bytes

HTML transferred:       0 bytes

Requests per second:    20.87 [#/sec] (mean)

Time per request:       479.161 [ms] (mean)

Time per request:       47.916 [ms] (mean, across all concurrent requests)

Transfer rate:          7.50 [Kbytes/sec] received

Connection Times (ms)

min  mean[+/-sd] median   max

Connect:        0    1   3.8      0      20

Processing:   143  459 331.6    352    1783

Waiting:      143  458 331.6    343    1783

Total:        143  460 331.4    360    1783

Percentage of the requests served within a certain time (ms)

50%    360

66%    405

75%    512

80%    581

90%    895

95%   1375

98%   1720

99%   1783

100%   1783 (longest request)

2、重启httpd服务,开启Xcache,在测试下[root@localhost setup]# ab -n100 -c10

Benchmarking 172.18.250.76 (be patient).....done

Server Software:        Apache/2.2.15

Server Hostname:        172.18.250.76

Server Port:            80

Document Path:          /wordpress/index.php

Document Length:        0 bytes

Concurrency Level:      10

Time taken for tests:   1.659 seconds

Complete requests:      100

Failed requests:        0

Write errors:           0

Non-2xx responses:      100

Total transferred:      36800 bytes

HTML transferred:       0 bytes

Requests per second:    60.27 [#/sec] (mean)   //三倍加速请求

Time per request:       165.908 [ms] (mean)

Time per request:       16.591 [ms] (mean, across all concurrent requests)

Transfer rate:          21.66 [Kbytes/sec] received

Connection Times (ms)

min  mean[+/-sd] median   max

Connect:        0    1   2.6      0      10

Processing:    41  158  27.5    158     235

Waiting:       40  158  27.6    158     235

Total:         41  159  28.7    158     245

Percentage of the requests served within a certain time (ms)

50%    158

66%    166

75%    168

80%    171

90%    192

95%    213

98%    240

99%    245

100%    245 (longest request)

六:对访问phpmyadmin网页时进行SSL加密认证

签证及CA认证是怎么进行可以参考我的博文:Linux中加密解密技术及CA认证

1、先下载mod_ssl模块,因为httpd2.2没包含这个模块[root@localhost ssl]# yum -y install mod_ssl

2、编辑/etc/httpd/conf.d/ssl.conf文件[root@localhost ssl]# vim /etc/httpd/conf.d/ssl.conf

DocumentRoot "/www/php"      //取消注释,修改虚拟主机的url

ServerName      //虚拟主机名

SSLEngine on                 //确保为on

SSLCertificateFile /etc/httpd/ssl/httpd.crt       //存放签署的证书

SSLCertificateFile /etc/httpd/ssl/httpd.key       //存放私钥的位置

3、重启httpd服务器,查看443端口是否启用[root@localhost ssl]# netstat -ntlp

tcp    0   0 :::443          :::*                        LISTEN      6080/httpd

4、验证页面是否能访问

5、从虚拟机把CA证书下载到windows主机上[root@www CA]# sz cacert.pem

6、把证书导入到浏览器当中

7、重新打开浏览器,输入虚拟主机名:

yum php xcache,yum安装lamp及Xcache加速相关推荐

  1. 安装LAMP环境(PHP5.4)

    # 更新Linux到最新内核 yum update -y # 更改时区cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime # 安装时间同步 y ...

  2. linux - centos yum安装LAMP环境

    1. centos 7.2 一般机器都带yum命令,并且yum包源都是可以用的,直接yum -y install 后面加上你所需要安装的软件,他会自动下载自动安装,非常方便. 例如 yum -y in ...

  3. 利用yum 安装 lamp环境搭载 cacti监控和memcached数据库

    今天测试了一下yum安装lamp和cacti监/控已经memcached数据库 首先介绍下我的系统环境 centos6.7 x86-64 1安装cacti yum install cacti 安装ca ...

  4. CentOS 6.5系统使用yum方式安装LAMP环境和phpMyAdmin,mysql8.0.1/mysql5.7.22+centos7,windows mysql安装、配置...

    介绍如何在CentOs6.2下面使用YUM配置安装LAMP环境,一些兄弟也很喜欢使用编译的安装方法,个人觉得如果不是对服务器做定制,用yum安装稳定简单,何必去download&make&am ...

  5. yum php mysql5.5_CentOS 5.5使用yum来安装LAMP(php运行环境)

    CentOS 5.5使用yum来安装LAMP(php运行环境) 更新时间:2010年09月10日 21:05:37   作者: 今天用yum方法搭建起了个LAMP环境,中间遇到了很多问题,经过goog ...

  6. centos 7 YUM 安装LAMP 环境

    centos 7 YUM 安装LAMP 环境 两种安装方式: 使用163yum源,或阿里的yum源,或者搭建本地yum源 由于centos 7自带的yum 源是国外的,国内无法访问, 搭建使用 163 ...

  7. centos(7) 使用yum进行安装lamp环境

    1.用yum安装Apache,Mysql,PHP. 1.1安装Apache yum install httpd httpd-devel 安装完成后,用service httpd start 1.2 安 ...

  8. CentOS 6.4 yum安装LAMP环境

    一.制作连外网的yum源文件 1.  centOS安装完成时是默认存在的,不需要做任何操作,可以直接使用yum 命令进行操作, 默认是在 /etc/yum.repos.d/目录下的 2. 如果你因为制 ...

  9. yum 快速安装 LAMP

    安装APACHE yum -y install httpd 安装PHP yum -y install php 安装MYSQL yum install -y mysql-server 让PHP支持MYS ...

最新文章

  1. fir抽取滤波器matlab,Xilinx FPGA之抽取FIR滤波器的实现
  2. Java泛型编程基础
  3. RPM vs SRPM
  4. Python从头/尾删除子符串的正确操作
  5. maven报错解决: -source 1.5 中不支持 diamond 运算符
  6. 《混合云计算》——2.2 结合服务创建混合云环境
  7. Intel PAUSE指令变化影响到MySQL的性能,该如何解决?
  8. openerp child_of操作符深度解析
  9. FreeBSD BSDiff 被曝高危内存损坏漏洞,时隔4年终修复
  10. vue查询列表中所有用户信息_vue实现全匹配搜索列表内容
  11. 洛谷 P1164:小A点菜(DP/DFS)
  12. (转)听赌徒谈风险:没犯任何错误照样输个精光
  13. 一阶线性微分方程的初等积分法例题
  14. 连续投影算法_腾讯优图 | 3D结构光摄像头深度算法综述
  15. linux下录音识别成文字软件下载,如何将录音转换成文字,这个方法你需要知道...
  16. 学习软件设计模式的书籍
  17. 大学离散数学作业用代码怎么写?用Python判断离散数学的自反、对称、传递、符合、自反闭包、函数及其类型直接上代码配超详细注释以及源码下载地址 =_= python大学任务
  18. 线段树,方差,数学(Variance,玲珑杯 Round#5 H lonlife 1063)
  19. Joel 技术分享心得
  20. ShareSDK 抖音平台注册

热门文章

  1. 两万多字诠释python最经典基础算法之100题【内含思路、程序和答案】【python初学者必备】
  2. 说说今天刷Nvidia TX2踩的坑
  3. JSBox 基础接口 获取IOS信息 device
  4. 泰丰智能IPO过会:年营收6亿 王振华家族控制58%股权
  5. 单片机c语言 常用英语,数码管单片机c语言程序设计(国外英语资料).doc
  6. HEXO博客系统添加搜索功能
  7. 手机APP商城定制开发对于企业有哪些好处
  8. java编程之图片处理
  9. 【c++】拼音转数字
  10. html声明charset=“utf-8“后,浏览器访问中文依旧乱码的问题解决(绝对有效)