欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

马哥 24_03 _编译安装LAMP之php-5.4.13、xcache-2.0及使用ab命令实现压力测试【攻城狮论坛の免费分享】 有大用

[root@localhost php-5.4.13]# ls /usr/local/php

bin  etc  include  lib  php


bin 二进制文件

etc 配置文件

include 头文件

lib 库文件

php    php/man 手册


[root@localhost php-5.4.13]#


[root@localhost php-5.4.13]# ls /usr/local/php/bin  #下面的都是php的命令行工具

pear  peardev  pecl  phar  phar.phar  php  php-cgi  php-config  phpize

[root@localhost php-5.4.13]#

为 php的其它的子项目所提供的配置文件的存放路径

[root@localhost php-5.4.13]# ls /usr/local/php/etc

pear.conf

[root@localhost php-5.4.13]#


[root@localhost php-5.4.13]# ls /usr/local/php/php

man

[root@localhost php-5.4.13]#


[root@localhost php-5.4.13]#  cp php.ini-production /etc/php.ini   # 在 ./configure 有个参数是 --with-config-file-path=/etc 表示在 /etc下面找php.ini文件 


一般.ini遵循法则与 yum 的配置文件 mysql的配置文件差不多 ,都是分段式的 

[root@localhost php-5.4.13]#

[root@localhost php-5.4.13]# vim /etc/php.ini  (稍微看了一下)



让 apache与php结合起来工作       

[root@localhost php-5.4.13]# vim /etc/httpd/httpd.conf

里面是 httpd.conf 的部分内容



LoadModule php5_module        modules/libphp5.so   #  php作为apache的一个模块???

........................................

      AddType application/x-compress .Z

      AddType application/x-gzip .gz .tgz

#下面这两行是自行添 加的

    AddType application/x-httpd-php .php  #这是让支持php格式的页面 能够理解处理php结尾的页面文件

    AddType application/x-httpd-php-source .phps # 这是让支持php源码格式的文件

........................................

image.png

<IfModule dir_module>

    DirectoryIndex index.php index.html  #这里加上index.php

</IfModule>

image.png

# Server-pool management (MPM specific)

#Include /etc/httpd/extra/httpd-mpm.conf


# Multi-language error messages

#Include /etc/httpd/extra/httpd-multilang-errordoc.conf


# Fancy directory listings

#Include /etc/httpd/extra/httpd-autoindex.conf  #自动索引


# Language settings

#Include /etc/httpd/extra/httpd-languages.conf #支持语言


# User home directories

#Include /etc/httpd/extra/httpd-userdir.conf #支持用户个人家目录下使用网页文件的


# Real-time info on requests and configuration

#Include /etc/httpd/extra/httpd-info.conf


# Virtual hosts

#Include /etc/httpd/extra/httpd-vhosts.conf


# Local access to the Apache HTTP Server Manual

#Include /etc/httpd/extra/httpd-manual.conf


# Distributed authoring and versioning (WebDAV)

#Include /etc/httpd/extra/httpd-dav.conf


# Various default settings

#Include /etc/httpd/extra/httpd-default.conf


# Configure mod_proxy_html to understand HTML4/XHTML1

<IfModule proxy_html_module>

Include /etc/httpd/extra/proxy-html.conf

</IfModule>


# Secure (SSL/TLS) connections

#Include /etc/httpd/extra/httpd-ssl.conf  #想使用ssl ,需要启用它 还要启用 mod_ssl.so 模块

#

# Note: The following must must be present to support

#       starting without SSL on platforms with no /dev/random equivalent

#       but a statically compiled-in mod_ssl.

#

<IfModule ssl_module>

SSLRandomSeed startup builtin

SSLRandomSeed connect builtin

</IfModule>

#

# uncomment out the below to deal with user agents that deliberately

# violate open standards by misusing DNT (DNT *must* be a specific

# end-user choice)

#

#<IfModule setenvif_module>

#BrowserMatch "MSIE 10.0;" bad_DNT

#</IfModule>

#<IfModule headers_module>

#RequestHeader unset DNT env=bad_DNT

#</IfModule>



[root@localhost php-5.4.13]# httpd -t

Syntax OK

[root@localhost php-5.4.13]# service httpd restart

停止 httpd:                                               [确定]

启动 httpd:                                               [确定]

[root@localhost php-5.4.13]#


image.png

image.png




[root@localhost php-5.4.13]# cd  /usr/local/apache/htdocs/

[root@localhost htdocs]# pwd

/usr/local/apache/htdocs

[root@localhost htdocs]#

[root@localhost htdocs]# ls

index.html

[root@localhost htdocs]# mv index.html index.php

[root@localhost htdocs]#


[root@localhost htdocs]# vim index.php

<html><body><h1>It works! my apache</h1></body></html>

<?php

echo phpinfo();

?>


http://192.168.1.45/


image.png

image.png






[root@localhost htdocs]# vim index.php

<html><body><h1>It works! my apache</h1></body></html>

<?php

//echo phpinfo();


$conn = mysql_connect('localhost','root','');

if($conn)

  echo "Success...";

else

  echo "Failure...";

?>




http://192.168.1.45/

image.png


关闭mysql

[root@localhost htdocs]# service mysqld stop

Shutting down MySQL.                                       [确定]

[root@localhost htdocs]#



http://192.168.1.45/

image.png



能够跟php5.4结合的只有Xcache 2.0 及以后的版本


image.png

image.png

image.png


image.png

https://xcache.lighttpd.net/

https://xcache.lighttpd.net/wiki/Release-2.0.0

https://xcache.lighttpd.net/pub/Releases/2.0.0/xcache-2.0.0.tar.gz

https://xcache.lighttpd.net/pub/Releases/2.0.0/xcache-2.0.0.tar.bz2



[root@localhost ~]# wget https://xcache.lighttpd.net/pub/Releases/2.0.0/xcache-2                                      .0.0.tar.bz2

--2019-04-29 02:29:34--  https://xcache.lighttpd.net/pub/Releases/2.0.0/xcache-2                                      .0.0.tar.bz2

正在解析主机 xcache.lighttpd.net... 188.40.103.19, 2a01:4f8:221:2708::2

Connecting to xcache.lighttpd.net|188.40.103.19|:443... 已连接。

ERROR: cannot verify xcache.lighttpd.net's certificate, issued by `/C=US/O=Let's                                       Encrypt/CN=Let's Encrypt Authority X3':

  Unable to locally verify the issuer's authority.

ERROR: certificate common name `lighttpd.net' doesn't match requested host name                                       `xcache.lighttpd.net'.

To connect to xcache.lighttpd.net insecurely, use `--no-check-certificate'.

无法建立 SSL 连接。

[root@localhost ~]# wget https://xcache.lighttpd.net/pub/Releases/2.0.0/xcache-2                                      .0.0.tar.bz2 --no-check-certificate

--2019-04-29 02:29:50--  https://xcache.lighttpd.net/pub/Releases/2.0.0/xcache-2                                      .0.0.tar.bz2

正在解析主机 xcache.lighttpd.net... 188.40.103.19, 2a01:4f8:221:2708::2

Connecting to xcache.lighttpd.net|188.40.103.19|:443... 已连接。

WARNING: cannot verify xcache.lighttpd.net's certificate, issued by `/C=US/O=Let                                      's Encrypt/CN=Let's Encrypt Authority X3':

  Unable to locally verify the issuer's authority.

WARNING: certificate common name `lighttpd.net' doesn't match requested host nam                                      e `xcache.lighttpd.net'.

已发出 HTTP 请求,正在等待回应... 200 OK

长度:108614 (106K) [application/x-gtar-compressed]

Saving to: `xcache-2.0.0.tar.bz2'


100%[======================================>] 108,614     26.2K/s   in 4.0s


2019-04-29 02:30:03 (26.2 KB/s) - `xcache-2.0.0.tar.bz2' saved [108614/108614]



[root@localhost ~]# tar xf xcache-2.0.0.tar.bz2

[root@localhost ~]# cd xcache-2.0.0

[root@localhost xcache-2.0.0]#


Xcache是php的模块(是php的扩展)    安装php的时候有些扩展是可以指定,有些扩展可以单独安装




[root@localhost xcache-2.0.0]# man phpize

Cannot open the message catalog "man" for locale "zh_CN.UTF-8"

(NLSPATH="<none>")


No manual entry for phpize

[root@localhost xcache-2.0.0]#


[root@localhost xcache-2.0.0]# man -M /usr/local/php/php/ phpize

Cannot open the message catalog "man" for locale "zh_CN.UTF-8"

(NLSPATH="<none>")


No manual entry for phpize

[root@localhost xcache-2.0.0]#


[root@localhost xcache-2.0.0]# ls /usr/local/php/php/man/man1/

php.1  php-config.1  phpize.1

[root@localhost xcache-2.0.0]#


[root@localhost xcache-2.0.0]# man -M /usr/local/php/php/man phpize

image.png


image.png


(要相关的php命令 (phpize)来加载这个扩展,而且得识别这个扩展)

phpize : phpize - prepare a PHP extension for compiling  准备好一个php扩展以便进行编译的


几乎所有的php扩展 在编译前都要执行这个 phpize的命令的


[root@localhost xcache-2.0.0]# /usr/local/php/bin/phpize

Configuring for:

PHP Api Version:         20100412

Zend Module Api No:      20100525

Zend Extension Api No:   220100525

[root@localhost xcache-2.0.0]#



[root@localhost xcache-2.0.0]# man -M /usr/local/php/php/man php-config

image.png


 php-config - get information about PHP configu-

       ration and compile options

能够获得php的配置信息以及编译时所使用的选项信息


xcache 要根据 php-config 来获取我们的php安装时到底启用了哪些功能



[root@localhost xcache-2.0.0]# pwd

/root/xcache-2.0.0

[root@localhost xcache-2.0.0]# ./configure --help | less

`configure' configures this package to adapt to many kinds of systems.


Usage: ./configure [OPTION]... [VAR=VALUE]...


To assign environment variables (e.g., CC, CFLAGS...), specify them as

VAR=VALUE.  See below for descriptions of some of the useful variables.


Defaults for the options are specified in brackets.


Configuration:

  -h, --help              display this help and exit

      --help=short        display options specific to this package

      --help=recursive    display the short help of all the included packages

  -V, --version           display version information and exit

  -q, --quiet, --silent   do not print `checking...' messages

      --cache-file=FILE   cache test results in FILE [disabled]

  -C, --config-cache      alias for `--cache-file=config.cache'

  -n, --no-create         do not create output files

      --srcdir=DIR        find the sources in DIR [configure

dir or `..']


Installation directories:

  --prefix=PREFIX         install architecture-independent files in PREFIX

                          [/usr/local]   # 这个不用指,它会默认安装到php的扩展目录里面去

  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX

                          [PREFIX]


By default, `make install' will install all the files in

`/usr/local/bin', `/usr/local/lib' etc.  You can specify

an installation prefix other than `/usr/local' using `--prefix',

for instance `--prefix=$HOME'.


For better control, use the options below.


Fine tuning of the installation directories:

  --bindir=DIR           user executables [EPREFIX/bin]

  --sbindir=DIR          system admin executables [EPREFIX/sbin]

  --libexecdir=DIR       program executables [EPREFIX/libexec]

  --datadir=DIR          read-only architecture-independent data [PREFIX/share]

  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]

  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]

  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]

  --libdir=DIR           object code libraries [EPREFIX/lib]

  --includedir=DIR       C header files [PREFIX/include]

  --oldincludedir=DIR    C header files for non-gcc [/usr/include]

  --infodir=DIR          info documentation [PREFIX/info]

  --mandir=DIR           man documentation [PREFIX/man]


System types:

  --build=BUILD     configure for building on BUILD [guessed]

  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

  --target=TARGET   configure for building compilers for TARGET [HOST]


Optional Features:

  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)

  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]

  --enable-xcache         Include XCache support.  #启用 xcache的功能

  --enable-xcache-constant        XCache: Handle new constants made by php compiler (e.g.: for __halt_compiler)

  --enable-xcache-optimizer       XCache: (N/A)

  --enable-xcache-coverager       XCache: Enable code coverage dumper, useful for testing php scripts

  --enable-xcache-assembler       XCache: (N/A)

  --enable-xcache-disassembler    XCache: Enable opcode to php variable dumper, NOT for production server

  --enable-xcache-encoder         XCache: (N/A)

  --enable-xcache-decoder         XCache: (N/A)

  --enable-xcache-test            XCache: Enable self test - FOR DEVELOPERS ONLY!!

  --enable-xcache-dprint          XCache: Enable debug print functions - FOR DEVELOPERS ONLY!!

  --enable-shared=PKGS  build shared libraries default=yes

  --enable-static=PKGS  build static libraries default=yes

  --enable-fast-install=PKGS  optimize for fast installation default=yes

  --disable-libtool-lock  avoid locking (might break parallel builds)


Optional Packages:

  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]

  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)

  --with-libdir=NAME      Look for libraries in .../NAME rather than .../lib

  --with-php-config=PATH  Path to php-config php-config  # 其它大部分不用指,我们一般只需要使用这个--with-php-config 和 --enable-xcache 即可

  --with-gnu-ld           assume the C compiler uses GNU ld default=no

  --with-pic              try to use only PIC/non-PIC objects default=use both

  --with-tags=TAGS      include additional configurations automatic



Some influential environment variables:

  CC          C compiler command

  CFLAGS      C compiler flags

  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a

              nonstandard directory <lib dir>

  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have

              headers in a nonstandard directory <include dir>

  CPP         C preprocessor


Use these variables to override the choices made by `configure' or to help

it to find libraries and programs with nonstandard names/locations.




[root@localhost xcache-2.0.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config

//配置过程

..........................

-with-php-config=/usr/local/php/bin/php-config

[root@localhost xcache-2.0.0]# make

//编译过程        (中间有警告不管它)

..........................


[root@localhost xcache-2.0.0]# make install  #安装过程

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

[root@localhost xcache-2.0.0]#


[root@localhost xcache-2.0.0]# pwd

/root/xcache-2.0.0


[root@localhost xcache-2.0.0]# cat xcache.ini

[xcache-common]

;; install as zend extension (recommended), normally "$extens                                                         ion_dir/xcache.so"

zend_extension = /usr/local/lib/php/extensions/non-debug-non-                                                         zts-xxx/xcache.so

; zend_extension_ts = /usr/local/lib/php/extensions/non-debug                                                         -zts-xxx/xcache.so

;; For windows users, replace xcache.so with php_xcache.dll

zend_extension_ts = c:/php/extensions/php_xcache.dll

;; or install as extension, make sure your extension_dir sett                                                         ing is correct

; extension = xcache.so

;; or win32:

; extension = php_xcache.dll


[xcache.admin]

xcache.admin.enable_auth = On

xcache.admin.user = "mOo"

; xcache.admin.pass = md5($your_password)

xcache.admin.pass = ""


[xcache]

; ini only settings, all the values here is default unless ex                                                         plained


; select low level shm/allocator scheme implemenation

xcache.shm_scheme =        "mmap"

; to disable: xcache.size=0

; to enable : xcache.size=64M etc (any size > 0) and your sys                                                         tem mmap allows

xcache.size  =               60M

; set to cpu count (cat /proc/cpuinfo |grep -c processor)

xcache.count =                 1

; just a hash hints, you can always store count(items) > slot                                                         s

xcache.slots =                8K

; ttl of the cache item, 0=forever

xcache.ttl   =                 0

; interval of gc scanning expired items, 0=no scan, other val                                                         ues is in seconds

xcache.gc_interval =           0


; same as aboves but for variable cache

xcache.var_size  =            4M

xcache.var_count =             1

xcache.var_slots =            8K

; default ttl

xcache.var_ttl   =             0

xcache.var_maxttl   =          0

xcache.var_gc_interval =     300


; N/A for /dev/zero

xcache.readonly_protection = Off

; for *nix, xcache.mmap_path is a file path, not directory.

; Use something like "/tmp/xcache" if you want to turn on Rea                                                         donlyProtection

; 2 group of php won't share the same /tmp/xcache

; for win32, xcache.mmap_path=anonymous map name, not file pa                                                         th

xcache.mmap_path =    "/dev/zero"



; leave it blank(disabled) or "/tmp/phpcore/"

; make sure it's writable by php (open_basedir is not checked                                                         )

xcache.coredump_directory =   ""


; per request settings

xcache.cacher =               On

xcache.stat   =               On

xcache.optimizer =           Off


xcache.test =                Off

xcache.experimental =        Off


[xcache.coverager]

; per request settings

; enable coverage data collecting for xcache.coveragedump_dir                                                         ectory and xcache_coverager_start/stop/get/clean() functions                                                          (will hurt executing performance)

xcache.coverager =          Off


; ini only settings

; make sure it's readable (open_basedir is checked) by covera                                                         ge viewer script

; requires xcache.coverager=On

xcache.coveragedump_directory = ""

[root@localhost xcache-2.0.0]#


[root@localhost xcache-2.0.0]# pwd

/root/xcache-2.0.0

[root@localhost xcache-2.0.0]# ls                #可以看到 xcache.ini 的样例性的配置文件

# 要想让php支持xcache的功能,那么xcache.ini 的配置信息必须要提供到php里面去,所以 cat xcache.ini 追加到 php.ini 里面去

#或者复制 xcache.ini到 php.d 目录下面去

acinclude.m4    const_string.lo                install-sh          NEWS                       stack.h

aclocal.m4      const_string_opcodes_php4.x.h  libtool             opcode_spec.c              stack.lo

admin           const_string_opcodes_php5.0.h  lock.c              opcode_spec_def.h          structinfo.m4

align.h         const_string_opcodes_php5.1.h  lock.h              opcode_spec.h              test.mak

assembler.c     const_string_opcodes_php5.4.h  lock.lo             opcode_spec.lo             tests

AUTHORS         const_string_opcodes_php6.x.h  ltmain.sh           optimizer.c                THANKS

autom4te.cache  COPYING                        Makefile            optimizer.h                utils.c

build           coverager                      Makefile.frag       phpdc.phpr                 utils.h

ChangeLog       coverager.c                    Makefile.fragments  phpdop.phpr                utils.lo

config.guess    coverager.h                    Makefile.global     prepare.devel              xcache.c

config.h        decoder.c                      Makefile.objects    prepare.devel.inc          xcache_globals.h

config.h.in     Decompiler.class.php           mem.c               prepare.devel.inc.example  xcache.h

config.log      decompilesample.php            mem.h               processor                  xcache.ini

config.m4       disassembler.c                 mem.lo              processor.c                xcache.la

config.nice     disassembler.h                 missing             processor.h                xcache.lo

config.status   encoder.c                      mkinstalldirs       processor.lo               xcache-test.ini

config.sub      foreachcoresig.h               mkopcode.awk        processor.out              xcache-zh-gb2312.ini

configure       graph                          mkopcode_spec.awk   processor_real.c           xc_malloc.c

configure.in    include                        mkstructinfo.awk    README                     xc_shm.c

config.w32      includes.c                     mmap.c              run-tests.php              xc_shm.h

const_string.c  includes.i                     mmap.lo             run-xcachetest             xc_shm.lo

const_string.h  INSTALL                        modules             stack.c

[root@localhost xcache-2.0.0]#




[root@localhost xcache-2.0.0]# ls -ls /etc/php.d/

总计 32

4 -rw-r--r-- 1 root root 49 2013-08-19 curl.ini

4 -rw-r--r-- 1 root root 57 2013-08-19 fileinfo.ini

4 -rw-r--r-- 1 root root 49 2013-08-19 json.ini

4 -rw-r--r-- 1 root root 57 2013-08-19 mbstring.ini

4 -rw-r--r-- 1 root root 47 2013-08-19 pdo.ini

4 -rw-r--r-- 1 root root 61 2013-08-19 pdo_sqlite.ini

4 -rw-r--r-- 1 root root 49 2013-08-19 phar.ini

4 -rw-r--r-- 1 root root 47 2013-08-19 zip.ini

[root@localhost xcache-2.0.0]# cp xcache.ini /etc/php.d/

[root@localhost xcache-2.0.0]#


[root@localhost xcache-2.0.0]# vim /etc/php.d/xcache.ini

[xcache-common]    ;普通功能

;; install as zend extension (recommended), normally "$extension_dir/xcache.so"

;zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so

zend_extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/  ;改成真实的路径


; zend_extension_ts = /usr/local/lib/php/extensions/non-debug-zts-xxx/xcache.so

;; For windows users, replace xcache.so with php_xcache.dll

;zend_extension_ts = c:/php/extensions/php_xcache.dll    ;给windows使用的,注释掉就可以了

;; or install as extension, make sure your extension_dir setting is correct

; extension = xcache.so

;; or win32:

; extension = php_xcache.dll


[xcache.admin]    ;管理功能

xcache.admin.enable_auth = On    ;启用认证  当然可以关掉

xcache.admin.user = "mOo"           ;管理用户

; xcache.admin.pass = md5($your_password)

xcache.admin.pass = ""       ;管理密码,是md5加密的


[xcache]

; ini only settings, all the values here is default unless explained


; select low level shm/allocator scheme implemenation

xcache.shm_scheme =        "mmap"           ;shm就是 shared memory 共享内存  ;使用哪种方式来使用共享内存,使用哪种方式在各个php进程之间共享内存   mmap (memory map)叫内存映射,意味着把一段内存可以让多个进程同时访问的,它是其中的一种机制

; to disable: xcache.size=0

; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows

xcache.size  =               60M         ;缓存opcode代码的空间有多大

; set to cpu count (cat /proc/cpuinfo |grep -c processor)

xcache.count =                 1          ;设置cpu个数

; just a hash hints, you can always store count(items) > slots    (hash算法,数据库索引的时候再解释吧)

xcache.slots =                8K        ;缓存当中有几个槽位来缓存多少个opcode的 每一个槽位有多大

; ttl of the cache item, 0=forever

xcache.ttl   =                 0    ;过期时间, 0 表示永远不过期,由xcache自我进行管理

; interval of gc scanning expired items, 0=no scan, other values is in seconds

xcache.gc_interval =           0    ;万一过期了,我们回收过来内存,过期的内容要清除出去, gc( Garbage Collection 回收站,垃圾回收器,垃圾收集器)            这表示我们的垃圾回收器多长时间工作一次 0 表示不做任何扫描的  ;;;xcache.ttl 有过期时间,那么才要扫描的        当然这些额外的机制都会给我们的系统带来额外的资源开销的,用不着,可以不用启用


; same as aboves but for variable cache   ;变量缓存

xcache.var_size  =            4M                 ;变量缓存有多大

xcache.var_count =             1                  ;缓存多少个

xcache.var_slots =            8K               

; default ttl

xcache.var_ttl   =             0

xcache.var_maxttl   =          0

xcache.var_gc_interval =     300


; N/A for /dev/zero

xcache.readonly_protection = Off

; for *nix, xcache.mmap_path is a file path, not directory.

; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection

; 2 group of php won't share the same /tmp/xcache

; for win32, xcache.mmap_path=anonymous map name, not file path

xcache.mmap_path =    "/dev/zero"



; leave it blank(disabled) or "/tmp/phpcore/"

; make sure it's writable by php (open_basedir is not checked)

xcache.coredump_directory =   ""


; per request settings

xcache.cacher =               On            ;xcache缓存功能启用起来

xcache.stat   =               On

xcache.optimizer =           Off               ;xcache自己的优化器没有启用起来   这个不用启用


xcache.test =                Off                    ;xcache测试功能也不用启用

xcache.experimental =        Off


[xcache.coverager]

; per request settings

; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)

xcache.coverager =          Off


; ini only settings

; make sure it's readable (open_basedir is checked) by coverage viewer script

; requires xcache.coverager=On

xcache.coveragedump_directory = ""




要想让它重新生效,必须重启web服务器,xcache模块是被web加载的

[root@localhost xcache-2.0.0]# service httpd restart

停止 httpd:                                               [确定]

启动 httpd:                                               [确定]

[root@localhost xcache-2.0.0]#


[root@localhost xcache-2.0.0]# vim /usr/local/apache/htdocs/index.php

<html><body><h1>It works! my apache</h1></body></html>

<?php

//echo phpinfo();


$conn = mysql_connect('localhost','root','');

if($conn)

  echo "Success...";

else

  echo "Failure...";

phpinfo();

?>


http://192.168.1.45/


readonly 只读的,当然不能让它 readonly

Opcode Cache 启用的 一共62,914,560 bytes ,分出来  4 split(s), 每个槽位   with 8192 slots each

如果把缓存空间大小60M设置为0,意味着禁用

; to disable: xcache.size=0

; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows



image.png


image.png



源码编译的方式使用虚拟主机




oot@localhost httpd]# cd /etc/httpd/

[root@localhost httpd]# pwd

/etc/httpd

[root@localhost httpd]#

root@localhost httpd]# vim httpd.conf

.................................

# DocumentRoot "/usr/local/apache/htdocs"       #注释中心主机


.................................

Include /etc/httpd/extra/httpd-vhosts.conf            #注释去掉,启用这一项

.................................



[root@localhost httpd]# ls

conf    httpd.conf      magic       original

conf.d  httpd.conf.bak  mime.types  run

extra   logs            modules     ssl

[root@localhost httpd]#


[root@localhost httpd]# vim extra/httpd-vhosts.conf

# Virtual Hosts

#

# Required modules: mod_log_config   # 要使用虚拟机 ,得启用这个模块


# If you want to maintain multiple domains/hostnames on your

# machine you can setup VirtualHost containers for them. Most configurations

# use only name-based virtual hosts so the server doesn't need to worry about

# IP addresses. This is indicated by the asterisks in the directives below.

#

# Please see the documentation at

# <URL:http://httpd.apache.org/docs/2.4/vhosts/>

# for further details before you try to setup virtual hosts.

#

# You may use the command line option '-S' to verify your virtual host

# configuration.


#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for all requests that do not

# match a ServerName or ServerAlias in any <VirtualHost> block.

#

<VirtualHost *:80>

    ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot "/usr/local/apache/docs/dummy-host.example.com"

    ServerName dummy-host.example.com

    ServerAlias www.dummy-host.example.com

    ErrorLog "logs/dummy-host.example.com-error_log"   #这是相对路径,相对于 /usr/local/apache/logs

    CustomLog "logs/dummy-host.example.com-access_log" common

</VirtualHost>

<VirtualHost *:80>

    ServerAdmin webmaster@dummy-host2.example.com

    DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"

    ServerName dummy-host2.example.com

    ErrorLog "logs/dummy-host2.example.com-error_log"

    CustomLog "logs/dummy-host2.example.com-access_log" common

</VirtualHost>



[root@localhost httpd]# vim httpd.conf

.................................

LoadModule log_config_module modules/mod_log_config.so        #己经启用它

.................................


[root@localhost httpd]# mkdir -pv /www/{a.org,b.net}

[root@localhost httpd]#




[root@localhost httpd]# vim extra/httpd-vhosts.conf

# configuration.


#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for all requests that do not

# match a ServerName or ServerAlias in any <VirtualHost> block.

# 就算是基于主机名的虚拟主机,它也不需要 NameVirtualHost  了 

<VirtualHost *:80>

    ServerName www.a.org

#    ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot "/www/a.org"

#    ServerAlias www.dummy-host.example.com

    ErrorLog "/var/log/httpd/a.org-error_log"

    CustomLog "/var/log/httpd/a.org-access_log" combined

</VirtualHost>


<VirtualHost *:80>

    ServerName www.b.net

    DocumentRoot "/www/b.net"

    ErrorLog "/var/log/httpd/b.net-error_log"

    CustomLog "/var/log/httpd/b.net-access_log" common

</VirtualHost>



[root@localhost httpd]# httpd -t                #检查语法

Syntax OK

[root@localhost httpd]#

 

[root@localhost httpd]# service httpd restart

停止 httpd:                                               [确定]

启动 httpd:                                               [确定]

[root@localhost httpd]#


[root@localhost httpd]# tail /var/log/httpd/a.org-error_log        #没有任何错误信息

[root@localhost httpd]#

[root@localhost httpd]# echo "<h1>www.a.org</h1>" > /www/a.org/index.html

[root@localhost httpd]#


http://www.a.org/


image.png

[root@localhost httpd]# tail -n 3 /var/log/httpd/a.org-error_log

[Mon Apr 29 05:00:52.404222 2019] [authz_core:error] [pid 18281:tid 2913680272] [client 192.168.1.251:3376] AH01630: client denied by server configuration: /www/a.org/

[Mon Apr 29 05:00:52.479808 2019] [authz_core:error] [pid 18281:tid 2903190416] [client 192.168.1.251:3376] AH01630: client denied by server configuration: /www/a.org/favicon.ico

[Mon Apr 29 05:00:54.591840 2019] [authz_core:error] [pid 18281:tid 2892700560] [client 192.168.1.251:3376] AH01630: client denied by server configuration: /www/a.org/

用户请求被拒绝        默认情况下,简单的加一个目录来开放用户访问就可以了

[root@localhost httpd]#


[root@localhost httpd]# echo "<h1>www.b.net</h1>" > /www/b.net/index.html

[root@localhost httpd]#



windows 上 dos命令下   ipconfig/flushdns       #清空dns缓存 (马哥上面需要,我的正常情况下不需要吧)


http://www.b.net/

image.png

[root@localhost httpd]# vim httpd.conf  #下面这个用户名 和组啥意思 apache以daemon用户daemon组的身份运行? 

..............................

<IfModule unixd_module>

#

# If you wish httpd to run as a different user or group, you must run

# httpd as root initially and it will switch.

#

# User/Group: The name (or #number) of the user/group to run httpd as.

# It is usually good practice to create a dedicated user and group for

# running httpd, as with most system services.

#

User daemon

Group daemon


</IfModule>

...........................


[root@localhost httpd]# vim httpd.conf

...........................

# DocumentRoot "/usr/local/apache/htdocs"

<Directory "/usr/local/apache/htdocs">

    #

    # Possible values for the Options directive are "None", "All",

    # or any combination of:

    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

    #

    # Note that "MultiViews" must be named *explicitly* --- "Options All"

    # doesn't give it to you.

    #

    # The Options directive is both complicated and important.  Please see

    # http://httpd.apache.org/docs/2.4/mod/core.html#options

    # for more information.

    #

    Options Indexes FollowSymLinks


    #

    # AllowOverride controls what directives may be placed in .htaccess files.

    # It can be "All", "None", or any combination of the keywords:

    #   AllowOverride FileInfo AuthConfig Limit

    #

    AllowOverride None


    #

    # Controls who can get stuff from this server.

    #

    Require all granted  #这是啥意思   中心主机是允许的?

</Directory>

...........................


在 2.4当中配置任何虚拟主机的时候,如果没有明确定义某个目录能够被访问,那这个目录就不能被访问




[root@localhost httpd]# vim extra/httpd-vhosts.conf

# configuration.


#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for all requests that do not

# match a ServerName or ServerAlias in any <VirtualHost> block.

#

<VirtualHost *:80>

    ServerName www.a.org

#    ServerAdmin webmaster@dummy-host.example.com

    DocumentRoot "/www/a.org"

    <Directory "/www/a.org">

        Options none

        AllowOverride none

        Require all granted

    </Directory>

#    ServerAlias www.dummy-host.example.com

    ErrorLog "/var/log/httpd/a.org-error_log"

    CustomLog "/var/log/httpd/a.org-access_log" combined

</VirtualHost>


<VirtualHost *:80>

    ServerName www.b.net

    DocumentRoot "/www/b.net"

    <Directory "/www/b.net">

        Options none

        AllowOverride none

        Require all granted

    </Directory>

    ErrorLog "/var/log/httpd/b.net-error_log"

    CustomLog "/var/log/httpd/b.net-access_log" common

</VirtualHost>



[root@localhost httpd]# service httpd restart

停止 httpd:                                               [确定]

启动 httpd:                                               [确定]

[root@localhost httpd]#


http://www.a.org/


http://www.b.net/index.html



测试性能  压力测试


[root@localhost httpd]# cd /usr/local/apache/

[root@localhost apache]# ls

bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules

[root@localhost apache]# ls bin/

ab         checkgid   envvars-std   htdbm     httpd       rotatelogs

apachectl  dbmmanage  fcgistarter   htdigest  httxt2dbm

apxs       envvars    htcacheclean  htpasswd  logresolve

[root@localhost apache]#


ab:  apache benchmark (apache 性能压力测试工具, apache  性能评估工具)


[root@localhost apache]# man ab

Cannot open the message catalog "man" for locale "zh_CN.UTF-8"

(NLSPATH="<none>")


Formatting page, please wait...

AB(8)                                 ab                                 AB(8)


NAME

       ab - Apache HTTP server benchmarking tool


SYNOPSIS

       ab  [  -A  auth-username:password  ]  [  -c  concurrency ] [ -C cookie-

       name=value ] [ -d ] [ -e csv-file ] [ -g gnuplot-file ] [  -h  ]  [  -H

       custom-header  ]  [  -i  ] [ -k ] [ -n requests ] [ -p POST-file ] [ -P

       proxy-auth-username:password ] [ -q ] [ -s ] [ -S ] [ -t timelimit ]  [

       -T content-type ] [ -v verbosity] [ -V ] [ -w ] [ -x <table>-attributes

       ] [ -X proxy[:port] ] [ -y <tr>-attributes ]  [  -z  <td>-attributes  ]

       [http://]hostname[:port]/path


SUMMARY

       ab  is  a tool for benchmarking your Apache Hypertext Transfer Protocol

       (HTTP) server. It is designed to give you an  impression  of  how  your

       current  Apache  installation  performs.  This especially shows you how

       many requests per second your Apache installation is capable  of  serv-

       ing.


OPTIONS

       -A auth-username:password

:


-c  concurrency (并发量)

下图是并发量 一次可以同时处理多少个请求

image.png



-n requests  一共请求多少个


-n 要大于 -c 的 ,

image.png



[root@localhost apache]# vim /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1               localhost.localdomain localhost

::1             localhost6.localdomain6 localhost6

192.168.1.45    www.a.org

192.168.1.45    www.b.net

~




ab 测试的时候,必须要带上页面  不能仅仅是 域名

[root@localhost apache]# ab -c 10 -n 1000 http://www.a.org/index.html

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

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

Copyright 2006 The Apache Software Foundation, http://www.apache.org/


Benchmarking www.a.org (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Finished 1000 requests



Server Software:        Apache/2.4.4        测试的服务器软件及版本号

Server Hostname:        www.a.org          主机名称   

Server Port:            80                             端口


Document Path:          /index.html        请求的文件

Document Length:        19 bytes           这个文件有多大


Concurrency Level:      10            并发级别10个

Time taken for tests:   0.825678 seconds       第一个请求开始(tcp连接开始)到最后一个请求的?响应报文,响应回来结束直接所经过的时长

Complete requests:      1000        成功请求得到多少个

Failed requests:        0        失败的请求有几个

Write errors:           0          失败的写入次数

Total transferred:      273000 bytes        服务器响应给我们的整体的数据量的大小 (总的 既包括每个报文,又包括每个报文的首部加起来)

HTML transferred:       19000 bytes        仅指每个报文的大小, 首部就不所含了

image.png

Requests per second:    1211.13 [#/sec] (mean)        每秒钟完成的请求数,数字不大,是因为请求太少了

Time per request:       8.257 [ms] (mean)        (它是一批请求(10个请求)同时完成的时间,可不是一个请求完成的时间)           

Time per request:       0.826 [ms] (mean, across all concurrent requests)  每个请求平均花费的时间是0.8毫秒 (1000个请求都完成)

Transfer rate:          322.16 [Kbytes/sec] received        传输速率,大约每秒钟传输了多少个字节


Connection Times (ms)      (ms 是毫秒吧)(下面的0,不是真正的0,可能精确度不够)

              min  mean[+/-sd] median   max              ( [+/-sd] 表示误差吧)

Connect:        0    0   0.5      0      12                建立连接所花费的时间        mean就是平均的意思?    0.5 是误差

Processing:     0    7  31.2      0     356             处理过程的时间

Waiting:        0    7  31.1      0     355               等待时间,请求过去了,等待响应的时间?请求传输(不是响应传输)的时间?

Total:          0    7  31.2      0     356


Percentage of the requests served within a certain time (ms)

  50%      0

  66%      0

  75%      1

  80%      1

  90%      7

  95%     54

  98%    106

  99%    186

 100%    356 (longest request)

[root@localhost apache]#



[root@localhost apache]# ab -c 2 -n 1000 http://www.a.org/index.html

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

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

Copyright 2006 The Apache Software Foundation, http://www.apache.org/


Benchmarking www.a.org (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Finished 1000 requests



Server Software:        Apache/2.4.4

Server Hostname:        www.a.org

Server Port:            80


Document Path:          /index.html

Document Length:        19 bytes


Concurrency Level:      2

Time taken for tests:   0.140876 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Total transferred:      273000 bytes

HTML transferred:       19000 bytes

Requests per second:    7098.44 [#/sec] (mean)

Time per request:       0.282 [ms] (mean)

Time per request:       0.141 [ms] (mean, across all concurrent requests)

Transfer rate:          1888.19 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    0   0.5      0      16

Processing:     0    0   0.5      0      16

Waiting:        0    0   0.0      0       1

Total:          0    0   0.7      0      16


Percentage of the requests served within a certain time (ms)

  50%      0

  66%      0

  75%      0

  80%      0

  90%      0

  95%      0

  98%      0

  99%      0

 100%     16 (longest request)

[root@localhost apache]#



[root@localhost apache]# ab -c 1000 -n 1000 http://www.a.org/index.html

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

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

Copyright 2006 The Apache Software Foundation, http://www.apache.org/


Benchmarking www.a.org (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Finished 1000 requests



Server Software:        Apache/2.4.4

Server Hostname:        www.a.org

Server Port:            80


Document Path:          /index.html

Document Length:        19 bytes


Concurrency Level:      1000

Time taken for tests:   6.386959 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Total transferred:      273000 bytes

HTML transferred:       19000 bytes

Requests per second:    156.57 [#/sec] (mean)

Time per request:       6386.959 [ms] (mean)

Time per request:       6.387 [ms] (mean, across all concurrent requests)

Transfer rate:          41.65 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0   12   7.0     13      23

Processing:    11 1093 1878.6    210    6365

Waiting:       10 1091 1878.8    208    6364

Total:         12 1105 1880.8    225    6386


Percentage of the requests served within a certain time (ms)

  50%    225

  66%    638

  75%   1444

  80%   1473

  90%   3103

  95%   6383

  98%   6384

  99%   6385

 100%   6386 (longest request)

[root@localhost apache]#



[root@localhost apache]# ab -c 100 -n 5000 http://www.a.org/index.html

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

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

Copyright 2006 The Apache Software Foundation, http://www.apache.org/


Benchmarking www.a.org (be patient)

Completed 500 requests

Completed 1000 requests

Completed 1500 requests

Completed 2000 requests

Completed 2500 requests

Completed 3000 requests

Completed 3500 requests

Completed 4000 requests

Completed 4500 requests

Finished 5000 requests



Server Software:        Apache/2.4.4

Server Hostname:        www.a.org

Server Port:            80


Document Path:          /index.html

Document Length:        19 bytes


Concurrency Level:      100

Time taken for tests:   0.574735 seconds

Complete requests:      5000

Failed requests:        0

Write errors:           0

Total transferred:      1369641 bytes

HTML transferred:       95323 bytes

Requests per second:    8699.66 [#/sec] (mean)

Time per request:       11.495 [ms] (mean)

Time per request:       0.115 [ms] (mean, across all concurrent requests)

Transfer rate:          2326.29 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    1   2.1      1      18

Processing:     0    9  23.3      6     341

Waiting:        0    5  22.9      2     336

Total:          0   10  23.5      7     341


Percentage of the requests served within a certain time (ms)

  50%      7

  66%      8

  75%      9

  80%     11

  90%     18

  95%     24

  98%     30

  99%     96

 100%    341 (longest request)

[root@localhost apache]#



同时请求太多 会报错了 

[root@localhost apache]# ab -c 5000 -n 50000 http://www.a.org/index.html  

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

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

Copyright 2006 The Apache Software Foundation, http://www.apache.org/


Benchmarking www.a.org (be patient)

socket: Too many open files (24)

[root@localhost apache]#


马哥的报错 ,可能是打开的请求太多了

image.png

马哥 加上 -r 能忽略这个错误

image.png

我加上  -r 就提示没有-r 这个选项

image.png


[root@localhost apache]# locate -r /ab$

/root/httpd-2.4.4/support/ab

/usr/bin/ab

/usr/local/apache/bin/ab

/usr/share/locale/ab

[root@localhost apache]#

像下面这个 使用 -r 才可以 ,可以 ab版本不一样

[root@localhost apache]# /root/httpd-2.4.4/support/ab  -r -c 5000 -n 50000 http://www.a.org/index.html

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

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

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


Benchmarking www.a.org (be patient)

socket: Too many open files (24)

[root@localhost apache]#

并发量不一样, 请求个数是一样的 ,但是  下面这些值会不一样

Requests per second:    8699.66 [#/sec] (mean)

Time per request:       11.495 [ms] (mean)

Time per request:       0.115 [ms] (mean, across all concurrent requests)




image.png


[root@localhost apache]# /root/httpd-2.4.4/support/ab  -r -c 5000 -n 50000 http://www.a.org/index.html

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

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

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


Benchmarking www.a.org (be patient)

socket: Too many open files (24)

[root@localhost apache]#

image.png

上面报错是因为: linux命令有个限定,每一个进程不能打开超过 1024 (1000?)个文件

并发2000个,每一个都是一个套接字文件,打开2000个文件了


[root@localhost apache]# ulimit -n 10000            改变限定,让每个进程可以打开10000个文件.

[root@localhost apache]#


下面的代码 可能两次执行结果不一样

[root@localhost apache]# /root/httpd-2.4.4/support/ab  -r -c 5000 -n 50000 http://www.a.org/index.html

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

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

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


Benchmarking www.a.org (be patient)

socket: Too many open files (24)

[root@localhost apache]# ulimit -n 10000

[root@localhost apache]# /root/httpd-2.4.4/support/ab  -r -c 5000 -n 50000 http://www.a.org/index.html

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

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

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


Benchmarking www.a.org (be patient)

Completed 5000 requests

Completed 10000 requests

Completed 15000 requests

Completed 20000 requests

Completed 25000 requests

Completed 30000 requests

Completed 35000 requests

Completed 40000 requests

Completed 45000 requests

Completed 50000 requests

Finished 50000 requests



Server Software:        Apache/2.4.4

Server Hostname:        www.a.org

Server Port:            80


Document Path:          /index.html

Document Length:        19 bytes


Concurrency Level:      5000

Time taken for tests:   26.419 seconds

Complete requests:      50000

Failed requests:        136

   (Connect: 0, Receive: 0, Length: 136, Exceptions: 0)

Write errors:           0

Total transferred:      13612872 bytes

HTML transferred:       947416 bytes

Requests per second:    1892.59 [#/sec] (mean)

Time per request:       2641.879 [ms] (mean)

Time per request:       0.528 [ms] (mean, across all concurrent requests)

Transfer rate:          503.20 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0  252 758.8     37    3343

Processing:    34  265 1473.8    142   23006

Waiting:        1  141 873.6     75   22880

Total:         39  517 1752.8    176   26191


Percentage of the requests served within a certain time (ms)

  50%    176

  66%    197

  75%    217

  80%    237

  90%    477

  95%   3430

  98%   3592

  99%   4342

 100%  26191 (longest request)

[root@localhost apache]#



[root@localhost apache]# netstat -an

image.png这些太多的套接字文件,此前发起的每一个请求,我们的服务器都是维持一个套接字(一个连接)

太多的连接还在等待 未断开 ( 因为每个连接 要经历三次握手,四次挥手(断开) ) ,所以两次执行大量的 ab 命令,会结果不一样



[root@localhost apache]# ls -lh /var/log

总计 5.9M

-rw-r----- 1 root  root  4.5K 04-29 02:04 acpid

-rw------- 1 root  root  558K 11-10 14:26 anaconda.log

-rw------- 1 root  root   41K 11-10 14:26 anaconda.syslog

-rw------- 1 root  root   47K 11-10 14:26 anaconda.xlog

drwxr-x--- 2 root  root  4.0K 11-10 14:28 audit

-rw------- 1 root  root     0 04-29 03:09 boot.log

-rw------- 1 root  root     0 03-31 11:51 boot.log.1

-rw------- 1 root  root     0 03-29 01:38 boot.log.2

-rw------- 1 root  root     0 03-04 06:43 boot.log.3

-rw------- 1 root  root     0 02-24 03:33 boot.log.4

-rw------- 1 root  utmp  8.3K 04-29 05:22 btmp

drwxr-xr-x 2 root  root  4.0K 2007-06-28 conman

drwxr-xr-x 2 root  root  4.0K 2007-06-28 conman.old

-rw------- 1 root  root   985 04-29 08:01 cron

-rw------- 1 root  root  7.5K 04-29 03:09 cron.1

-rw------- 1 root  root  4.8K 03-31 11:51 cron.2

-rw------- 1 root  root  3.9K 03-29 01:37 cron.3

-rw------- 1 root  root  4.6K 03-04 06:43 cron.4

drwxr-xr-x 2 lp    sys   4.0K 04-29 03:09 cups

-rw-r--r-- 1 root  root   37K 04-29 02:04 dmesg

-rw------- 1 root  root   12K 04-03 22:04 faillog

drwxr-xr-x 2 root  root  4.0K 11-10 14:40 gdm

drwx------ 2 root  root  4.0K 04-29 03:09 httpd

-rw------- 1 root  root  1.8M 04-29 08:20 kern.log

-rw-r--r-- 1 root  root  144K 04-29 08:20 lastlog

drwxr-xr-x 2 root  root  4.0K 11-10 14:13 mail

-rw------- 1 root  root   887 04-29 04:02 maillog

-rw------- 1 root  root  4.9K 04-29 03:09 maillog.1

-rw------- 1 root  root  3.4K 03-31 11:51 maillog.2

-rw------- 1 root  root  2.5K 03-29 01:38 maillog.3

-rw------- 1 root  root  3.0K 03-04 06:43 maillog.4

-rw------- 1 root  root   18K 04-29 08:25 messages

-rw------- 1 root  root  1.9M 04-29 03:09 messages.1

-rw------- 1 root  root  222K 03-31 11:51 messages.2

-rw------- 1 root  root   99K 03-29 01:38 messages.3

-rw------- 1 root  root   77K 03-04 05:38 messages.4

-rw-r----- 1    27    27 2.0K 04-03 21:08 mysqld.log.rpmsave

drwxrwx--- 2 named named 4.0K 02-17 20:08 named

drwxr-xr-x 2 root  root  4.0K 11-10 14:19 pm

drwx------ 2 root  root  4.0K 2008-08-12 ppp

drwxr-xr-x 2 root  root  4.0K 12-10 14:39 prelink

drwxr-xr-x 2 root  root  4.0K 03-31 11:51 rhsm

-rw-r--r-- 1 root  root   34K 04-29 04:02 rpmpkgs

-rw-r--r-- 1 root  root   34K 04-04 04:02 rpmpkgs.1

-rw-r--r-- 1 root  root   34K 03-30 04:02 rpmpkgs.2

-rw-r--r-- 1 root  root   34K 03-05 04:02 rpmpkgs.3

-rw-r--r-- 1 root  root   34K 02-25 04:02 rpmpkgs.4

drwx------ 2 root  root  4.0K 2012-03-21 samba

-rw-r--r-- 1 root  root   72K 04-02 09:00 scrollkeeper.log

-rw------- 1 root  root   748 04-29 08:20 secure

-rw------- 1 root  root  8.3K 04-29 02:29 secure.1

-rw------- 1 root  root  3.3K 03-31 10:46 secure.2

-rw------- 1 root  root  2.0K 03-29 01:22 secure.3

-rw------- 1 root  root  3.3K 03-04 05:38 secure.4

drwxr-xr-x 2 root  root  4.0K 04-29 03:09 setroubleshoot

-rw------- 1 root  root     0 04-29 03:09 spooler

-rw------- 1 root  root     0 03-31 11:51 spooler.1

-rw------- 1 root  root     0 03-29 01:38 spooler.2

-rw------- 1 root  root     0 03-04 06:43 spooler.3

-rw------- 1 root  root     0 02-24 03:33 spooler.4

drwxr-x--- 2 squid squid 4.0K 2010-02-16 squid

-rw------- 1 root  root     0 11-10 14:12 tallylog

drwxr-xr-x 2 root  root  4.0K 2009-06-09 vbox

-rw-rw-r-- 1 root  utmp  419K 04-29 08:20 wtmp

-rw-r--r-- 1 root  root   47K 11-10 14:40 Xorg.0.log

-rw-r--r-- 1 root  root   47K 11-10 14:36 Xorg.0.log.old

-rw------- 1 root  root  2.5K 04-03 21:08 yum.log

-rw-r--r-- 1 root  root   132 12-20 13:21 yum.log.1

[root@localhost apache]#


[root@localhost apache]# ls -lh /var/log/lastlog

-rw-r--r-- 1 root root 144K 04-29 08:20 /var/log/lastlog

[root@localhost apache]#


[root@localhost apache]# cp /var/log/lastlog /www/a.org/test.html

[root@localhost apache]#


过几分钟,让所有的套接字等待全部结束,

[root@localhost apache]# netstat -an

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address               Foreign Address             Stat                                      e

tcp        0      0 127.0.0.1:2208              0.0.0.0:*                   LIST                                      EN

tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LIST                                      EN

tcp        0      0 0.0.0.0:688                 0.0.0.0:*                   LIST                                      EN

tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LIST                                      EN

tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LIST                                      EN

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LIST                                      EN

tcp        0      0 127.0.0.1:2207              0.0.0.0:*                   LIST                                      EN

tcp        0    500 192.168.1.45:22             192.168.1.251:2625          ESTA                                      BLISHED

tcp        0      0 192.168.1.45:22             192.168.1.251:11034         ESTA                                      BLISHED

tcp        0      0 :::80                       :::*                        LIST                                      EN

tcp        0      0 :::22                       :::*                        LIST                                      EN

udp        0      0 0.0.0.0:682                 0.0.0.0:*                                                             

udp        0      0 0.0.0.0:685                 0.0.0.0:*                                                             

udp        0      0 0.0.0.0:35932               0.0.0.0:*                                                             

udp        0      0 0.0.0.0:5353                0.0.0.0:*                                                             

udp        0      0 0.0.0.0:111                 0.0.0.0:*                                                             

udp        0      0 0.0.0.0:631                 0.0.0.0:*                                                             

udp        0      0 :::55005                    :::*                                                                  

udp        0      0 :::5353                     :::*                                                                  

Active UNIX domain sockets (servers and established)

Proto RefCnt Flags       Type       State         I-Node Path

unix  2      [ ACC ]     STREAM     LISTENING     7269   @ISCSIADM_ABSTRACT_NAME                                      SPACE

unix  2      [ ACC ]     STREAM     LISTENING     11765  @/tmp/fam-root-

unix  2      [ ACC ]     STREAM     LISTENING     11616  /var/run/avahi-daemon/s                                      ocket

unix  2      [ ACC ]     STREAM     LISTENING     11477  /tmp/.font-unix/fs7100

unix  2      [ ACC ]     STREAM     LISTENING     8788   @/var/run/hald/dbus-s1V                                      EVQlPzO

unix  2      [ ACC ]     STREAM     LISTENING     11310  /dev/gpmctl

unix  2      [ ACC ]     STREAM     LISTENING     7254   @ISCSID_UIP_ABSTRACT_NA                                      MESPACE

unix  2      [ ACC ]     STREAM     LISTENING     8787   @/var/run/hald/dbus-DVt                                      Sk64Jkq

unix  2      [ ]         DGRAM                    1775   @/org/kernel/udev/udevd

unix  2      [ ]         DGRAM                    8796   @/org/freedesktop/hal/u                                      dev_event

unix  2      [ ACC ]     STREAM     LISTENING     7832   /var/run/audispd_events

unix  2      [ ACC ]     STREAM     LISTENING     8506   /var/run/dbus/system_bu                                      s_socket

unix  2      [ ACC ]     STREAM     LISTENING     8602   /var/run/sdp

unix  18     [ ]         DGRAM                    7895   /dev/log

unix  2      [ ACC ]     STREAM     LISTENING     8721   /var/run/pcscd.comm

unix  2      [ ACC ]     STREAM     LISTENING     8743   /var/run/acpid.socket

unix  2      [ ACC ]     STREAM     LISTENING     10869  /var/run/cups/cups.sock

unix  2      [ ]         DGRAM                    360036

unix  2      [ ]         DGRAM                    54182

unix  3      [ ]         STREAM     CONNECTED     11768  @/tmp/fam-root-

unix  3      [ ]         STREAM     CONNECTED     11767

unix  3      [ ]         STREAM     CONNECTED     11758  /var/run/dbus/system_bu                                      s_socket

unix  3      [ ]         STREAM     CONNECTED     11757

unix  3      [ ]         STREAM     CONNECTED     11619  /var/run/dbus/system_bu                                      s_socket

unix  3      [ ]         STREAM     CONNECTED     11618

unix  3      [ ]         STREAM     CONNECTED     11613

unix  3      [ ]         STREAM     CONNECTED     11612

unix  2      [ ]         DGRAM                    11610

unix  2      [ ]         DGRAM                    11404

unix  2      [ ]         DGRAM                    11282

unix  2      [ ]         DGRAM                    11248

unix  2      [ ]         DGRAM                    11213

unix  2      [ ]         DGRAM                    10931

unix  2      [ ]         DGRAM                    10761

unix  2      [ ]         DGRAM                    10711

unix  2      [ ]         DGRAM                    10582

unix  3      [ ]         STREAM     CONNECTED     10544  /var/run/dbus/system_bu                                      s_socket

unix  3      [ ]         STREAM     CONNECTED     10543

unix  3      [ ]         STREAM     CONNECTED     10481  @/var/run/hald/dbus-DVt                                      Sk64Jkq

unix  3      [ ]         STREAM     CONNECTED     10480

unix  3      [ ]         STREAM     CONNECTED     10312  @/var/run/hald/dbus-DVt                                      Sk64Jkq

unix  3      [ ]         STREAM     CONNECTED     10311

unix  3      [ ]         STREAM     CONNECTED     10252  /var/run/acpid.socket

unix  3      [ ]         STREAM     CONNECTED     10251

unix  3      [ ]         STREAM     CONNECTED     10232  @/var/run/hald/dbus-DVt                                      Sk64Jkq

unix  3      [ ]         STREAM     CONNECTED     10231

unix  3      [ ]         STREAM     CONNECTED     8791   @/var/run/hald/dbus-s1V                                      EVQlPzO

unix  3      [ ]         STREAM     CONNECTED     8790

unix  2      [ ]         DGRAM                    8707

unix  3      [ ]         STREAM     CONNECTED     8596   /var/run/dbus/system_bu                                      s_socket

unix  3      [ ]         STREAM     CONNECTED     8595

unix  2      [ ]         DGRAM                    8575

unix  2      [ ]         DGRAM                    8565

unix  3      [ ]         STREAM     CONNECTED     8510

unix  3      [ ]         STREAM     CONNECTED     8509

unix  3      [ ]         STREAM     CONNECTED     8418

unix  3      [ ]         STREAM     CONNECTED     8417

unix  2      [ ]         DGRAM                    8275

unix  2      [ ]         DGRAM                    7903

unix  3      [ ]         STREAM     CONNECTED     7823

unix  3      [ ]         STREAM     CONNECTED     7822

[root@localhost apache]#


[root@localhost apache]# /usr/local/apache/bin/ab -r -c 2000 -n 10000 http://www.a.org/test.html

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

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

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


Benchmarking www.a.org (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests



Server Software:        Apache/2.4.4

Server Hostname:        www.a.org

Server Port:            80


Document Path:          /test.html

Document Length:        147168 bytes


Concurrency Level:      2000

Time taken for tests:   6.322 seconds

Complete requests:      10000

Failed requests:        0

Write errors:           0

Total transferred:      1474290000 bytes

HTML transferred:       1471680000 bytes

Requests per second:    1581.84 [#/sec] (mean)

Time per request:       1264.349 [ms] (mean)

Time per request:       0.632 [ms] (mean, across all concurrent requests)  #每个请求多久

Transfer rate:          227743.46 [Kbytes/sec] received   #每秒传22万个字节  227743.46/1024=222.4

                                                                                      #再乘以8 * 222.4 = 1779 兆 所以千兆网都不行


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0   27  23.6     17     101

Processing:    69  296 777.2    137    6255

Waiting:        1  198 787.3     29    6251

Total:         91  324 784.5    164    6321


Percentage of the requests served within a certain time (ms)

  50%    164

  66%    177

  75%    192

  80%    207

  90%    332

  95%    776

  98%   1730

  99%   6305

 100%   6321 (longest request)

[root@localhost apache]#



这是 event ,不是一个请求一个进程的, 

反正进程也是很多的 (当然比 prefork 少许多)

[root@localhost ~]# ps aux | grep httpd

root     18506  0.0  1.0 100216 11304 ?        Ss   05:45   0:00 /usr/local/apac                                      he/bin/httpd

daemon   18539  0.0  2.7 400644 28896 ?        Sl   05:45   0:01 /usr/local/apac                                      he/bin/httpd

daemon   19036  0.0  2.5 397312 26720 ?        Sl   08:17   0:00 /usr/local/apac                                      he/bin/httpd

daemon   19038  0.0  2.5 399576 26892 ?        Sl   08:17   0:00 /usr/local/apac                                      he/bin/httpd

daemon   19092  0.0  2.7 401440 27988 ?        Sl   08:17   0:00 /usr/local/apac                                      he/bin/httpd

daemon   19094  0.0  2.5 398636 26636 ?        Sl   08:17   0:00 /usr/local/apac                                      he/bin/httpd

daemon   19116  0.1  2.9 401340 30408 ?        Sl   08:17   0:01 /usr/local/apac                                      he/bin/httpd

daemon   19124  0.1  2.9 402652 30672 ?        Sl   08:17   0:01 /usr/local/apac                                      he/bin/httpd

daemon   19265  0.0  2.9 402208 30364 ?        Sl   08:18   0:00 /usr/local/apac                                      he/bin/httpd

daemon   19293  0.1  3.1 402504 32568 ?        Sl   08:18   0:01 /usr/local/apac                                      he/bin/httpd

daemon   19295  0.1  3.4 409060 35184 ?        Sl   08:18   0:01 /usr/local/apac                                      he/bin/httpd

root     19422  0.0  0.0   4280   716 pts/0    S+   08:35   0:00 grep httpd

[root@localhost ~]# 



[root@localhost ~]# dd if=/dev/zero of=/www/a.org/test3.html bs=1M count=2

2+0 records in

2+0 records out

2097152 bytes (2.1 MB) copied, 0.00201316 seconds, 1.0 GB/s

[root@localhost ~]#



网页文件压缩下 能够节约带宽的

每秒钟响应的带宽 * 86400(秒) 就是每天能够响应的流量



[root@localhost ~]# /usr/local/apache/bin/ab -r -c 2000 -n 10000 http://www.org.com/test3.html

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

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

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


Benchmarking www.org.com (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests



Server Software:        nginx/1.10.1

Server Hostname:        www.org.com

Server Port:            80


Document Path:          /test3.html

Document Length:        9 bytes


Concurrency Level:      2000

Time taken for tests:   189.609 seconds

Complete requests:      10000

Failed requests:        12463

   (Connect: 0, Receive: 1410, Length: 9643, Exceptions: 1410)

Write errors:           0

Non-2xx responses:      8590

Total transferred:      2734141 bytes

HTML transferred:       1394590 bytes

Requests per second:    52.74 [#/sec] (mean)        #每秒钟响应 52 个请求   要按峰值(最大量)作为响应请求的标准

Time per request:       37921.708 [ms] (mean)

Time per request:       18.961 [ms] (mean, across all concurrent requests)

Transfer rate:          14.08 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0 4566 10669.4    343   93477

Processing:   265 27264 65556.1    333  189011

Waiting:        0  610 1761.9    320   10372

Total:        548 31830 64577.0   3638  189011


Percentage of the requests served within a certain time (ms)

  50%   3638

  66%   9615

  75%   9671

  80%  21603

  90%  189005

  95%  189008

  98%  189009

  99%  189010

 100%  189011 (longest request)

[root@localhost ~]#


[root@localhost ~]# /usr/local/apache/bin/ab -r -c 200 -n 500 http://www.org.com/test3.html

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

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

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


Benchmarking www.org.com (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Finished 500 requests



Server Software:        nginx/1.10.1

Server Hostname:        www.org.com

Server Port:            80


Document Path:          /test3.html

Document Length:        9 bytes


Concurrency Level:      200

Time taken for tests:   50.707 seconds

Complete requests:      500

Failed requests:        398

   (Connect: 0, Receive: 0, Length: 398, Exceptions: 0)

Write errors:           0

Non-2xx responses:      500

Total transferred:      157766 bytes

HTML transferred:       68180 bytes

Requests per second:    9.86 [#/sec] (mean)

Time per request:       20282.825 [ms] (mean)

Time per request:       101.414 [ms] (mean, across all concurrent requests)

Transfer rate:          3.04 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:      261 2370 5023.6    361   21340

Processing:   273 1820 3179.6    339   11158

Waiting:      273 1818 3174.0    339   10349

Total:        565 4190 6135.5    759   30990


Percentage of the requests served within a certain time (ms)

  50%    759

  66%   1706

  75%   6973

  80%   9656

  90%  11456

  95%  21578

  98%  21625

  99%  21670

 100%  30990 (longest request)

[root@localhost ~]#



image.png

image.png

image.png


[root@localhost ~]# wget https://files.phpmyadmin.net/phpMyAdmin/3.5.1/phpMyAdmin-3.5.1-all-languages.zip

--2019-04-29 09:49:42--  https://files.phpmyadmin.net/phpMyAdmin/3.5.1/phpMyAdmin-3.5.1-all-languages.zip

正在解析主机 files.phpmyadmin.net... 185.180.13.25

Connecting to files.phpmyadmin.net|185.180.13.25|:443... 已连接。

ERROR: cannot verify files.phpmyadmin.net's certificate, issued by `/C=US/O=DigiCert Inc/CN=DigiCert SHA2 Secure Server CA':

  Issued certificate not yet valid.

ERROR: certificate common name `rsc.cdn77.org' doesn't match requested host name `files.phpmyadmin.net'.

To connect to files.phpmyadmin.net insecurely, use `--no-check-certificate'.

无法建立 SSL 连接。

[root@localhost ~]# wget https://files.phpmyadmin.net/phpMyAdmin/3.5.1/phpMyAdmin-3.5.1-all-languages.zip `--no-check-certificate

>

[root@localhost ~]# wget https://files.phpmyadmin.net/phpMyAdmin/3.5.1/phpMyAdmin-3.5.1-all-languages.zip --no-check-certificate

--2019-04-29 09:49:54--  https://files.phpmyadmin.net/phpMyAdmin/3.5.1/phpMyAdmin-3.5.1-all-languages.zip

正在解析主机 files.phpmyadmin.net... 185.180.13.212

Connecting to files.phpmyadmin.net|185.180.13.212|:443... 已连接。

WARNING: cannot verify files.phpmyadmin.net's certificate, issued by `/C=US/O=DigiCert Inc/CN=DigiCert SHA2 Secure Server CA':

  Issued certificate not yet valid.

WARNING: certificate common name `rsc.cdn77.org' doesn't match requested host name `files.phpmyadmin.net'.

已发出 HTTP 请求,正在等待回应... 200 OK

长度:6145653 (5.9M) [application/zip]

Saving to: `phpMyAdmin-3.5.1-all-languages.zip'


100%[======================================>] 6,145,653    305K/s   in 20s


2019-04-29 09:50:17 (297 KB/s) - `phpMyAdmin-3.5.1-all-languages.zip' saved [6145653/6145653]


[root@localhost ~]#


解压一下

[root@localhost ~]# unzip phpMyAdmin-3.5.1-all-languages.zip

.............................................................

[root@localhost ~]# mv phpMyAdmin-3.5.1-all-languages/ /www/b.net/

[root@localhost ~]#

[root@localhost ~]# cd /www/b.net/

[root@localhost b.net]# ls

admin.php        data         member.php                      stat

api              favicon.ico  misc.php                        temp

api.php          forum.php    phpMyAdmin-3.5.1-all-languages  uc_c

archiver         group.php    plugin.php                      uc_s

config           home.php     portal.php                      user

connect.php      index.html   robots.txt

cp.php           index.php    search.php

crossdomain.xml  install      source

[root@localhost b.net]#



[root@localhost b.net]# mv phpMyAdmin-3.5.1-all-languages/ pma

[root@localhost b.net]# cd pma/

[root@localhost pma]#

[root@localhost pma]# ls

browse_foreigners.php     favicon.ico            RELEASE-DATE-3.5.1      tbl_gis_visualization.php

bs_disp_as_mime_type.php  file_echo.php          robots.txt              tbl_import.php

bs_play_media.php         gis_data_editor.php    schema_edit.php         tbl_indexes.php

ChangeLog                 import.php             schema_export.php       tbl_move_copy.php

changelog.php             import_status.php      server_binlog.php       tbl_operations.php

chk_rel.php               index.php              server_collations.php   tbl_printview.php

config.sample.inc.php     js                     server_databases.php    tbl_relation.php

db_create.php             libraries              server_engines.php      tbl_replace.php

db_datadict.php           LICENSE                server_export.php       tbl_row_action.php

db_events.php             license.php            server_import.php       tbl_select.php

db_export.php             locale                 server_plugins.php      tbl_sql.php

db_import.php             main.php               server_privileges.php   tbl_structure.php

db_operations.php         navigation.php         server_replication.php  tbl_tracking.php

db_printview.php          phpinfo.php            server_sql.php          tbl_triggers.php

db_qbe.php                phpmyadmin.css.php     server_status.php       tbl_zoom_select.php

db_routines.php           pmd_display_field.php  server_synchronize.php  themes

db_search.php             pmd_general.php        server_variables.php    themes.php

db_sql.php                pmd_pdf.php            setup                   transformation_overview.php

db_structure.php          pmd_relation_new.php   show_config_errors.php  transformation_wrapper.php

db_tracking.php           pmd_relation_upd.php   sql.php                 url.php

db_triggers.php           pmd_save_pos.php       tbl_addfield.php        user_password.php

docs.css                  prefs_forms.php        tbl_alter.php           view_create.php

Documentation.html        prefs_manage.php       tbl_change.php          view_operations.php

Documentation.txt         print.css              tbl_chart.php           webapp.php

enum_editor.php           querywindow.php        tbl_create.php

examples                  README                 tbl_export.php

export.php                README.VENDOR          tbl_get_field.php

[root@localhost pma]#


[root@localhost pma]# cp config.sample.inc.php config.inc.php

[root@localhost pma]#


[root@localhost pma]# vim config.inc.php

<?php

/* vim: set expandtab sw=4 ts=4 sts=4: */

/**

 * phpMyAdmin sample configuration, you can use it as base for

 * manual configuration. For easier setup you can use setup/

 *

 * All directives are explained in Documentation.html and on phpMyAdmin

 * wiki <http://wiki.phpmyadmin.net>.

 *

 * @package PhpMyAdmin

 */


/*

 * This is needed for cookie based authentication to encrypt password in

 * cookie

 */

//$cfg['blowfish_secret'] = 'a8b7c6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

$cfg['blowfish_secret'] = 'VNlmq5O2X4rqEw';    //这个随机数的生成见下面

 //blowfish 加密的密钥(随机码),可以自己生成随机数写在这里

/*

 * Servers configuration

 */

$i = 0;


/*

 * First server

 */

$i++;

/* Authentication type */

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

/* Server parameters */

$cfg['Servers'][$i]['host'] = 'localhost';

$cfg['Servers'][$i]['connect_type'] = 'tcp';

$cfg['Servers'][$i]['compress'] = false;    //不要压缩

/* Select mysql if your server does not have mysqli */

$cfg['Servers'][$i]['extension'] = 'mysqli';

$cfg['Servers'][$i]['AllowNoPassword'] = false;//允许没有密码

............................



打开另一窗口,生成随机数            (16进制的10位数 下面这个命令不行)

[root@localhost ~]# openssl rand -hex 10    

Usage: rand [options] num

where options are

-out file             - write to file

-engine e             - use engine e, possibly a hardware device.

-rand file:file:... - seed PRNG from files

-base64               - encode output

[root@localhost ~]#

[root@localhost ~]# openssl rand

Usage: rand [options] num

where options are

-out file             - write to file

-engine e             - use engine e, possibly a hardware device.

-rand file:file:... - seed PRNG from files

-base64               - encode output

[root@localhost ~]#


[root@localhost ~]# whatis rand

rand                 (3)  - pseudo-random number generator

rand                 (3p)  - pseudo-random number generator

rand [sslrand]       (1ssl)  - generate pseudo-random bytes

rand [sslrand]       (3ssl)  - pseudo-random number generator

[root@localhost ~]#


[root@localhost ~]# man sslrand

RAND(1)                             OpenSSL                            RAND(1)


NAME

       rand - generate pseudo-random bytes


SYNOPSIS

       openssl rand [-out file] [-rand file(s)] [-base64]            #不支持hex吗?

       num


DESCRIPTION

       The rand command outputs num pseudo-random bytes

       after seeding the random number generator once.  As

       in other openssl command line tools, PRNG seeding

       uses the file $HOME/.rnd or .rnd in addition to the

       files given in the -rand option.  A new $HOME/.rnd

       or .rnd file will be written back if enough seeding

       was obtained from these sources.


OPTIONS

       -out file

           Write to file instead of standard output.

:



[root@localhost ~]# openssl rand -base64 10   (这里生成的放在上面)

VNlmq5O2X4rqEw==

[root@localhost ~]#



http://www.b.net/pma/

image.png



image.png




[root@localhost pma]# mysqladmin -uroot password '123456'

mysqladmin: connect to server at 'localhost' failed

error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'

Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

[root@localhost pma]# service mysqld start

Starting MySQL..                                           [确定]

[root@localhost pma]# mysqladmin -uroot password '123456'

[root@localhost pma]#

[root@localhost pma]# mysqladmin -uroot -p flush-privileges        (# 这个不执行其实也可以,因为 123456是有效的 )

Enter password:

[root@localhost pma]#



此时输用户名密码可以登录

image.png

image.png

image.png





[root@localhost pma]# /usr/local/apache/bin/ab -c 100 -n 1000 http                                                    ://www.b.net/pma/index.php      # index.php未涉及到查询数据库,否则会更慢

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

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

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


Benchmarking www.b.net (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Completed 600 requests

Completed 700 requests

Completed 800 requests

Completed 900 requests

Completed 1000 requests

Finished 1000 requests



Server Software:        Apache/2.4.4

Server Hostname:        www.b.net

Server Port:            80


Document Path:          /pma/index.php

Document Length:        7038 bytes


Concurrency Level:      100

Time taken for tests:   5.334 seconds

Complete requests:      1000

Failed requests:        0

Write errors:           0

Total transferred:      7845606 bytes

HTML transferred:       7038000 bytes

Requests per second:    187.47 [#/sec] (mean)    #看这个值  

Time per request:       533.409 [ms] (mean)  #看这个值

Time per request:       5.334 [ms] (mean, across all concurrent requests)   #看这个值

Transfer rate:          1436.37 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    4  13.8      0     112

Processing:     4  521 692.1    248    4807

Waiting:        4  521 692.1    247    4807

Total:          4  526 696.6    248    4847


Percentage of the requests served within a certain time (ms)

  50%    248

  66%    458

  75%    761

  80%    964

  90%   1346

  95%   1901

  98%   2840

  99%   3301

 100%   4847 (longest request)

[root@localhost pma]#

测的时候 打开正常的网页看看 能不能打开

http://www.b.net/pma/index.php    

马哥这边打不开了

image.png


Xcache 能至少加速30%


马哥的 cpu 太忙了

image.png






压力测试工具

ab        apache服务器自带的常用的工具  差不多挺好用的

http_load    专门的第三方工具,网上搜 一个进程模拟并发测试?    下载编译安装,编译过程很简单

webbench        多个进程模拟并发测试? 有时模拟太多的话对本客户机也有压力?

siege


image.png

image.png



怎么能够实现编译安装的apache 启用 https的功能 

[root@localhost ~]# vim /etc/httpd/httpd.conf

.............................................

LoadModule ssl_module modules/mod_ssl.so   #启用 https 的ssl 模块

.............................................

Include /etc/httpd/extra/httpd-ssl.conf            #配置文件启用起来

.............................................



[root@localhost ~]# vim /etc/httpd/extra/httpd-ssl.conf

# 涉及到端口  加密算法  PassPhraseDialog 

#

# This is the Apache server configuration file providing SSL support.

# It contains the configuration directives to instruct the server how to

# serve pages over an https connection. For detailed information about these

# directives see <URL:http://httpd.apache.org/docs/2.4/mod/mod_ssl.html>

#

# Do NOT simply read the instructions in here without understanding

# what they do.  They're here only as hints or reminders.  If you are unsure

# consult the online docs. You have been warned.

#

# Required modules: mod_log_config, mod_setenvif, mod_ssl,

#          socache_shmcb_module (for default value of SSLSessionCache)


#

# Pseudo Random Number Generator (PRNG):

# Configure one or more sources to seed the PRNG of the SSL library.

# The seed data should be of good random quality.

# WARNING! On some platforms /dev/random blocks if not enough entropy

# is available. This means you then cannot use the /dev/random device

# because it would lead to very long connection times (as long as

# it requires to make more entropy available). But usually those

# platforms additionally provide a /dev/urandom device which doesn't

# block. So, if available, use this one instead. Read the mod_ssl User

# Manual for more details.

#

#SSLRandomSeed startup file:/dev/random  512

#SSLRandomSeed startup file:/dev/urandom 512

#SSLRandomSeed connect file:/dev/random  512

#SSLRandomSeed connect file:/dev/urandom 512


#SSLRandomSeed connect file:/dev/urandom 512



#

# When we also provide SSL we have to listen to the

# standard HTTP port (see above) and to the HTTPS port

#

# Note: Configurations that use IPv6 but not IPv4-mapped addresses need two

#       Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443"

#

Listen 443


##

##  SSL Global Context

##

##  All SSL configuration in this context applies both to

##  the main server and all SSL-enabled virtual hosts.

##


#   SSL Cipher Suite:

#   List the ciphers that the client is permitted to negotiate.

#   See the mod_ssl documentation for a complete list.

SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5


#   Speed-optimized SSL Cipher configuration:

#   If speed is your main concern (on busy HTTPS servers e.g.),

#   you might want to force clients to specific, performance

#   optimized ciphers. In this case, prepend those ciphers

#   to the SSLCipherSuite list, and enable SSLHonorCipherOrder.

#   Caveat: by giving precedence to RC4-SHA and AES128-SHA

#   (as in the example below), most connections will no longer

#   have perfect forward secrecy - if the server's key is

#   compromised, captures of past or future traffic must be

#   considered compromised, too.

#SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:MEDIUM:!aNULL:!MD5

#SSLHonorCipherOrder on


#   Pass Phrase Dialog:

#   Configure the pass phrase gathering process.

#   The filtering dialog program (`builtin' is an internal

#   terminal dialog) has to provide the pass phrase on stdout.

SSLPassPhraseDialog  builtin


#   Inter-Process Session Cache:

#   Configure the SSL Session Cache: First the mechanism

#   to use and second the expiring timeout (in seconds).

#SSLSessionCache         "dbm:/usr/local/apache/logs/ssl_scache"

SSLSessionCache        "shmcb:/usr/local/apache/logs/ssl_scache(512000)"

SSLSessionCacheTimeout  300


##

## SSL Virtual Host Context

##


<VirtualHost _default_:443>


#   General setup for the virtual host

#DocumentRoot "/usr/local/apache/htdocs"

DocumentRoot "/www/a.org"

#ServerName www.example.com:443

ServerName www.a.org

ServerAdmin you@example.com

ErrorLog "/usr/local/apache/logs/error_log"

TransferLog "/usr/local/apache/logs/access_log"


#   SSL Engine Switch:

#   Enable/Disable SSL for this virtual host.

SSLEngine on


#   Server Certificate:

#   Point SSLCertificateFile at a PEM encoded certificate.  If

#   the certificate is encrypted, then you will be prompted for a

#   pass phrase.  Note that a kill -HUP will prompt again.  Keep

#   in mind that if you have both an RSA and a DSA certificate you

#   can configure both in parallel (to also allow the use of DSA

#   ciphers, etc.)

#   Some ECC cipher suites (http://www.ietf.org/rfc/rfc4492.txt)

#   require an ECC certificate which can also be configured in

#   parallel.

#很显然 openssl 要建立一个CA ,CA要自签证书,客户端发起请求 

#利用私匙生成证书签署请求,从私匙中提取公钥

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"


#   Server Certificate Chain:

#   Point SSLCertificateChainFile at a file containing the

#   concatenation of PEM encoded CA certificates which form the

#   certificate chain for the server certificate. Alternatively

#   the referenced file can be the same as SSLCertificateFile

#   when the CA certificates are directly appended to the server

#   certificate for convenience.

#SSLCertificateChainFile "/etc/httpd/server-ca.crt"


#   Certificate Authority (CA):

#   Set the CA certificate verification path where to find CA

#   certificates for client authentication or alternatively one

#   huge file containing all of them (file must be PEM encoded)

#   Note: Inside SSLCACertificatePath you need hash symlinks

#         to point to the certificate files. Use the provided

#         Makefile to update the hash symlinks after changes.

#SSLCACertificatePath "/etc/httpd/ssl.crt"

#SSLCACertificateFile "/etc/httpd/ssl.crt/ca-bundle.crt"


#   Certificate Revocation Lists (CRL):

#   Set the CA revocation path where to find CA CRLs for client

#   authentication or alternatively one huge file containing all

#   of them (file must be PEM encoded).

#   The CRL checking mode needs to be configured explicitly

#   through SSLCARevocationCheck (defaults to "none" otherwise).

#   Note: Inside SSLCARevocationPath you need hash symlinks

#         to point to the certificate files. Use the provided

#         Makefile to update the hash symlinks after changes.

#SSLCARevocationPath "/etc/httpd/ssl.crl"

#SSLCARevocationFile "/etc/httpd/ssl.crl/ca-bundle.crl"

#SSLCARevocationCheck chain


#   Client Authentication (Type):

#   Client certificate verification type and depth.  Types are

#   none, optional, require and optional_no_ca.  Depth is a

#   number which specifies how deeply to verify the certificate

#   issuer chain before deciding the certificate is not valid.

#SSLVerifyClient require

#SSLVerifyDepth  10


#   TLS-SRP mutual authentication:

#   Enable TLS-SRP and set the path to the OpenSSL SRP verifier

#   file (containing login information for SRP user accounts).

#   Requires OpenSSL 1.0.1 or newer. See the mod_ssl FAQ for

#   detailed instructions on creating this file. Example:

#   "openssl srp -srpvfile /etc/httpd/passwd.srpv -add username"

#SSLSRPVerifierFile "/etc/httpd/passwd.srpv"




#   Access Control:

#   With SSLRequire you can do per-directory access control based

#   on arbitrary complex boolean expressions containing server

#   variable checks and other lookup directives.  The syntax is a

#   mixture between C and Perl.  See the mod_ssl documentation

#   for more details.

#<Location />

#SSLRequire (    %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \

#            and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \

#            and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \

#            and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \

#            and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20       ) \

#           or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/

#</Location>





#   SSL Engine Options:

#   Set various options for the SSL engine.

#   o FakeBasicAuth:

#     Translate the client X.509 into a Basic Authorisation.  This means that

#     the standard Auth/DBMAuth methods can be used for access control.  The

#     user name is the `one line' version of the client's X.509 certificate.

#     Note that no password is obtained from the user. Every entry in the user

#     file needs this password: `xxj31ZMTZzkVA'.

#   o ExportCertData:

#     This exports two additional environment variables: SSL_CLIENT_CERT and

#     SSL_SERVER_CERT. These contain the PEM-encoded certificates of the

#     server (always existing) and the client (only existing when client

#     authentication is used). This can be used to import the certificates

#     into CGI scripts.

#   o StdEnvVars:

#     This exports the standard SSL/TLS related `SSL_*' environment variables.

#     Per default this exportation is switched off for performance reasons,

#     because the extraction step is an expensive operation and is usually

#     useless for serving static content. So one usually enables the

#     exportation for CGI and SSI requests only.

#   o StrictRequire:

#     This denies access when "SSLRequireSSL" or "SSLRequire" applied even

#     under a "Satisfy any" situation, i.e. when it applies access is denied

#     and no other module can change it.

#   o OptRenegotiate:

#     This enables optimized SSL connection renegotiation handling when SSL

#     directives are used in per-directory context.

#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire

<FilesMatch "\.(cgi|shtml|phtml|php)$">

    SSLOptions +StdEnvVars

</FilesMatch>

<Directory "/usr/local/apache/cgi-bin">

    SSLOptions +StdEnvVars

</Directory>


#   SSL Protocol Adjustments:

#   The safe and default but still SSL/TLS standard compliant shutdown

#   approach is that mod_ssl sends the close notify alert but doesn't wait for

#   the close notify alert from client. When you need a different shutdown

#   approach you can use one of the following variables:

#   o ssl-unclean-shutdown:

#     This forces an unclean shutdown when the connection is closed, i.e. no

#     SSL close notify alert is sent or allowed to be received.  This violates

#     the SSL/TLS standard but is needed for some brain-dead browsers. Use

#     this when you receive I/O errors because of the standard approach where

#     mod_ssl sends the close notify alert.

#   o ssl-accurate-shutdown:

#     This forces an accurate shutdown when the connection is closed, i.e. a

#     SSL close notify alert is send and mod_ssl waits for the close notify

#     alert of the client. This is 100% SSL/TLS standard compliant, but in

#     practice often causes hanging connections with brain-dead browsers. Use

#     this only for browsers where you know that their SSL implementation

#     works correctly.

#   Notice: Most problems of broken clients are also related to the HTTP

#   keep-alive facility, so you usually additionally want to disable

#   keep-alive for those clients, too. Use variable "nokeepalive" for this.

#   Similarly, one has to force some clients to use HTTP/1.0 to workaround

#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and

#   "force-response-1.0" for this.


BrowserMatch "MSIE [2-5]" \

         nokeepalive ssl-unclean-shutdown \

         downgrade-1.0 force-response-1.0


#   Per-Server Logging:

#   The home of a custom SSL log file. Use this when you want a

#   compact non-error SSL logfile on a virtual host basis.

CustomLog "/usr/local/apache/logs/ssl_request_log" \

          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"


</VirtualHost>



马哥说 SSL一个IP只能建立一个主机,因为SSL会话是基于IP地址来实现的?但是现在己经可以多个了

弄好了 httpd-ssl.conf后,重启web服务器即可


[root@localhost extra]# cd /etc/httpd/extra/

[root@localhost extra]# pwd

/etc/httpd/extra

[root@localhost extra]# ls

httpd-autoindex.conf  httpd-languages.conf           httpd-ssl.conf

httpd-dav.conf        httpd-manual.conf              httpd-userdir.conf

httpd-default.conf    httpd-mpm.conf                 httpd-vhosts.conf

httpd-info.conf       httpd-multilang-errordoc.conf  proxy-html.conf

[root@localhost extra]#




[root@localhost extra]# vim httpd-mpm.conf

#定义每一种不同的mpm的工作参数的

#默认情况下 rpm安装时在主配置文件 httpd.conf中提供的





# prefork MPM

# StartServers: number of server processes to start

# MinSpareServers: minimum number of server processes which are kept spare

# MaxSpareServers: maximum number of server processes which are kept spare

# MaxRequestWorkers: maximum number of server processes allowed to start

# MaxConnectionsPerChild: maximum number of connections a server process serves

#                         before terminating

<IfModule mpm_prefork_module>

    StartServers             5

    MinSpareServers          5

    MaxSpareServers         10

    MaxRequestWorkers      250

    MaxConnectionsPerChild   0

</IfModule>


# worker MPM

# StartServers: initial number of server processes to start

# MinSpareThreads: minimum number of worker threads which are kept spare

# MaxSpareThreads: maximum number of worker threads which are kept spare

# ThreadsPerChild: constant number of worker threads in each server process

# MaxRequestWorkers: maximum number of worker threads

# MaxConnectionsPerChild: maximum number of connections a server process serves

#                         before terminating

<IfModule mpm_worker_module>

    StartServers             3

    MinSpareThreads         75

    MaxSpareThreads        250

    ThreadsPerChild         25

    MaxRequestWorkers      400

    MaxConnectionsPerChild   0

</IfModule>


# event MPM

# StartServers: initial number of server processes to start

# MinSpareThreads: minimum number of worker threads which are kept spare

# MaxSpareThreads: maximum number of worker threads which are kept spare

# ThreadsPerChild: constant number of worker threads in each server process

# MaxRequestWorkers: maximum number of worker threads

# MaxConnectionsPerChild: maximum number of connections a server process serves

#                         before terminating

<IfModule mpm_event_module>

    StartServers             3

    MinSpareThreads         75

    MaxSpareThreads        250

    ThreadsPerChild         25

    MaxRequestWorkers      400

    MaxConnectionsPerChild   0

</IfModule>


# NetWare MPM

# ThreadStackSize: Stack size allocated for each worker thread

# StartThreads: Number of worker threads launched at server startup

# MinSpareThreads: Minimum number of idle threads, to handle request spikes

# MaxSpareThreads: Maximum number of idle threads

# MaxThreads: Maximum number of worker threads alive at the same time

# MaxConnectionsPerChild: Maximum  number of connections a thread serves. It

#                         is recommended that the default value of 0 be set

#                         for this directive on NetWare.  This will allow the

#                         thread to continue to service requests indefinitely.

<IfModule mpm_netware_module>

    ThreadStackSize      65536

    StartThreads           250

    MinSpareThreads         25

    MaxSpareThreads        250

    MaxThreads            1000

    MaxConnectionsPerChild   0

</IfModule>



改里面的值  观察 

top 命令下的cpu  

vmstat 命令


[root@localhost extra]# vmstat 1

# cs 上下文切换的次数

# bi bo si so 看看 开启日志的时候,bi bo 变化量大

#  bi bo : io 上从磁盘载入的个数和 写入到磁盘上的个数

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------

 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

 0  0     12 574432  10344 174436    0    0     4     2   30  130  0  0 100  0  0

 0  0     12 574432  10352 174428    0    0     0    36  915  235  0  0 100  0  0

 0  0     12 574432  10352 174436    0    0     0     0  851  222  0  1 99  0  0

 0  0     12 574432  10352 174436    0    0     0     0  883  265  0  1 99  0  0




[root@localhost ~]# /usr/local/apache/bin/ab -c 1000 -n 10000 http://www.a.org/t                                      est.html

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

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

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


Benchmarking www.a.org (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests



Server Software:        Apache/2.4.4

Server Hostname:        www.a.org

Server Port:            80


Document Path:          /test.html

Document Length:        147168 bytes


Concurrency Level:      1000

Time taken for tests:   3.086 seconds

Complete requests:      10000

Failed requests:        0

Write errors:           0

Total transferred:      1474290000 bytes

HTML transferred:       1471680000 bytes

Requests per second:    3240.43 [#/sec] (mean)

Time per request:       308.601 [ms] (mean)

Time per request:       0.309 [ms] (mean, across all concurrent requests)

Transfer rate:          466536.96 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0    9  11.7      5      66

Processing:    16  167 141.1    160    3020

Waiting:        1   41 134.2     13    3020

Total:         20  176 149.1    167    3086


Percentage of the requests served within a certain time (ms)

  50%    167

  66%    172

  75%    174

  80%    178

  90%    198

  95%    366

  98%    798

  99%    832

 100%   3086 (longest request)

[root@localhost ~]#


另一窗口中看看  # vmstat 1


[root@localhost extra]# vmstat 1


image.png

image.png


马哥的图

image.png

普通分类: