[root@localhost local]# tar -xf xcache-3.2.0.tar.bz2
[root@localhost xcache-3.2.0]# man -M /usr/local/php/php/man phpize 查看帮助文档
[root@localhost xcache-3.2.0]# /usr/local/php/bin/phpize
[root@localhost xcache-3.2.0]# man -M /usr/local/php/php/man php-config查看帮助文档
[root@localhost xcache-3.2.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
[root@localhost xcache-3.2.0]# make
[root@localhost xcache-3.2.0]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
[root@localhost xcache-3.2.0]#
[root@localhost php-5.6.24]# mkdir /etc/php.d
[root@localhost xcache-3.2.0]# cp xcache.ini /etc/php.d/ 为xcache拷贝一个配置文件
[root@localhost xcache-3.2.0]# vim /etc/php.d/xcache.ini
[xcache-common] 定义zend扩展
将安装xcache后的Installing shared extensions路径写在 zend_extension里
extension = /usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so
[xcache.admin] 定义xcache的管理
[xcache]
xcache.shm_scheme = "mmap" 实用哪种方式来共享内存 mmap:内存映射
xcache.size = 60M 缓存空间大小
xcache.count = 1 设置CPU个数
xcache.ttl = 0 过期时间
xcache.gc_interval = 0 垃圾回收器多长时间工作一次
xcache.var_size = 4M xcache的变量缓存空间大小
xcache.var_count = 1 缓存多少个
xcache.var_slots = 8K
xcache.cacher = On
xcache.stat = On 缓存功能是否启用
xcache.optimizer = Off xcache自身的优化器是否启动
要让 xcache重新生效,需要重启apache服务
------------------------------------------
解决:php扩展报错:Cannot find config.m4.
cd /usr/local/php-5.3.28/ext/
./ext_skel --extname=sdomain
cd sdomain/
mv config.m4 /usr/local/php/bin/
-------------------------
启动php虚拟主机:
[root@localhost local]# vim /etc/httpd/httpd.conf
#DocumentRoot "/usr/local/apache/htdocs" 禁用
#Virtual hosts
Include /etc/httpd/extra/httpd-vhosts.conf 启用虚拟主机
[root@localhost local]# vim /etc/httpd/extra/httpd-vhosts.conf 配置虚拟主机配置文件
# Required modules: mod_log_config 此提示需要启动mod_log_config
[root@localhost local]# vim /etc/httpd/httpd.conf 默认已经启用
[root@localhost local]# mkdir /www/{a.org,b.net} -pv
mkdir: created directory `/www‘
mkdir: created directory `/www/a.org‘
mkdir: created directory `/www/b.net‘
[root@localhost local]# mkdir /var/log/httpd/
[root@localhost local]# vim /etc/httpd/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/www/a.org"
<Directory "/www/a.org">
Options none
AllowOverride none
Require all granted 允许所有人访问
</Directory>
ServerName www.a.org
ErrorLog "/var/log/httpd/a.org-erro_log"
CustomLog "/var/log/httpd/a.org-access_log" combined
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/www/b.net"
<Directory "/www/b.net">
Options none
AllowOverride none
Require all granted
</Directory>
ServerName w
ServerName www.b.net
ErrorLog "/var/log/httpd/b.net-erro_log"
CustomLog "/var/log/httpd/b.net-access_log" combined
</VirtualHost>
重启apache服务
ab压力测试:
[root@localhost bin]# echo "<h1>www.a.org<h1>" > /www/a.org/index.html
[root@localhost bin]# echo "<h1>www.b.net<h1>" > /www/b.net/index.html
[root@localhost apache]# ./bin/ab httpd压力测试工具
ab -c 指定并发量,一次请求多少个
-n 指定一共要请求多少个
[root@localhost apache]# ./bin/ab -c 100 -n 1000 http://www.a.org/index.html
Server Software: Apache/2.4.23
Server Hostname: www.a.org
Server Port: 80
Document Path: /index.html
Document Length: 18 bytes
Concurrency Level: 1000 并发量
Time taken for tests: 27.089 seconds 所花费的时间
Complete requests: 48089 成功得到请求个数
Failed requests: 0 多少个失败
Total transferred: 13128570 bytes 服务器响应的整体数据大小
HTML transferred: 865620 bytes
Requests per second: 1775.20 [#/sec] (mean) 每秒钟完成的请求数
Time per request: 563.316 [ms] (mean) 每从并发请求平均花费的时间
Time per request: 0.563 [ms] (mean, across all concurrent requests) 单个平均时间
Transfer rate: 473.28 [Kbytes/sec] received 传输速率,每秒钟传输多少个字节。通过ab测试算出所需要的带宽
Connection Times (ms)
min mean[+/-sd] median max
Connect: 19 239 379.2 133 7574
Processing: 21 305 864.8 138 14983
Waiting: 2 259 843.4 106 14863
Total: 97 544 1005.6 246 15051
min 最短多少毫秒
mean平均多少毫秒
max 最长多少毫秒
Percentage of the requests served within a certain time (ms)
[root@localhost etc]# cp /etc/services /www/a.org/text.html 复制一个大点的主页版给httpd进行测试
[root@localhost bin]# ./ab -c 100 -n 10000 http://www.a.org/text.html
Server Software: Apache/2.4.23
Server Hostname: www.a.org
Server Port: 80
Document Path: /text.html
Document Length: 641020 bytes
Concurrency Level: 100
Time taken for tests: 21.618 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 6412820000 bytes
HTML transferred: 6410200000 bytes
Requests per second: 462.58 [#/sec] (mean)
Time per request: 216.180 [ms] (mean)
Time per request: 2.162 [ms] (mean, across all concurrent requests)
Transfer rate: 289690.60 [Kbytes/sec] received 282M*8=2263M 所以需要大约2500M的带宽
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 38 25.7 33 216
Processing: 60 178 60.6 154 429
Waiting: 0 34 26.5 30 213
Total: 66 216 73.3 176 486
Percentage of the requests served within a certain time (ms)
50% 176
66% 217
75% 302
80% 316
90% 330
95% 343
98% 386
99% 435
100% 486 (longest request)
[root@localhost a.org]# dd if=/dev/zero of=/www/a.org/text2.html count=20 bs=1M
[root@localhost a.org]# /usr/local/apache/bin/ab -r -c 100 -n 1000 http://www.a.org/text2.html
Server Software: Apache/2.4.23
Server Hostname: www.a.org
Server Port: 80
Document Path: /text2.html
Document Length: 2097152 bytes
Concurrency Level: 100
Time taken for tests: 9.764 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 2097416000 bytes
HTML transferred: 2097152000 bytes
Requests per second: 102.42 [#/sec] (mean)
Time per request: 976.402 [ms] (mean)
Time per request: 9.764 [ms] (mean, across all concurrent requests)
Transfer rate: 209776.01 [Kbytes/sec] received 209775.01/1024 *8=所需带宽
Connection Times (ms)
min mean[+/-sd] median max
Connect: 14 84 38.8 84 215
Processing: 743 891 65.8 888 1090
Waiting: 1 64 40.4 62 216
Total: 871 975 55.1 972 1112
Percentage of the requests served within a certain time (ms)
50% 972
66% 976
75% 982
80% 1003
90% 1107
95% 1110
98% 1110
99% 1111
100% 1112 (longest request)
[root@localhost b.net]# unzip phpMyAdmin-3.5.1-all-languages.zip
[root@localhost b.net]# mv phpMyAdmin-3.5.1-all-languages/ pma
[root@localhost pma]# cp config.sample.inc.php config.inc.php 复制一个配置文件
[root@localhost pma]# openssl rand -base64 20 生成随机数
eyQFSUT16JqsijjSCZdDfkpYLf4=
[root@localhost pma]# vim config.inc.php
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg[‘blowfish_secret‘] = ‘eyQFSUT16JqsijjSCZdDfkpYLf4=‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
http://www.b.net/pma/
[root@localhost pma]# mysqladmin -uroot password ‘root‘; 为数据库设置密码
[root@localhost pma]# /usr/local/apache/bin/ab -c 500 -n 5000 http://www.b.net/pma/index.php
启用ssl功能
[root@localhost pma]# vim /etc/httpd/httpd.conf
LoadModule ssl_module modules/mod_ssl.so 启用此模块
Include /etc/httpd/extra/httpd-ssl.conf 启用
[root@localhost pma]# vim /etc/httpd/extra/httpd-ssl.conf
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "/www/a.org"
ServerName www.a.org
ServerAdmin you@example.com
ErrorLog "/usr/local/apache/logs/error_log"
TransferLog "/usr/local/apache/logs/access_log"
SSLCertificateFile "/etc/httpd/server.crt" 证书文件位置
#SSLCertificateFile "/etc/httpd/server-dsa.crt"
#SSLCertificateFile "/etc/httpd/server-ecc.crt"
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you‘ve both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
# ECC keys, when in use, can also be configured in parallel
SSLCertificateKeyFile "/etc/httpd/server.key" 私钥文件位置
#SSLCertificateKeyFile "/etc/httpd/server-dsa.key"
#SSLCertificateKeyFile "/etc/httpd/server-ecc.key"
需要搭建一个ca服务器
本文出自 “运维成长路” 博客,谢绝转载!
原文地址:http://coolcl.blog.51cto.com/4514424/1832988