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. Kibana:分析及可视化日志文件
  2. javascript的族家族史
  3. rocketmq中的broker设计与实现
  4. 给力!神策数据创新推出数字化运营闭环解决方案!
  5. python -- lambda表达式
  6. 从LeNet到SENet——卷积神经网络回顾
  7. python 向MySQL里插入中文数据
  8. 【转】outlook 2007 如何设置开机自动启动
  9. ABAP 内表(internal table) 标题行(header line) 工作区(work area) 简介 - [SAP]
  10. c语言游戏小型程序代码,C语言小游戏源码
  11. 用python 数据分析,有推荐的书籍或资料吗?
  12. 12种 vo2dto 方法,就 BeanUtils.copyProperties 压测最拉胯!【快双11了,别用错喽】
  13. 四、网络层(一)网络层的功能
  14. 计算机老师中专教学论文,中专计算机多元化教学论文
  15. Graphics2D进行后台绘图
  16. hilink互联技术_华为负重前行,打出王炸HiLink技术,引爆国内生态链格局
  17. eclipse中字体大小及背景颜色设置
  18. K-Means算法的收敛性和如何快速收敛超大的KMeans?
  19. GRE考试词汇平静类
  20. 关于matlab licence许可到期问题

热门文章

  1. ST电机库v5.4.4源代码分析(4): 电角度和力矩方向分析(Hall传感器)
  2. Spring框架(一)—— Spring 简介
  3. 三菱m60系统波特率怎么设置_三菱 M60 三菱-M60 M60S series 操作 手册
  4. matlab hanning窗口怎么使用,在Python和Matlab中,Hanning窗口值不匹配
  5. JAVA环境与ECLIPSE的安装+代码上传至GITHUB(超详细!!!)
  6. 做短视频的必备工具和素材网,一部手机就能做,稳定收益200多
  7. 想入手显示器,恳请粉丝带我推荐,必有重谢!
  8. 链家网php技术笔试题,链家网 18秋招技术岗模拟测试
  9. 常用字符集及字符编码和Charset类
  10. 唐朔飞版本计算机组成原理(第二版)各章知识点思维导图