源码编译lnmp架构 | 编译php-fpm | Discuz!论坛 | memcache缓存机制 openstry缓存
mysql
编译mysql
cmake-2.8.12.2-4.el6.x86_64.rpm mysql-boost-5.7.17.tar.gz
[[email protected] ~]# tar zxf mysql-boost-5.7.17.tar.gz
[[email protected] ~]# cd mysql-5.7.17/ 这个必须用cmake,不能用./configure
[[email protected] mysql-5.7.17]# yum list cmake
Loaded plugins: product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel-source | 3.9 kB 00:00
rhel-source/primary_db | 3.1 MB 00:00
Available Packages
cmake.x86_64 2.6.4-5.el6
rhel6自带的版本太低,至少2.8以上,rhel7自带的可以
1,安装cmake
[[email protected] ~]# rpm -ivh cmake-2.8.12.2-4.el6.x86_64.rpm
warning: cmake-2.8.12.2-4.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
libarchive.so.2()(64bit) is needed by cmake-2.8.12.2-4.el6.x86_64
有依赖性直接用yum安装cmake-2.8.12.2-4.el6.x86_64.rpm
2,开始cmake
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ 这个指定的目录不用自己建立
#安装目录
-DMYSQL_DATADIR=/usr/local/mysql/data \
#数据库存放目录
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \ #Unix socket 文件路径
-DWITH_MYISAM_STORAGE_ENGINE=1 \
#安装 myisam 存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ 引擎根据需要加,没必要都添加
#安装 innodb 存储引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
#安装 archive 存储引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
#安装 blackhole 存储引擎
-DWITH_PARTITION_STORAGE_ENGINE=1 \
#安装数据库分区
-DENABLED_LOCAL_INFILE=1 \
#允许从本地导入数据
-DWITH_READLINE=1 \
#快捷键功能
-DWITH_SSL=yes \
#支持 SSL
-DDEFAULT_CHARSET=utf8 \
#使用 utf8 字符
-DDEFAULT_COLLATION=utf8_general_ci \
#校验字符
-DEXTRA_CHARSETS=all \
#安装所有扩展字符集
-DMYSQL_TCP_PORT=3306 \
#MySQL 监听端口
!!!这些附加信息不是全加,根据需要修改
重新cmake时需要清除缓存信息
rm -f CmakeCache.txt #cmake时会先读取缓存信息,可能会和我们重新编译附加的信息冲突
(在安装了vim的系统中如果用vi打开还是打开的vim,需要加\vi \表示转义,在vi中编辑然后贴过来不会有特殊字符的存在干扰编译,如果在编译过程中,出现某一个附加条件报错,但是语法逻辑有问题,那就删除该附加条件,然后再手动敲上去,不要复制粘贴)
yum install -y gcc gcc-c++
[[email protected] mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/ tab补出
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:64 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
[[email protected] mysql-5.7.17]# rm -rf CMakeCache.txt
[[email protected] mysql-5.7.17]# yum install -y ncurses-devel
[[email protected] mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0/
-- Googletest was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source. 这个不用管
-- If you are inside a firewall, you may need to use an https proxy: export https_proxy=http://example.com:80
-- Performing Test HAVE_UNUSED_TYPEDEFS
-- Performing Test HAVE_UNUSED_TYPEDEFS - Failed
-- Performing Test HAVE_MISLEADING_INDENTATION
-- Performing Test HAVE_MISLEADING_INDENTATION - Failed
CMake Warning at cmake/bison.cmake:20 (MESSAGE):
Bison executable not found in PATH
Call Stack (most recent call first):
sql/CMakeLists.txt:549 (INCLUDE)
CMake Warning at cmake/bison.cmake:20 (MESSAGE):
Bison executable not found in PATH
Call Stack (most recent call first):
libmysqld/CMakeLists.txt:187 (INCLUDE)
waring可以跳过,也可以安装bison
[[email protected] mysql-5.7.17]# yum install -y bison
[[email protected] mysql-5.7.17]# rm -rf CMakeCache.txt
[[email protected] mysql-5.7.17]# cmake
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.7.17
cmake成功!!!!!!
3,make
4,make install
编译安装成功
rpm -qa | grep mysql可以删除mysql,mysql-server,但是mysql-libs不能删除
配置/etc/my.cnf
[[email protected] ~]# cd /usr/local/lnmp/mysql/
[[email protected] mysql]# ls
bin COPYING docs include lib man mysql-test README share support-files
[[email protected] mysql]# ll /etc/my.cnf
-rw-r--r--. 1 root root 251 Aug 9 2013 /etc/my.cnf
[[email protected] support-files]# ls
magic my-default.cnf mysqld_multi.server mysql-log-rotate mysql.server
[[email protected] support-files]# cp my-default.cnf /etc/my.cnf 覆盖掉
cp: overwrite `/etc/my.cnf'? y
[[email protected] support-files]# vim /etc/my.cnf
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = /usr/local/lnmp/mysql 主要是去掉这4个注释
datadir = /usr/local/lnmp/mysql/data
port = 3306
# server_id = .....
socket = /usr/local/lnmp/mysql/data/mysql.sock cmake编译时附加信息之一
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
建立mysql的启动脚本
[[email protected] support-files]# file mysql.server 这是启动脚本
mysql.server: POSIX shell script text executable
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
[[email protected] support-files]# ll /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10916 Aug 5 10:50 /etc/init.d/mysqld
创建用户
[[email protected] mysql]# ll
total 56
drwxr-xr-x 2 root root 4096 Aug 5 10:19 bin
-rw-r--r-- 1 root root 17987 Nov 28 2016 COPYING
drwxr-xr-x 2 root root 4096 Aug 5 10:19 docs
drwxr-xr-x 3 root root 4096 Aug 5 10:19 include
drwxr-xr-x 4 root root 4096 Aug 5 10:19 lib
drwxr-xr-x 4 root root 4096 Aug 5 10:19 man
drwxr-xr-x 10 root root 4096 Aug 5 10:20 mysql-test
-rw-r--r-- 1 root root 2478 Nov 28 2016 README
drwxr-xr-x 28 root root 4096 Aug 5 10:20 share
drwxr-xr-x 2 root root 4096 Aug 5 10:20 support-files
[[email protected] mysql]# id mysql
id: mysql: No such user
[[email protected] mysql]# groupadd -g 27 mysql 真机mysql的用户id是27
[[email protected] mysql]# useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/data -s /sbin/nologin mysql 不创建家目录,指定用户家目录禁止登录
修改mysql目录用户权限
[[email protected] mysql]# chown -R mysql.mysql .
[[email protected] mysql]# ll
total 56
drwxr-xr-x 2 mysql mysql 4096 Aug 5 10:19 bin
-rw-r--r-- 1 mysql mysql 17987 Nov 28 2016 COPYING
drwxr-xr-x 2 mysql mysql 4096 Aug 5 10:19 docs
drwxr-xr-x 3 mysql mysql 4096 Aug 5 10:19 include
drwxr-xr-x 4 mysql mysql 4096 Aug 5 10:19 lib
drwxr-xr-x 4 mysql mysql 4096 Aug 5 10:19 man
drwxr-xr-x 10 mysql mysql 4096 Aug 5 10:20 mysql-test
-rw-r--r-- 1 mysql mysql 2478 Nov 28 2016 README
drwxr-xr-x 28 mysql mysql 4096 Aug 5 10:20 share
drwxr-xr-x 2 mysql mysql 4096 Aug 5 10:20 support-files
[[email protected] mysql]# cd bin/ 命令目录,含初始化命令等
[[email protected] bin]# pwd
/usr/local/lnmp/mysql/bin
[[email protected] ~]# ls -a
. .bashrc mysql-5.7.17
.. cmake-2.8.12.2-4.el6.x86_64.rpm mysql-boost-5.7.17.tar.gz
.bash_logout .cshrc .tcshrc
.bash_profile .lftp .viminfo
[[email protected] ~]# vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin
添加这个的主要目的是不管在哪个路径都可以执行/usr/local/lnmp/mysql/bin这里面的可执行文件
export PATH
[[email protected] ~]# source .bash_profile
初始化用户
[[email protected] ~]# mysql_install_db
2018-08-05 10:55:10 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2018-08-05 10:55:10 [ERROR] The data directory needs to be specified.
[[email protected] mysql]# mysqld --initialize --user=mysql
2018-08-05T03:08:05.095648Z 1 [Note] A temporary password is generated for [email protected]: hu#_+&7qk,gZ
[[email protected] mysql]# chkconfig --list mysqld 检查开机是否自动启动
service mysqld supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add mysqld')
[[email protected] mysql]# ll
total 60
drwxr-xr-x 2 mysql mysql 4096 Aug 5 10:54 bin
-rw-r--r-- 1 mysql mysql 17987 Nov 28 2016 COPYING
drwxr-x--- 5 mysql mysql 4096 Aug 5 11:08 data
drwxr-xr-x 2 mysql mysql 4096 Aug 5 10:19 docs
drwxr-xr-x 3 mysql mysql 4096 Aug 5 10:19 include
drwxr-xr-x 4 mysql mysql 4096 Aug 5 10:19 lib
drwxr-xr-x 4 mysql mysql 4096 Aug 5 10:19 man
drwxr-xr-x 10 mysql mysql 4096 Aug 5 10:20 mysql-test
-rw-r--r-- 1 mysql mysql 2478 Nov 28 2016 README
drwxr-xr-x 28 mysql mysql 4096 Aug 5 10:20 share
drwxr-xr-x 2 mysql mysql 4096 Aug 5 10:20 support-files
[[email protected] mysql]# chown root.root . -R
[[email protected] mysql]# chown mysql data/ -R data是mysql服务写的目录,只要这个目录的组是mysql就够了
[[email protected] mysql]# ll
total 60
drwxr-xr-x 2 root root 4096 Aug 5 10:54 bin
-rw-r--r-- 1 root root 17987 Nov 28 2016 COPYING
drwxr-x--- 5 mysql root 4096 Aug 5 11:08 data
drwxr-xr-x 2 root root 4096 Aug 5 10:19 docs
drwxr-xr-x 3 root root 4096 Aug 5 10:19 include
drwxr-xr-x 4 root root 4096 Aug 5 10:19 lib
drwxr-xr-x 4 root root 4096 Aug 5 10:19 man
drwxr-xr-x 10 root root 4096 Aug 5 10:20 mysql-test
-rw-r--r-- 1 root root 2478 Nov 28 2016 README
drwxr-xr-x 28 root root 4096 Aug 5 10:20 share
drwxr-xr-x 2 root root 4096 Aug 5 10:20 support-files
数据库启动测试
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[[email protected] mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
安全初始化
一定要先启动mysql
[[email protected] mysql]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: hu#_+&7qk,gZ
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: n 是否安装插件,这个插件会严格检查密码的强弱度,实验条件没必要配置
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) :
... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) :
... skipping.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
... skipping.
All done!
登录测试
[[email protected] mysql]# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
php
编译
tat jxf php-5.6.35.tar.bz2
cd php-5.6.35
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash 这个会出现在phpinfo()页面
yum install -y libxml2-devel
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
yum install -y openssl-devel
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
yum install -y curl-devel
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
yum list gd
注意要和系统自带的的版本一致,否则不兼容
yum install -y gd-devel-2.0.35-11.el6.x86_64.rpm 解决各种图片格式的依赖
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
yum install -y gmp-devel
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
yum install -y libmcrypt-2.5.8-9.el6.x86_64.rpm 安装这个需要devel版的依赖libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
yum install -y net-snmp-devel
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
这个警告可以不容易找到configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
rpm -ivh re2c-0.13.5-1.el6.x86_64.rpm
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp -enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
make && make install
编译安装成功!!!
配置php
[[email protected] php-5.6.35]# cd /usr/local/lnmp/php/
[[email protected] php]# cd etc/
[[email protected] etc]# ls
pear.conf php-fpm.conf.default
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default
[[email protected] ~]# cd php-5.6.35
[[email protected] php-5.6.35]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini
[[email protected] ~]# cd /usr/local/lnmp/php/etc
[[email protected] etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default php.ini
[[email protected] etc]# vim php.ini
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shanghai 配置时区
[[email protected] etc]# vim php-fpm.conf
[global]
; Pid file
; Note: the default prefix is /usr/local/lnmp/php/var
; Default Value: none
pid = run/php-fpm.pid 去掉注释
实现php和nginx的联动
[[email protected] etc]# id nginx
id: nginx: No such user
[[email protected] etc]# useradd -M -d /usr/local/lnmp/nginx -s /sbin/nologin nginx
[[email protected] php-5.6.35]# cd sapi/
[[email protected] sapi]# ls
aolserver apache_hooks continuity litespeed phttpd thttpd
apache caudium embed milter pi3web tux
apache2filter cgi fpm nsapi roxen webjames
apache2handler cli isapi phpdbg tests
[[email protected] sapi]# cd fpm/
[[email protected] fpm]# ls
config.m4 LICENSE php-fpm.conf status.html.in
CREDITS Makefile.frag php-fpm.conf.in tests
fpm php-fpm php-fpm.service www.conf.in
init.d.php-fpm php-fpm.8 php-fpm.service.in
init.d.php-fpm.in php-fpm.8.in status.html
[[email protected] fpm]# file init.d.php-fpm
init.d.php-fpm: POSIX shell script text executable
建立php-fpm脚本文件
[[email protected] fpm]# cp init.d.php-fpm /etc/init.d/php-fpm php-fpm是启动脚本
[[email protected] fpm]# chmod +x /etc/init.d/php-fpm
[[email protected] fpm]# /etc/init.d/php-fpm start
Starting php-fpm done
[[email protected] fpm]# ps ax
8263 ? Ss 0:00 php-fpm: master process (/usr/local/lnmp/php/etc/php-fpm.conf)
8264 ? S 0:00 php-fpm: pool www
8265 ? S 0:00 php-fpm: pool www 可以看到三个进程
[[email protected] fpm]# netstat -antuple
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 8443 950/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 0 8658 1026/master
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 0 253274 8263/php-fpm
tcp 0 0 172.25.28.5:22 172.25.28.250:43870 ESTABLISHED 0 8927 1076/sshd
tcp 0 0 :::22 :::* LISTEN 0 8445 950/sshd
tcp 0 0 ::1:25 :::* LISTEN 0 8660 1026/master
tcp 0 0 :::3306 :::* LISTEN 27 118371 29453/mysqld
nignx
编译nginx
[[email protected] ~]# tar zxf nginx-1.10.1.tar.gz
[[email protected] ~]# cd nginx-1.10.1
[[email protected] nginx-1.10.1]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[[email protected] nginx-1.10.1]# vim src/core/nginx.h 去掉版本号
[[email protected] nginx-1.10.1]# vim auto/cc/gcc 去掉debug检查
[[email protected] nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx --with-file-aio --with-threads
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
[[email protected] nginx-1.10.1]# yum install -y pcre-devel
[[email protected] nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx --with-file-aio --with-threads
[[email protected] nginx-1.10.1]# make && make install
编译安装成功!!!
配置nginx
[[email protected] nginx-1.10.1]# cd /usr/local/lnmp/
[[email protected] lnmp]# ls
mysql nginx php
[[email protected] lnmp]# cd nginx/
[[email protected] nginx]# cd conf/
[[email protected] conf]# ls
fastcgi.conf koi-utf nginx.conf uwsgi_params
fastcgi.conf.default koi-win nginx.conf.default uwsgi_params.default
fastcgi_params mime.types scgi_params win-utf
fastcgi_params.default mime.types.default scgi_params.default
[[email protected] conf]# vim nginx.conf
events {
worker_connections 65535;
}
[[email protected] conf]# vim /etc/security/limits.conf
# End of file
nginx - nofile 65536
[[email protected] conf]# sysctl -a | grep file
fs.file-nr = 512 0 291236
fs.file-max = 291236
[[email protected] conf]# vim nginx.conf
打开php的配置
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
fastcgi.conf这个文件第一行包含了fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
}
# deny access to .htaccess files, if Apache's document root
建立nginx启动脚本,这里可以自己写,也可以使用生成的二进制文件
[[email protected] nginx]# cd sbin/
[[email protected] sbin]# ls
nginx
[[email protected] sbin]# pwd
/usr/local/lnmp/nginx/sbin
[[email protected] sbin]# cd
[[email protected] ~]# vim .bash_profile
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/nginx/sbin
[[email protected] ~]# source .bash_profile
测试nginx
[[email protected] ~]# nginx
[[email protected] ~]# nginx -t
nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful
建立nginx发布页面index.php
[[email protected] ~]# cd /usr/local/lnmp/nginx/
[[email protected] nginx]# ls
client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp
[[email protected] nginx]# cd html/
[[email protected] html]# ls
50x.html index.html
[[email protected] html]# vim index.php
<?php
phpinfo()
?>
这里地址栏需要输入index.php Configure Command 就是我们php ./configure内容
使index.php成为默认发布页面
[[email protected] html]# cd ..
[[email protected] nginx]# ls
client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp
[[email protected] nginx]# cd conf/
[[email protected] conf]# ls
fastcgi.conf koi-utf nginx.conf uwsgi_params
fastcgi.conf.default koi-win nginx.conf.default uwsgi_params.default
fastcgi_params mime.types scgi_params win-utf
fastcgi_params.default mime.types.default scgi_params.default
[[email protected] conf]# vim nginx.conf
#access_log logs/host.access.log main;
location / {
root html;
index index.php index.html index.htm; 配置为先找index.php
}
#error_page 404 /404.html;
apache既有index.php又有index.html那么先找index.php,无须配置,nginx不同
直接访问ip
Discuz!
yum install -y unzip
unzip Discuz_X3.2_SC_UTF8.zip -d /usr/local/lnmp/nginx/html/
[[email protected] ~]# cd /usr/local/lnmp/
[[email protected] lnmp]# ls
mysql nginx php
[[email protected] lnmp]# cd nginx/
[[email protected] nginx]# ls
client_body_temp html sbin
conf logs scgi_temp
fastcgi_temp proxy_temp uwsgi_temp
[[email protected] nginx]# cd html/
[[email protected] html]# ls
50x.html index.html index.php readme upload utility
[[email protected] html]# cd upload/
[[email protected] upload]# ls
admin.php crossdomain.xml install source
api data member.php static
api.php favicon.ico misc.php template
archiver forum.php plugin.php uc_client
config group.php portal.php uc_server
connect.php home.php robots.txt userapp.php
cp.php index.php search.php
[[email protected] html]# mv upload/ bbs
安装测试
172.25.28.5/bbs/install
解决不可写的问题
[[email protected] bbs]# chmod 777 config/ data/ uc_server/ uc_client/ -R 谁需要给谁
[[email protected] bbs]# /etc/init.d/mysqld start 配置数据库时,必须要启动,可以登录
Starting MySQL SUCCESS!
[[email protected] bbs]# cd /usr/local/lnmp/php/etc/
[[email protected] etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default php.ini
[[email protected] etc]# vim php.ini
添加.sock文件路径
[[email protected] etc]# /etc/init.d/php-fpm reload 必须要重新加载
Reload service php-fpm done
解决权限问题,主要是对mysql的data数据目录
[[email protected] etc]# cd /usr/local/lnmp/mysql
[[email protected] mysql]# ll
total 60
drwxr-xr-x 2 root root 4096 Aug 5 11:51 bin
-rw-r--r-- 1 root root 17987 Nov 28 2016 COPYING
drwxr-x--- 5 mysql root 4096 Aug 5 15:17 data 其他人没有任何权力
drwxr-xr-x 2 root root 4096 Aug 5 10:19 docs
drwxr-xr-x 3 root root 4096 Aug 5 10:19 include
drwxr-xr-x 4 root root 4096 Aug 5 10:19 lib
drwxr-xr-x 4 root root 4096 Aug 5 10:19 man
drwxr-xr-x 10 root root 4096 Aug 5 10:20 mysql-test
-rw-r--r-- 1 root root 2478 Nov 28 2016 README
drwxr-xr-x 28 root root 4096 Aug 5 10:20 share
drwxr-xr-x 2 root root 4096 Aug 5 10:20 support-files
[[email protected] mysql]# chmod 755 data/
[[email protected] mysql]# cd data/
[[email protected] data]# ll
total 122940
-rw-r----- 1 mysql root 56 Aug 5 11:08 auto.cnf
-rw-r----- 1 mysql mysql 301 Aug 5 11:11 ib_buffer_pool
-rw-r----- 1 mysql root 12582912 Aug 5 11:13 ibdata1
-rw-r----- 1 mysql root 50331648 Aug 5 11:13 ib_logfile0
-rw-r----- 1 mysql root 50331648 Aug 5 11:08 ib_logfile1
-rw-r----- 1 mysql mysql 12582912 Aug 5 11:13 ibtmp1
drwxr-x--- 2 mysql root 4096 Aug 5 11:08 mysql
srwxrwxrwx 1 mysql mysql 0 Aug 5 11:13 mysql.sock
-rw------- 1 mysql mysql 6 Aug 5 11:13 mysql.sock.lock
drwxr-x--- 2 mysql root 4096 Aug 5 11:08 performance_schema
-rw-r----- 1 mysql root 20705 Aug 5 15:17 server5.err
-rw-r----- 1 mysql mysql 6 Aug 5 11:13 server5.pid
drwxr-x--- 2 mysql root 12288 Aug 5 11:08 sys
此时可以正常安装了
删除Discuz的默认安装页面
[[email protected] data]# pwd
[[email protected] nginx]# cd html/bbs
[[email protected] bbs]# ls
admin.php crossdomain.xml install source
api data member.php static
api.php favicon.ico misc.php template
archiver forum.php plugin.php uc_client
config group.php portal.php uc_server
connect.php home.php robots.txt userapp.php
cp.php index.php search.php
[[email protected] bbs]# rm -rf index.php
memcache
[[email protected] ~]# tar zxf memcache-2.2.5.tgz
[[email protected] ~]# cd memcache-2.2.5
[[email protected] memcache-2.2.5]# ls
config9.m4 memcache.php
config.m4 memcache_queue.c
config.w32 memcache_queue.h
CREDITS memcache_session.c
example.php memcache_standard_hash.c
memcache.c php_memcache.h
memcache_consistent_hash.c README
memcache.dsp
[[email protected] memcache-2.2.5]# cd /usr/local/
[[email protected] local]# cd lnmp/
[[email protected] lnmp]# cd php/
[[email protected] php]# ls
bin etc include lib php sbin var
[[email protected] php]# cd bin/
[[email protected] bin]# ls
pear pecl phar.phar php-cgi phpize
peardev phar php php-config
[[email protected] bin]# pwd
/usr/local/lnmp/php/bin
[[email protected] bin]# cd
[[email protected] ~]# vim .bash_profile 配置环境变量
[[email protected] ~]# source .bash_profile
[[email protected] ~]# cd memcache-2.2.5
[[email protected] memcache-2.2.5]# ls
config9.m4 memcache.php
config.m4 memcache_queue.c
config.w32 memcache_queue.h
CREDITS memcache_session.c
example.php memcache_standard_hash.c
memcache.c php_memcache.h
memcache_consistent_hash.c README
memcache.dsp
[[email protected] memcache-2.2.5]# phpize
phpize的作用可以这样理解:侦测环境(phpize工具是在php安装目录下,基于这点phpize对应了当时的php环境,所以是要根据该php的配置情况生成对应的configure文件),建立一个configure文件。必须在一个目录下去运行phpize。那么phpize就知道你的的环境是哪个目录,并且configure文件建立在该目录下。
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[[email protected] memcache-2.2.5]# ls
acinclude.m4 ltmain.sh
aclocal.m4 Makefile.global
autom4te.cache memcache.c
build memcache_consistent_hash.c
config9.m4 memcache.dsp
config.guess memcache.php
config.h.in memcache_queue.c
config.m4 memcache_queue.h
config.sub memcache_session.c
configure memcache_standard_hash.c
configure.in missing
config.w32 mkinstalldirs
CREDITS php_memcache.h
example.php README
install-sh run-tests.php
[[email protected] memcache-2.2.5]# ./configure
[[email protected] memcache-2.2.5]# make
[[email protected] memcache-2.2.5]# make install
Installing shared extensions: /usr/local/lnmp/php/lib/php/extensions/no-debug-non-zts-20131226/
编译安装memcaceh模块成功
[[email protected] memcache-2.2.5]# ll /usr/local/lnmp/php/lib/php/extensions/no-debug-non-zts-20131226/
total 1920
-rwxr-xr-x 1 root root 260483 Aug 5 16:14 memcache.so
-rwxr-xr-x 1 root root 1112440 Aug 5 13:25 opcache.a
-rwxr-xr-x 1 root root 589036 Aug 5 13:25 opcache.so
[[email protected] memcache-2.2.5]# cd /usr/local/lnmp/php/lib/php/extensions
[[email protected] extensions]# ls
no-debug-non-zts-20131226
[[email protected] extensions]# cd no-debug-non-zts-20131226/
[[email protected] no-debug-non-zts-20131226]# ls
memcache.so opcache.a opcache.so
[[email protected] no-debug-non-zts-20131226]# php -m | grep memcache
-m Show compiled in modules
此时memcache还没有加入php模块
编辑php配置文件
[[email protected] local]# cd lnmp/php/etc/
[[email protected] etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default php.ini
[[email protected] etc]# vim php.ini
按照格式写入动态模块
[[email protected] etc]# /etc/init.d/php-fpm reload 重启
Reload service php-fpm done
[[email protected] etc]# php -m | grep memcache
memcache
安装memcached软件
[[email protected] ~]# yum install -y memcached
[[email protected] ~]# /etc/init.d/memcached start
Starting memcached: [ OK ]
[[email protected] ~]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 14805/memcached
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11941/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 950/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1026/master
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14778/php-fpm
tcp 0 0 172.25.28.5:22 172.25.28.250:47386 ESTABLISHED 8268/sshd
tcp 0 0 172.25.28.5:56086 172.25.28.250:80 TIME_WAIT -
tcp 0 0 :::11211 :::* LISTEN 14805/memcached
tcp 0 0 :::22 :::* LISTEN 950/sshd
tcp 0 0 ::1:25 :::* LISTEN 1026/master
tcp 0 0 :::3306 :::* LISTEN 29453/mysqld
[[email protected] ~]# cd memcache-2.2.5
[[email protected] memcache-2.2.5]# cp memcache.php example.php /usr/local/lnmp/nginx/html/ memcache的首页和测试页面放到nginx默认发布目录
[[email protected] memcache-2.2.5]# cd /usr/local/lnmp/nginx/html/
[[email protected] html]# ls
50x.html example.php index.php readme
bbs index.html memcache.php utility
浏览器访问测试页面172.25.28.5/example.php
[[email protected] html]# vim memcache.php
配置密码
可以是多个服务器,但这里我们只有一个
[[email protected] html]# /etc/init.d/php-fpm reload
Reload service php-fpm done
访问测试 172.25.28.5/memcache.php 输入密码
测试时可以打开网站,刷新网页,Hits命中率会提高
客户端压力对比测试
ab是apachebench命令的缩写。
ab是apache自带的压力测试工具。ab非常实用,它不仅可以对apache服务器进行网站访问压力测试,也可以对或其它类型的服务器进行压力测试。比如nginx、tomcat、IIS等
[[email protected] pub]# ab -c 10 -n 1000 http://172.25.28.5/index.php
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 172.25.28.5 (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: nginx
Server Hostname: 172.25.28.5
Server Port: 80
Document Path: /index.php
Document Length: 84805 bytes
Concurrency Level: 10
Time taken for tests: 1.221 seconds
Complete requests: 1000
Failed requests: 96
(Connect: 0, Receive: 0, Length: 96, Exceptions: 0)
Write errors: 0
Total transferred: 84960900 bytes
HTML transferred: 84804900 bytes
Requests per second: 819.00 [#/sec] (mean)
Time per request: 12.210 [ms] (mean)
Time per request: 1.221 [ms] (mean, across all concurrent requests)
Transfer rate: 67952.53 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.8 0 7
Processing: 3 12 3.4 11 28
Waiting: 2 9 3.2 10 22
Total: 3 12 3.3 12 28
Percentage of the requests served within a certain time (ms)
50% 12
66% 13
75% 14
80% 15
90% 17
95% 18
98% 19
99% 21
100% 28 (longest request)
[[email protected] pub]# ab -c 10 -n 1000 http://172.25.28.5/example.php
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 172.25.28.5 (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: nginx
Server Hostname: 172.25.28.5
Server Port: 80
Document Path: /example.php
Document Length: 123 bytes
Concurrency Level: 10
Time taken for tests: 0.473 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 279000 bytes
HTML transferred: 123000 bytes
Requests per second: 2115.22 [#/sec] (mean)
Time per request: 4.728 [ms] (mean)
Time per request: 0.473 [ms] (mean, across all concurrent requests)
Transfer rate: 576.31 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 0.6 0 4
Processing: 1 4 1.5 4 12
Waiting: 1 4 1.5 4 12
Total: 2 5 1.5 4 16
WARNING: The median and mean for the initial connection time are not within a normal deviation
These results are probably not that reliable.
Percentage of the requests served within a certain time (ms)
50% 4
66% 5
75% 5
80% 6
90% 6
95% 8
98% 9
99% 10
100% 16 (longest request)
对比可以发现memcache缓存有很好的作用!!!
OpenResty
server5
nginx -s stop 停止nginx
tar zxf openresty-1.13.6.1.tar.gz openresty自带nginx
cd openresty-1.13.6.1
./configure --prefix=/usr/local/lnmp/openresty --with-http_ssl_module --with-http_stub_status_module --user=nginx --group=nginx --with-file-aio --with-threads
gmake
gmake install
编译安装成功!!!
修改配置文件
(https://www/cnblogs.com/qiangxia/p/4892104.html )
[[email protected] openresty-1.13.6.1]# cd /usr/local/lnmp/openresty/
[[email protected] openresty]# ls
bin COPYRIGHT luajit lualib nginx pod resty.index site
[[email protected] openresty]# cd nginx/
[[email protected] nginx]# ls
conf html logs sbin
[[email protected] nginx]# cd conf/
[[email protected] conf]# vim nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 66535;
}
http {
upstream memcache {
server localhost:11211;
keepalive 512 ; #这里不能加文档里面的single
}
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /memc {
internal;
memc_connect_timeout 100ms;
memc_send_timeout 100ms;
memc_read_timeout 100ms;
set $memc_key $query_string;
set $memc_exptime 300;
memc_pass memcache;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
set $key $uri$args;
srcache_fetch GET /memc $key;
srcache_store PUT /memc $key;
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
[[email protected] conf]# /usr/local/lnmp/openresty/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/lnmp/openresty/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/lnmp/openresty/nginx/conf/nginx.conf test is successful
启动openresty自带的nginx
[[email protected] conf]# /usr/local/lnmp/openresty/nginx/sbin/nginx
[[email protected] nginx]# ls
client_body_temp fastcgi_temp logs sbin uwsgi_temp
conf html proxy_temp scgi_temp
[[email protected] nginx]# cd html/
[[email protected] html]# ls
50x.html index.html
[[email protected] html]# cp /usr/local/lnmp/nginx/html/example.php .
[[email protected] html]# cp /usr/local/lnmp/nginx/html/index.php .
复制文件准备压力测试
客户压力对比测试端
[[email protected] pub]# ab -c 10 -n 1000 http://172.25.28.5/index.php
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 172.25.28.5 (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: openresty/1.13.6.1
Server Hostname: 172.25.28.5
Server Port: 80
Document Path: /index.php
Document Length: 86854 bytes
Concurrency Level: 10
Time taken for tests: 0.340 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 87046000 bytes
HTML transferred: 86854000 bytes
Requests per second: 2944.31 [#/sec] (mean)
Time per request: 3.396 [ms] (mean)
Time per request: 0.340 [ms] (mean, across all concurrent requests)
Transfer rate: 250283.71 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 2
Processing: 1 3 1.1 3 11
Waiting: 0 2 1.0 2 9
Total: 1 3 1.1 3 11
Percentage of the requests served within a certain time (ms)
50% 3
66% 4
75% 4
80% 4
90% 4
95% 5
98% 6
99% 9
100% 11 (longest request)
[[email protected] pub]# ab -c 10 -n 1000 http://172.25.28.5/example.php
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 172.25.28.5 (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: openresty/1.13.6.1
Server Hostname: 172.25.28.5
Server Port: 80
Document Path: /example.php
Document Length: 123 bytes
Concurrency Level: 10
Time taken for tests: 0.129 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 313000 bytes
HTML transferred: 123000 bytes
Requests per second: 7755.36 [#/sec] (mean)
Time per request: 1.289 [ms] (mean)
Time per request: 0.129 [ms] (mean, across all concurrent requests)
Transfer rate: 2370.54 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 2
Processing: 0 1 0.5 1 5
Waiting: 0 1 0.5 1 5
Total: 0 1 0.5 1 5
Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 2
95% 2
98% 3
99% 3
100% 5 (longest request)
可以发现openstry有更好的缓存性能!