没有合适的资源?快使用搜索试试~ 我知道了~
LNMPA的安装与优化过程
3星 · 超过75%的资源 需积分: 9 14 下载量 90 浏览量
2014-04-24
16:48:08
上传
评论 1
收藏 47KB DOC 举报
温馨提示
试读
12页
在安装LNMP或是LAPM时常遇到的问题的优化步骤,还有lnmpa的安装优化
资源推荐
资源详情
资源评论
LAMP 架构优化
1、安装 lamp 架构
安装 mysql
# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/usr/local/mysql/etc -
DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -
DWITH_BLACKHOLE_STORAGE_ENGINE=1 -
DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -
DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -
DENABLED_LOCAL_INFILE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -
DWITH_EXTRA_CHARSETS=all
# make
# make install
# cp my-medium.cnf /usr/local/mysql/etc/my.cnf
# cp mysql.server /etc/init.d/mysqld
# chmod 755 /etc/init.d/mysqld
# chkconfig --add mysqld
安装 apache 及相关功能支持软件
安装 apr
# ./configure --prefix=/usr/local/apr --enable-threads
# make
# make install
安装 apr-iconv
# ./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr/bin/apr-1-config
# make
# make install
安装 apr-util
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config --with-
mysql=/usr/local/mysql
# make
# make install
安装 pcre
# ./configure --prefix=/usr/local/pcre --enable-utf8 --enable-pcregrep-libz --enable-pcregrep-
libbz2
# make
# make install
安装 libzip
# ./configure --prefix=/usr/local/libzip
# make
# make install
安装 apache
#cd /usr/src/httpd-2.4.6/server/mpm/prefork
#vim prefork.c
# ./configure --prefix=/usr/local/httpd --enable-modules=all --enable-file-cache --enable-cache --
enable-cache-disk --enable-mem-cache --enable-so --enable-echo --enable-buffer --enable-http --
enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-fcgi --
enable-proxy-scgi --enable-proxy-ajp --enable-proxy-balancer --enable-proxy-express --enable-
session --enable-session-cookie --enable-ssl --enable-dav --enable-vhost-alias --enable-negotiation
--enable-info --enable-suexec --enable-cgi --enable-rewrite --with-mpm=prefork
--with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr-util
--with-pcre=/usr/local/pcre --with-z=/usr/local/libzip
# make
# make install
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr/bin/apr-1-config
--with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-z=/usr/local/libzip
安装 php
# ./configure --prefix=/usr/local/php --enable-mbstring --with-apxs2=/usr/local/httpd/bin/apxs --
with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php
--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-calendar
# make
# make install
2、压力测试
常见压力测试工具:ab,http_load,autobench,webbench,loadrunner
(1)ab 压力测试
# ab -c 5000 -n 5000 -g nokeep5.data http://10.0.0.11/template3/index.html
编辑 gnuplot 绘图配置文件
# yum install gnuplot
# vim gnuplot.txt
#www-test.output
set term png enhanced font '/usr/share/fonts/liberation/LiberationSabs-Regular.ttf'
set output "www-test.png"
set title "test: ab -c 5000 -n 5000"
set size 1,0).8
set grid y
set xlabel "request"
set ylabel "response times(ms)"
plot "/test/nokeep1.data" using 9 smooth sbezier with lines title "text test","/test/nokeep2.data"
using 9 smooth sbezier with lines title "php test","/test/nokeep3.data" using 9 smooth sbezier with
lines title "tmp1 test","/test/nokeep4.data" using 9 smooth sbezier with lines title "tmp2
test","/test/nokeep5.data" using 9 smooth sbezier with lines title "tmp3 test"
#gnuplot gnuplot.txt
(2)http_load 压力测试
-p 并发进程数
-f 总计访问次数
-r 每秒钟的访问频率
-s 总计访问时间
# http_load -p 1100 -s 20 url.txt
(3)webbench 压力测试
-c 指定并发连接数
-t 运行测试时间
# webbench -c 10000 -t 10 http://10.0.0.11/template3/index.html
3、apache 性能调优
(1) #vim httpd.conf
keepalive on | off
(2) #vim httpd.conf
ServerLimit 1024 \\设置最大连接用户数
StartServers 100 \\设置启动的空闲进程数
MinSpareServers 100 \\设置最小的空闲进程数
MaxSpareServers 500 \\设置最大空闲进程数
MaxRequestWorkers 500 \\允许启动的最大服务器进程数量
MaxConnectionsPerChild 4000 \\设置进程响应多少次连接后关闭
(3)使用缓存 cache 功能
在编译时加上:--enable-cache --enable-mem-cache --enable-disk-cache --enable-file-cache
在 apache 中添加功能模块
# cd /usr/src/httpd-2.4.6/modules/cache \\进入模块源文件所在目录
# /usr/local/httpd/bin/apxs -cia mod_cache.c cache_util.c cache_storage.c
# /usr/local/httpd/bin/apxs -cia mod_cache_disk.c
# /usr/local/httpd/bin/apxs -c -i -a mod_cache_file.c
# /usr/local/httpd/bin/apxs -c -i -a mod_socache_memcache.c
# vim httpd.conf
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
<IfModule mod_cache.c>
CacheDefaultExpire 86400
CacheMaxExpire 172800
CacheLastModifiedFactor 0.1
CacheDisable /sxjy
CacheEnable mem /template1
CacheEnable mem /template2
CacheEnable disk /teplate3
<IfModule mod_cache_mem.c>
CacheEnable mem /template1
CacheEnable mem /template2
MCacheMaxObjectCount 10000
MCacheMaxObjectSize 1048576
MCacheMaxStreamingBuffer 65536
MCacheMinObjectSize 10
MCacheRemovalAlgorithm GDSF
MCacheSize 134217728
</IfModule>
<IfModule mod_cache_disk.c>
剩余11页未读,继续阅读
资源评论
- 三两岁月2014-06-23文档是以前写的。
佑拐角803
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功