超级web服务器yum 安装apache+源码编译tomcat+awstat+phpmadin+mysql+php+AB压力测试

实验环境:

两台机器:Centos6.4

机器一: 192.168.56.10  安装httpd  php   等整合

机器二: 192。168.56.11 安装 mysql

========================================================================================

(iptables -t nat -I PREROUTING -d 外IP -p tcp -m tcp --dport 端口 -j DNAT --to-destination 外网IP:端口)

========================================================================================

机器一:

1. yum -y install *libxml2* httpd* PHP* *gcc* mysql mysql-devel ( 这里的mysql 是客户端)

vim  /etc/hosts

192.168.56.10    www.example.com

192.168.56.10    web.example.com

vim  /etc/httpd/conf/httpd.conf

修改:ServerName www.example.com:80

DirectoryIndex index.html index.html.var index.php

NameVirtualHost  192.168.56.10:80  //开启虚拟主机为了以后做虚拟主机挂网站

<VirtualHost 192.168.56.10:80>

ServerAdmin www.example.com

DocumentRoot /var/www/html

ServerName www.example.com

ErrorLog logs/www.example.com-error_log

CustomLog logs/www.example.com-access_log common

</VirtualHost>

2. 解压phpMyadmin-*

cp -RV   phpmyadmin-*                /var/www/html/phpmyadmin

cd     /var/www/html/phpmyadmin

mv config.sample.inc.php    config.sample.inc.php.bak

cp config.sample.inc.php.bak     config.inc.php

vim config.inc.php

$cfg[‘blowfish_secret‘] = ‘redhat‘;  //随便指定,不为空

$cfg[‘Servers‘][$i][‘auth_type‘] = ‘cookie‘;

$cfg[‘Servers‘][$i][‘host‘] = ‘192.168.56.11‘;//指定你的mysql 数据库地址

$cfg[‘Servers‘][$i][‘controluser‘] = ‘root‘;

$cfg[‘Servers‘][$i][‘controlpass‘] = ‘redhat‘; //指定你的mysql 数据库的用户名和密码

$cfg[‘Servers‘][$i][‘pmadb‘] = ‘phpmyadmin‘;

$cfg[‘Servers‘][$i][‘bookmarktable‘] = ‘pma_bookmark‘;

$cfg[‘Servers‘][$i][‘relation‘] = ‘pma_relation‘;

$cfg[‘Servers‘][$i][‘table_info‘] = ‘pma_table_info‘;

$cfg[‘Servers‘][$i][‘table_coords‘] = ‘pma_table_coords‘;

$cfg[‘Servers‘][$i][‘pdf_pages‘] = ‘pma_pdf_pages‘;

$cfg[‘Servers‘][$i][‘column_info‘] = ‘pma_column_info‘;

$cfg[‘Servers‘][$i][‘history‘] = ‘pma_history‘;

$cfg[‘Servers‘][$i][‘tracking‘] = ‘pma_tracking‘;

$cfg[‘Servers‘][$i][‘designer_coords‘] = ‘pma_designer_coords‘;

vim libraries/config.default.php

$cfg[‘blowfish_secret‘] = ‘redhat‘;

$cfg[‘Servers‘][$i][‘host‘] = ‘192.168.56.11‘;

$cfg[‘Servers‘][$i][‘port‘] = ‘3306‘; //指定你的Mysql 数据库端口

$cfg[‘Servers‘][$i][‘controluser‘] = ‘root‘;

$cfg[‘Servers‘][$i][‘controlpass‘] = ‘redhat‘;

$cfg[‘Servers‘][$i][‘user‘] = ‘root‘;

$cfg[‘Servers‘][$i][‘password‘] = ‘redhat‘;

//这个里面默认的为空,找到他们写入跟上面一样的数值:

$cfg[‘Servers‘][$i][‘pmadb‘] = ‘phpmyadmin‘;

$cfg[‘Servers‘][$i][‘bookmarktable‘] = ‘pma_bookmark‘;

$cfg[‘Servers‘][$i][‘relation‘] = ‘pma_relation‘;

$cfg[‘Servers‘][$i][‘table_info‘] = ‘pma_table_info‘;

$cfg[‘Servers‘][$i][‘table_coords‘] = ‘pma_table_coords‘;

$cfg[‘Servers‘][$i][‘pdf_pages‘] = ‘pma_pdf_pages‘;

$cfg[‘Servers‘][$i][‘column_info‘] = ‘pma_column_info‘;

$cfg[‘Servers‘][$i][‘history‘] = ‘pma_history‘;

$cfg[‘Servers‘][$i][‘tracking‘] = ‘pma_tracking‘;

$cfg[‘Servers‘][$i][‘designer_coords‘] = ‘pma_designer_coords‘;

===============================================================

客户端输入192.168.56.10/phpmyadmin   会报 mcrypt 插件错误:yum 安装PHP 没有mcrypt的插件。源码安装PHP你又必须指定 Mysql的安装位置。由于数据库和PHP分两台机器没法指定mysql的安装位置。所以我们采用编译安装模块。

========================================================================

1。开始编译 安装:libmcrypt-2.5.8

./configure    make && make install

2。开始编译 安装:mhash-0.9.9.9

/configure    make && make install

3。开始编译 安装:mcrypt-2.6.8

/configure    make && make install

===================================================================

以上三个包编译安装为了一个目的就是解决 php 没有 mcrypt.so 模块的问题

====================================================================

4。开始编译 源码PHP :(只编译不安装)php-5.2.13

./configure  --with-mcrypt

5. 编译完成以后,进入解压以后源码包的存放mcrypt的目录下

cd php-5.2.13/ext/mcrypt/

===========================================================

phpize 敲这条命令

aclocal 再敲这条命令

如果没有phpize 这条命令你需要安装php-devel.

亲身试验RHEL 光盘包没这个包。而centos里面有这个包。

敲这条命令的目的是为了在 mcrypt生产 configure 文件 。默认没有configure的

=====================================================================

6. 然后安装执行:

cd php-5.2.13/ext/mcrypt/

./configure

make clean

make

make install

7. 现在php的安装目录下面应该有了mcrypt.so 的文件了。

实在不清楚在哪里就用命令找一下

find / -name  mcrypt.so

我找到的在这个路径下 :

/usr/lib64/php/modules/mcrypt.so

/tmp/php-5.2.13/ext/mcrypt/modules/mcrypt.so

/tmp/php-5.2.13/ext/mcrypt/.libs/mcrypt.so

==========================================================================

8。 最后一步,把mcrypt.so 让php 调用识别就行了 :

vim  /etc/php.ini

extension=mcrypt.so

service  httpd restart

========================================================================

有些报错可能会遇到,我没遇到;这里就标识出来吧:

特别注意:

1、phpize需在解压后的源码包下执行,执行后生成configure脚本

2、运行./configure时,如果提示

configure: error: Cannot find php-config. Please use --with-php-config=PATH

请使用:

./configure --with-php-config=/php-install-path/bin/php-config #而不是使用php.ini

==============================================================================

机器二: 192.168.56.11  比较简单

yum  -y install mysql*

service mysqld restart

mysqladmin -u root password redhat

mysql -u root -p

输入密码进入mysql:

use mysql;

select host, user,password from user;

//查看到的只有本地的连接

| host                  | user | password                                  |

+-----------------------+------+-------------------------------------------+

| localhost             | root | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |

| SERVER-11.example.com | root |                                           |

| 127.0.0.1             | root |                                           |

| localhost             |      |                                           |

| SERVER-11.example.com |      |

//所以,我们要添加远程能够连接:

GRANT ALL PRIVILEGES ON *.* TO [email protected]‘%‘ IDENTIFIED BY ‘redhat‘;

[email protected]%  root 是你mysql的用户名 % 代表所有主机: 这里可以写IP:如 [email protected]

BY  指定的是你root的密码 :(这里的密码和上面PHPMyadmin 里面保持一致)

flush privileges; //使修改即时生效

=================================================================================

再用select host, user,password from user; 查看

+-----------------------+------+-------------------------------------------+

| host                  | user | password                                  |

+-----------------------+------+-------------------------------------------+

| localhost             | root | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |

| SERVER-11.example.com | root |                                           |

| 127.0.0.1             | root |                                           |

| localhost             |      |                                           |

| SERVER-11.example.com |      |                                           |

| %                     | root | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |

+-----------------------+------+-------------------------------------------+

=====================解决完成mcrypt.so完===================================

==========================================================================

安装 Discuz动网论坛

1. 修改php.ini

vim /etc/php.ini

short_open_tag = on

2. 解压论坛:unzip Discuz_7.2_FULL_SC_UTF8.zip -d discus

mv discus/upload/*  /var/www/htlm/bbs

service httpd restart

浏览器打开:http://192.168.56.10/bbs/install/index.php

点击安装下一步,会出现 什么不可读写,需要下一步把红色部分变成读写:

解决方法:(权限必须777;755试了还是不能写)

cd /var/www/html/bbs

chmod -R 777 config.inc.php attachments/

chmod -R 777 forumdata/ uc_client/data/cache/

service httpd restart

=========================================================================

在数据库服务器上创建bbs的数据库:192.168.56.11

create database discuz;

=========================================================================

在浏览器输入http://192.168.56.10/bbs/install/index.php 下一步,下一步。

指定数据库服务器:92.168.56.11

数据库名字:discuz

数据库用户名:root

数据库密码:redhat

数据库表前缀:cdb_discuz

下面写管理员密码:

安装完成: http://192.168.56.10/bbs

网站前台:http://www.example.com/bbs/index.php

访问bbs后台:http://www.example.com/bbs/admincp.php

=============================================================

有些情况出不来页面就把instll.php 删除

[email protected] bbs]# mv install/ install.lock

[[email protected] bbs]# chmod o-rx install.lock/

这两步不操作也可成功:

==============================================================

额外操作:可以不做,没实质意义:

AB 压力测试 :

[[email protected] ~]# ulimit -a | grep "open files"

open files (-n) 1024

[[email protected] ~]# ulimit -n 10000

[[email protected] ~]# ulimit -a | grep "open files"

open files (-n) 10000

[[email protected] ~]#ab -c 2000 -n 4000 http://192.168.56.10/bbs/

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.crazylinux.com (be patient)

apr_socket_recv: Connection reset by peer (104)

Total of 331 requests completed

Server Software: Apache/2.2.15

Server Hostname: www.example.com

Server Port: 80

Document Path: /bbs/

Document Length: 7710 bytes

Concurrency 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: 0

Total 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 max

Connect: 0 330 823.9 270 3837

Processing: 191 4977 4422.9 2976 26613

Waiting: 174 4976 4419.4 2976 26550

Total: 514 5308 4778.8 2999 27018

Percentage 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实际上并不是同时处理的,而是按照每个请求获得的时间片逐个轮转处理的,所以基本上

================================================================================

使用awstats 分析web 日志:

tar -zxvf awstats-6.95.tar.gz

mv awstats-6.95/ /usr/local/awstats

cd /usr/local/awstats/tools/

./awstats_configure.pl

指定你的http安装的路径,我是yum安装的,所以指定:

> /etc/httpd/conf/httpd.conf

输入两个Y

输入网站域名;www.example.com

vim /etc/awstats/awstats.www.example.com.conf

52 LogFile="/var/log/httpd/www.example.com-access_log"

在此先把access.log的日志格式修改一下 这里选择日志的格式为 combined,而不是common,awstats解析不了common

<VirtualHost 192.168.56.10>

DocumentRoot "/var/www/html"

ServerName www.example.com

ServerAlias www.francis.com

ErrorLog "logs/www.example.com-error_log"

CustomLog "logs/www.example.com-access_log" combined

</VirtualHost>

=============================================================

<VirtualHost 192.168.56.10>

DocumentRoot "/var/www/vir"

ServerName www.google.com

ErrorLog "logs/www.google.com-error_log"

CustomLog "logs/www.google.com-access_log" common

</VirtualHo>

===========================================================

cd /usr/local/awstats/

mkdir /var/lib/awstats

perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=192.168.56.10

注意:-config= 如果有DNS 用域名。如果没有DNS 用IP

===============================================================================

正确信息:cd /var/log/httpd/    rm -rf * (删除apche生成的日志。重新生成日志)

[[email protected] httpd]# perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=192.168.56.10 -update

Create/Update database for config "/etc/awstats/awstats.192.168.56.10.conf" by AWStats version 6.95 (build 1.943)

From data in log file "/var/log/httpd/www.example.com-access_log"...

Phase 1 : First bypass old records, searching new record...

Searching new records from beginning of log file...

Jumped lines in file: 0

Parsed lines in file: 0

Found 0 dropped records,

Found 0 corrupted records,

Found 0 old records,

Found 0 new qualified records.

================================================================================

开启计划任务:

crontab -e

*/5 * * * * /usr/bin/perl /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.example.com(192.168.56.10)

service crond restart

chkconfig crond on

==============================================================================

cd /var/www/html/bbs/

vim awstats.html

<html>

<head>

<meta http-equiv=refresh content="0;url=http://www.example.com/awstats/awstats.pl

-config=192.168.56.10">

</head>

<body>

</body>

</html>

客户端输入 :192.168.56.10/bbs/awstats.html 看见一个网页

=====================================================================


这个 访问控制可以不做

=====================================================================

对awstats进行访问控制

[[email protected] ~]# vim /etc/httpd/conf/httpd.conf 在里面查到与awstats相关信息

423 <Directory "/usr/local/awstats/wwwroot">

424 AuthName "Awstats"

425 AuthType Basic

426 AuthUserFile /usr/local/awstats/wwwroot/.htpasswd

427 require user awuser

428 Options None

429 AllowOverride AuthConfig

430 Order allow,deny

431 Allow from all

432 </Directory>

[[email protected] ~]# htpasswd -cm /usr/local/awstats/wwwroot/.htpasswd awuser

===================================================================================

搭建 Apache +tomcat 实现读取JSP 程序

[[email protected] local]# cat HelloWorld.java

public class HelloWorld {

public static void main(String args[]){

System.out.println("HelloWorld !!");

}

}

[[email protected] local]# javac HelloWorld.java //编译程序

[[email protected] local]# java HelloWorld //执行程序

HelloWorld !!

[[email protected] home]# tar -zxvf apache-tomcat-6.0.18.tar.gz -C /usr/local/src/

[[email protected] home]# ln -sf /usr/local/src/apache-tomcat-6.0.18 /usr/local/tomcat

[[email protected] home]# ln -sf /usr/local/tomcat/bin/startup.sh /usr/bin/tomcat-up

[[email protected] home]# ln -sf /usr/local/tomcat/bin/shutdown.sh /usr/bin/tomcat-down

[[email protected] home]# vim /usr/local/tomcat/conf/tomcat-users.xml

18 <tomcat-users>

19 <user username="crazy" password="linux" roles="manager,admin"/>

20 <!--

21 <role rolename="tomcat"/>

22 <role rolename="role1"/>

23 <user username="tomcat" password="tomcat" roles="tomcat"/>

24 <user username="both" password="tomcat" roles="tomcat,role1"/>

25 <user username="role1" password="tomcat" roles="role1"/>

26 -->

27 </tomcat-users>

[[email protected] home]# tomcat-up

[[email protected] home]# netstat -nutlp | grep java

tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 3526/java

tcp 0 0 :::8009 :::* LISTEN 3526/java

tcp 0 0 :::8080 :::* LISTEN 3526/java

=====================================================

客户端输入192.168.56.10:8080 选择tomcat-manager

输入 root  redhat  管理tomcat

cp mod_jk-1.2.28-httpd-2.2.X.so  /etc/httpd/modules/

vim /etc/httpd/conf/httpd.conf

AddType application/x-jsp .jsp

cd  /usr/local/tomcat/webapps

mkdir -p /var/www/html/apps

ln -sf /var/www/html/ web-apps1

vim /var/www/html/apps/showtime.jsp

<%@page language="java" import="java.util.*" %>

Now,the time&date is:<%out.println(new Date()); %>

======================================================

客户端 输入:http://192.168.56.10:8080/web-apps1/apps/showtime.jsp

Now,the time&date is:Thu Jul 10 23:37:11 CST 2014

时间: 2024-12-19 13:52:38

超级web服务器yum 安装apache+源码编译tomcat+awstat+phpmadin+mysql+php+AB压力测试的相关文章

衡阳高防服务器租用-CentOS6.2服务器环境配置:源码编译PHP5.4

衡阳高防服务器租用-CentOS6.2服务器环境配置:源码编译PHP5.4 在 开始之前,先把关于libmcrypt库的问题再说说,我也是在安装过程遇到的,因为原本以为yum可以安装好一切依赖包的,但在Centos6.2 64位环境下就是这么奇怪,yum安装上的libmcrypt始终都在编译过程提示缺少一个.h文件,为此差点碰伤了头.经过过多试验,总算把 libmcrypt这块先弄好了,否则到了PHP的安装环境是做不来的.安装PHP5.4.13要做的相关准备工作有除了下载PHP5.4.13的源码

apache源码编译时报错ssl_engine_init.c:546: error: &#39;STACK&#39; undeclared (first use in this function)

操作系统:centos6.4 X86_64 apache版本:httpd-2.2.6 openssl版本:openssl-1.0.1e 源码编译apache时报如下错误: ssl_engine_init.c: In function 'ssl_init_ctx_protocol': ssl_engine_init.c:390: warning: assignment discards qualifiers from pointer target type ssl_engine_init.c:39

linux软件包的安装之----源码编译安装

前提:必须装好前面说过的开发环境,rhel6上的3个开发包组 Rhel5/centos5上面安装: 1)Development Tools (2)Server Platform Development (3)Develogmentlibraries Rhel6/centos6上面安装: 1)  Development Tools (2)Server Platform Development (3)Desktop PlatformDevelopment **由于tarball中的c程序源码文件之间

Linux程序包管理之yum仓库、源码编译安装

CentOS:yum,dnf URL:ftp://172.16.0.1/pub yum是C/S架构,是rpm的前端工具,依赖于rpm存在的: 1.本地要有yun程序: 2.本地要有配置文件(配置远程服务器yum仓库或本地服务器yum仓库): 3.要有存在的文件服务器(程序包仓库即yum仓库).(也可以在本地配置服务器yum仓库): yum支持的服务器有两种:一种是ftp服务器,第二种是http服务器: yum工作简述: yum是客户端,也认为是自我独立管理的组件,需要联系远程的仓库,从仓库中下载

Apache源码编译安装脚本

??Apache是开源的的.最流行的Web服务器软件之一,它快速.可靠并且可通过简单的API扩充,将Perl/Python/PHP等解释器编译到服务器中.Apache的模块超多,以及具有运行稳定,强大的rewrite功能.动态处理能力强等优点,在追求稳定的业务环境下被广泛使用. ??以下是Apache2.4版本prefork模式的源码编译脚本: #!/bin/bash # #*************************************************************

Linux apache源码编译安装

下载.解压Apache源码 [[email protected] ~]# mkdir /usr/local/apache [[email protected] ~]# cd /usr/local/apache/ [[email protected] apache]# wget http://mirrors.sohu.com/apache/httpd-2.4.25.tar.gz [[email protected] apache]# tar -zxvf httpd-2.4.25.tar.gz 设置

CentOS 6 apache源码编译一键部署脚本

需求:源码编译apache 环境:CentOS 6 64位系统安装的桌面版 软件:httpd-2.4.12.tar.gz.pcre-8.31.tar.bz2.apr-util-1.5.3.apr-1.5.1.tar.gz 备注:目前只在centos 6环境下测试过,如果有报错可能是依赖包安装有缺失,本来想把这几个源码包上传上去的,上传一直失败,以上几个源码包需要到网上下载一下 [[email protected] ~]# cat apache.sh #!/bin/bash # #适用版本Cent

apache优化之防盗链,日志拆分,ab压力测试

Apache调优之apache防盗链.日志拆分和ab压力测试 1.apache防盗链 盗链,全称是盗取链接,假如我们的网站有很多好看的图片,别人可以查看我们网站图片的链接,然后应用在他的网站上,这样的话,去访问他的网站,实际上消耗的是我们的流量(因为实际链接在我们这里),这样我们就不得不去配置防盗链,使得别人不能复制我们图片的链接 要实现防盗链,我们就必须先理解盗链的实现原理,提到防盗链的实现原理就不得不从HTTP协议说起,在HTTP协议中,有一个表头字段叫referer,采用URL的格式来表示

Apache源码编译安装

精髓前言: 解析JAVA程序用:tomcat.resin.weblogic.jboss 解析.asp .aspx程序用:pws,iis  后端数据库为:sql server,access IP PV UV: IP:internet protocol    --internet协议 pv:page view         --访问量 uv:unique visitor      --独立访客 简单介绍cookie: cookie: 访问一个网站的时候,网站就会给你发一个cookie,独一无二的