已阅读5页,还剩15页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
RHEL5.4下最新源码搭建Apache+Mysql+Php+Discuz+PhpMyAdmin+Awstats+AB压力测试2010/05/14 第二版By crazylinuxEmail:crazy_相比第一版本,改变了实验中的某些步骤顺序,使整个实验更具真实性。并且有些服务版本已经更新。如有什么疑问,请发Email与作者联系。实验目的:完成Linux下面的LAMP环境的搭建,实现Discuz论坛,实现awstats分析Web日志,以及AB实现HTTP性能测试,最后通过phpMyAdmin管理MySQL数据库实验软件包:(都存放到Web服务器的/home下)软件下载地址:Apache: /httpd/httpd-2.2.15.tar.gzMysql:ftp:/mirror2.dataphone.se/pub/mysql/Downloads/MySQL-5.1/mysql-5.1.44.tar.gzPhp: /distributions/php-5.3.2.tar.gzDiscuz:/Discuz/7.2/Discuz_7.2_FULL_SC_UTF8.zipPhpMyAdmin: 4/download/3786632/4780719/2/zip/236/72/1268753528812_584/phpMyAdmin-3.3.1-all-languages.zipAwstats:/project/awstats/AWStats/6.95/awstats-6.95.tar.gzTomcat:/dist/tomcat/tomcat-6/v6.0.26/src/apache-tomcat-6.0.26-src.tar.gzJdk:/ESD6/JSCDL/jdk/6u20-b02/jdk-6u20-linux-i586.bin?AuthParam=1274057671_c83ff38693dae0e762fa9f82428c5f6d&TicketId=B%2Fw6lxyASF5LSBFDOldakATj&GroupName=CDS&FilePath=/ESD6/JSCDL/jdk/6u20-b02/jdk-6u20-linux-i586.bin&File=jdk-6u20-linux-i586.binlibmcrypt、mhash、mcrypt:/实验环境:RHEL5.4Web server:0/24Dns server: 0/24/Clinet: 00/24前提条件:在所有linux主机上配置yum仓库,把DVD光盘挂在到本地/media下,红色字体代表修改后结果rootlocalhost # cat /etc/yum.repos.d/rhel-debuginfo.repo rhel-debuginfoname=Red Hat Enterprise Linux $releasever - $basearch - Debugbaseurl=file:/media/Server/指定本地/mediaenabled=1/开启仓库gpgcheck=1gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release关闭所有linux防火墙与SELINUXrootlocalhost bin# iptables -Frootlocalhost bin# iptables -Xrootlocalhost bin# iptables -Zrootlocalhost bin# setenforce 0rootlocalhost bin# service iptables save一、 DNS环境的搭建1、 安装DNS相关软件包rootlocalhost # yum -y install bind bind-devel bind-chroot caching-nameserver2、配置DNS主配置文件rootlocalhost # cd /var/named/chroot/etc/rootlocalhost etc# cp -p named.caching-nameserver.conf named.confrootlocalhost etc# cat named.conf / named.caching-nameserver.conf/ Provided by Red Hat caching-nameserver package to configure the/ ISC BIND named(8) DNS server as a caching only nameserver / (as a localhost DNS resolver only). / See /usr/share/doc/bind*/sample/ for example named configuration files./ DO NOT EDIT THIS FILE - use system-config-bind or an editor/ to create named.conf - edits to this file will be lost on / caching-nameserver package upgrade./options listen-on port 53 any; ; listen-on-v6 port 53 :1; ; 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; / Those options should be used carefully because they disable port / randomization / query-source port 53; / query-source-v6 port 53; allow-query any; ; allow-query-cache any; ;logging channel default_debug file data/named.run; severity dynamic; ;view localhost_resolver match-clients any; ; match-destinations any; ; recursion yes; include /etc/named.rfc1912.zones;rootlocalhost etc# vim named.rfc1912.zones 在文件最后添加zone IN type master; file cl.zheng;zone IN type master; file g.zheng;zone 0.168.192. IN type master; file cl.fan;3、配置区域文件rootlocalhost etc# cd /var/named/chroot/var/named/rootlocalhost named# cp -p named.zero cl.zhengrootlocalhost named# cp -p named.zero g.zhengrootlocalhost named# cp -p named.zero cl.fanrootlocalhost named# cat cl.zheng $TTL 86400 IN SOA localhost. root.localhost. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS .dns IN A 0www IN A 0rootlocalhost named# cat g.zheng $TTL 86400 IN SOA localhost. root.localhost. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS .dns IN A 0www IN A 0rootlocalhost named# cat cl.fan $TTL 86400 IN SOA localhost. root.localhost. ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum IN NS .20 IN PTR .20 IN PTR .10 IN PTR .10 IN PTR .rootlocalhost named# cat /etc/resolv.conf nameserver 0rootlocalhost named# service named restartrootlocalhost named# chkconfig named on4、测试DNS (在clinet中把DNS指向0)rootlocalhost named# host has address 0rootlocalhost named# host has address 0二、 LAMP环境的搭建1、安装APACHE(配置源码包之前先安装GCC环境)rootlocalhost # yum -y install *gcc*rootlocalhost # rpm -e httpd nodeps /卸载系统自带的httpd这个包rootlocalhost # cd /home/ rootlocalhost home# tar -zxvf httpd-2.2.15.tar.gz -C /usr/local/src/rootlocalhost home# cd /usr/local/src/httpd-2.2.15/rootlocalhost httpd-2.2.15# ./configure -prefix=/usr/local/apache2 -enable-so -enable-rewrite rootlocalhost httpd-2.2.15# make & make install做个小技巧,实现开机自动启动APACHErootlocalhost httpd-2.2.15# cd /usr/local/apache2/bin/rootlocalhost bin# vim apachectl#!/bin/sh# chkconfig: 35 85 15# description: Apache is a World Wide Web Server rootlocalhost bin# cp apachectl /etc/init.d/apacherootlocalhost bin# chkconfig -add apacherootlocalhost bin# service apache restartrootlocalhost bin# chkconfig apache on测试:在clinet上IE中输入服务器的ip2、构建基于域名的虚拟主机前提条件rootlocalhost bin# cat /etc/resolv.conf nameserver 0search rootlocalhost bin# host has address 0rootlocalhost bin# host has address 0配置基于域名的虚拟主机rootlocalhost bin# vim /usr/local/apache2/conf/httpd.conf 把388行前面的#号去掉387 # Virtual hosts388 Include conf/extra/httpd-vhosts.confrootlocalhost bin# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf 修改下面这样 1 NameVirtualHost 0 2 3 DocumentRoot /usr/local/apache2/htdocs/crazylinuxcom 4 ServerName 5 ErrorLog logs/.error_log 6 CustomLog logs/.access_log common 7 8 9 10 DocumentRoot /usr/local/apache2/htdocs/googlecom 11 ServerName 12 ErrorLog logs/.error_log 13 CustomLog logs/.access_log common 14 rootlocalhost bin# cd /usr/local/apache2/htdocs/rootlocalhost htdocs# mkdir crazylinuxcom googlecom rootlocalhost htdocs# echo crazylinuxcom/index.htmlrootlocalhost htdocs# echo googlecom/index.html rootlocalhost htdocs# service apache restart测试:在clinet中指定DNS服务器的ip3、安装配置MYSQLrootlocalhost htdocs# cd /home/rootlocalhost home# tar -zxvf mysql-5.1.44.tar.gz -C /usr/local/src/ rootlocalhost home# cd /usr/local/src/mysql-5.1.44 rootlocalhost mysql-5.1.44# useradd -M -s /sbin/nologin mysqlrootlocalhost mysql-5.1.44# yum -y install libtermcap-develrootlocalhost mysql-5.1.44# ./configure -prefix=/usr/local/mysql -with-mysqlduser=mysqlrootlocalhost mysql-5.1.44# makerootlocalhost mysql-5.1.44# make installrootlocalhost mysql-5.1.44# cp support-files/f /etc/frootlocalhost mysql-5.1.44# /usr/local/mysql/bin/mysql_install_db -user=mysqlrootlocalhost mysql-5.1.44# chown -R root:mysql /usr/local/mysql/rootlocalhost mysql-5.1.44# chown -R mysql /usr/local/mysql/var/rootlocalhost mysql-5.1.44# echo /usr/local/mysql/lib/mysql /etc/ld.so.confrootlocalhost mysql-5.1.44# ldconfigrootlocalhost mysql-5.1.44# /usr/local/mysql/bin/mysqld_safe -user=mysql & /启动mysqlrootlocalhost mysql-5.1.44# ps -e | grep mysql 验证是否成功开启mysql 1664 pts/2 00:00:00 mysqld_safe 1690 pts/2 00:00:00 mysqldrootlocalhost mysql-5.1.44# netstat -ntulp | grep mysqltcp 0 0 :3306 :* LISTEN 1690/mysqldrootlocalhost mysql-5.1.44# cp support-files/mysql.server /etc/init.d/mysqldrootlocalhost mysql-5.1.44# chmod +x /etc/init.d/mysqld rootlocalhost mysql-5.1.44# chkconfig -add mysqldrootlocalhost mysql-5.1.44# chkconfig mysqld onrootlocalhost mysql-5.1.44# export PATH=$PATH:/usr/local/mysql/bin/rootlocalhost mysql-5.1.44# echo PATH=$PATH:/usr/local/mysql/bin/ /etc/profilerootlocalhost mysql-5.1.44# mysqladmin -u root password 123456 /修改mysql密码rootlocalhost mysql-5.1.44# mysql -u root -pEnter password: (输入123456密码)Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 6Server version: 5.1.44-log Source distributionType help; or h for help. Type c to clear the current input statement.mysql quit4、安装配置PHProotlocalhost mysql-5.1.44# cd /home/rootlocalhost home# tar -zxvf php-5.3.2.tar.gz -C /usr/local/src/rootlocalhost home# cd /usr/local/src/php-5.3.2/rootlocalhost php-5.3.2# yum -y install *libxml2* rootlocalhost php-5.3.2# ./configure -prefix=/usr/local/php5 /安装位置-enable-mbstring /设置php支持多字节字符串-with-apxs2=/usr/local/apache2/bin/apxs /设置apache服务支持apxs位置-with-mysql=/usr/local/mysql /设置mysql程序安装位置-with-config-file-path=/usr/local/php5 /设置php程序配置文件位置rootlocalhost php-5.3.2# make rootlocalhost php-5.3.2# make testrootlocalhost php-5.3.2# make installrootlocalhost php-5.3.2# cp php.ini-development /usr/local/php5/php.ini在APACHE里添加php,使APACHE支持PHProotlocalhost php-5.3.2# vim /usr/local/apache2/conf/httpd.conf53 LoadModule php5_module modules/libphp5.so54 AddType application/x-httpd-php .php167 168 DirectoryIndex index.php index.html169 5、测试PHP与APACHE的协同工作rootlocalhost php-5.3.2# cat /usr/local/apache2/htdocs/crazylinuxcom/index.phprootlocalhost php-5.3.2# service apache stoprootlocalhost php-5.3.2# service apache start测试:在client的IE中输入rootlocalhost php-5.3.2# cd /usr/local/apache2/htdocs/crazylinuxcom/在客户端测试6、架设Discuz论坛rootlocalhost # mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 3Server version: 5.1.44-log Source distributionType help; or h for help. Type c to clear the current input statement.mysql create database bbsdb;Query OK, 1 row affected (0.01 sec)mysql grant all on bbsdb.* to runbbslocalhost identified by 123456;Query OK, 0 rows affected (0.00 sec)mysql quit rootlocalhost # cd /home/rootlocalhost home# unzip Discuz_7.2_FULL_SC_UTF8.zip -d discus rootlocalhost home# mv discus/upload /usr/local/apache2/htdocs/crazylinuxcom/bbs rootlocalhost home# cd /usr/local/apache2/htdocs/crazylinuxcom/bbs/ rootlocalhost bbs# chown -R daemon config.inc.php attachments/ forumdata/ uc_client/data/cache/rootlocalhost bbs# vim /usr/local/php5/php.ini226 short_open_tag = Onrootlocalhost bbs# service apache restart在Client中输入/bbs/install/index.php进行安装rootlocalhost bbs# mv install/ install.lockrootlocalhost bbs# chmod o-rx install.lock/访问bbs前台:/bbs/index.php访问bbs后台:/bbs/admincp.php7、安装phpMyAdmin数据库管理套件rootlocalhost bbs# cd /home/rootlocalhost home# unzip phpMyAdmin-3.3.1-all-languages.zip -d /usr/local/apache2/htdocs/crazylinuxcom/rootlocalhost home# cd /usr/local/apache2/htdocs/crazylinuxcom/rootlocalhost crazylinuxcom# mv phpMyAdmin-3.3.1-all-languages phpMyAdminrootlocalhost crazylinuxcom# cd phpMyAdmin/rootlocalhost phpMyAdmin# cp config.sample.inc.php config.inc.phprootlocalhost phpMyAdmin# vim config.inc.php18 $cfgblowfish_secret = 123456; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */8、安装libmcrypt mhash mcrypt解决无法加载mcryptrootlocalhost phpMyadmin# cd /home/rootlocalhost home# tar -zxvf libmcrypt-2.5.8.tar.gz -C /usr/local/src/rootlocalhost home# cd /usr/local/src/libmcrypt-2.5.8/rootlocalhost libmcrypt-2.5.8# ./configurerootlocalhost libmcrypt-2.5.8# make & make installrootlocalhost libmcrypt-2.5.8# echo /usr/local/lib /etc/ld.so.confrootlocalhost libmcrypt-2.5.8# ldconfigrootlocalhost libmcrypt-2.5.8# cd /home/rootlocalhost home# tar -zxvf mhash-.tar.gz -C /usr/local/src/rootlocalhost home# cd /usr/local/src/mhash-/rootlocalhost mhash-# ./configurerootlocalhost mhash-# make & make installrootlocalhost mhash-# cd /home/rootlocalhost home# tar -zxvf mcrypt-2.6.8.tar.gz -C /usr/local/src/rootlocalhost home# cd /usr/local/src/mcrypt-2.6.8/rootlocalhost mcrypt-2.6.8# ./configurerootlocalhost mcrypt-2.6.8# make & make installrootlocalhost mcrypt-2.6.8# cd /usr/local/src/php-5.3.2/rootlocalhost php-5.3.2# ./configure -prefix=/usr/local/php5 -enable-mbstring -with-apxs2=/usr/local/apache2/bin/apxs -with-mysql=/usr/local/mysql -with-mcrypt -with-config-file-path=/usr/local/php5rootlocalhost php-5.3.2# service apache restart在Client中测试/phpMyAdmin三、额外操作1、AB压力测试先修改最大文件数限制rootlocalhost # ulimit -a | grep open filesopen files (-n) 1024rootlocalhost # ulimit -n 10000rootlocalhost # ulimit -a | grep open filesopen files (-n) 10000 rootlocalhost # /usr/local/apache2/bin/ab -c 2000 -n 4000 /bbs/This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, /Licensed to The Apache Software Foundation, /Benchmarking (be patient)apr_socket_recv: Connection reset by peer (104)Total of 331 requests completedServer Software: Apache/2.2.15Server Hostname: Server Port: 80Document Path: /bbs/Document Length: 7710 bytesConcurrency Level: 2000/用于并发连接的请求数Time taken for tests: 75.946 seconds/测试过程消耗的时间Complete requests: 331/测试过程总共完成的请求数Failed requests: 330/失败的请求数 (Connect: 0, Receive: 1, Length: 330, Exceptions: 0)Write errors: 0Total transferred: 2675927 bytes/测试过程网络传输量HTML transferred: 2559063 bytes/测试过程中的HTML内容传输量Requests per second: 4.36 #/sec (mean)/服务器平均每秒相应的请求数Time per request: 458886.079 ms (mean)/服务器平均每请求的相应时间Time per request: 229.443 ms (mean, across all concurrent requests) /每个请求实际运行时间的平均值Transfer rate: 34.41 Kbytes/sec received/平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题Connection Times (ms)/连接时间统计信息 min mean+/-sd median maxConnect: 0 330 823.9 270 3837Processing: 191 4977 4422.9 2976 26613Waiting: 174 4976 4419.4 2976 26550Total: 514 5308 4778.8 2999 27018Percentage of the requests served within a certain time (ms) 50% 2999 66% 5421 75% 6967 80% 8983 90% 13226 95% 17052 98% 17610 99% 19567 100% 27018 (longest request)/整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间,其中50的用户响应时间小于2999毫秒,60 的用户响应时间小于5421毫秒,最大的响应时间小于27018毫秒由于对于并发请求,cpu实际上并不是同时处理的,而是按照每个请求获得的时间片逐个轮转处理的,所以基本上第一个Time per request时间约等于第二个Time per request时间乘以并发请求数2、 个人主页rootlocalhost # vim /usr/local/apache2/conf/httpd.conf 去掉384行前的#号384 Include conf/extra/httpd-userdir.confrootlocalhost # useradd tomrootlocalhost # mkdir /home/tom/public_htmlrootlocalhost # echo This is tom site /home/tom/public_html/index.htmlrootlocalhost # chmod o+x /home/tom/rootlocalhost # service apache restart测试:(想想办法去掉符号)3、 使用awstats分析Web日志rootlocalhost home# tar -zxvf awstats-6.95.tar.gz -C /usr/local/src/rootlocalhost home# cd /usr/local/src/rootlocalhost src# mv awstats-6.95/ awstatsrootlocalhost src# cd /usr/local/src/awstats/tools/ rootlocalhost tools#
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 文学视角下园林植物的文化寓意探析
- 石河子大学《土壤肥料学》2022-2023学年第一学期期末试卷
- 石河子大学《人事测评》2021-2022学年第一学期期末试卷
- 石河子大学《地籍测量》2023-2024学年第一学期期末试卷
- 沈阳理工大学《现场总线控制系统》2022-2023学年期末试卷
- 沈阳理工大学《汽车检测与诊断技术》2023-2024学年第一学期期末试卷
- 沈阳理工大学《计算机程序设计》2022-2023学年期末试卷
- 沈阳理工大学《工程制图A》2021-2022学年第一学期期末试卷
- 沈阳理工大学《大学生健康教育》2021-2022学年第一学期期末试卷
- 光合同化物的下运途径
- (一模)宁波市2024学年第一学期高考模拟考试 物理试卷(含答案)
- 压力容器操作人员培训内容考核试卷
- 2024-2025学年上海市普陀区七年级(上)期中数学试卷(含解析)
- 芜湖市大学生乡村医生专项计划招聘考试试卷及答案
- 标准离婚协议书范文(3篇)
- 23年经济师中级考试(工商+经济基础)题(题库版)
- 2024秋期国家开放大学《政府经济学》一平台在线形考(形考任务1至4)试题及答案
- 【8道期中】安徽省滁州市全椒县2023-2024学年八年级上学期11月期中道德与法治试题
- 12J201平屋面建筑构造图集(完整版)
- 2024至2030年中国泰妙菌素行业投资前景及策略咨询研究报告
- 2024-2030年中国航空噪声与振动主动控制系统行业市场发展趋势与前景展望战略研究报告
评论
0/150
提交评论