OpenResty安装

源码编译
去http://openresty.org/cn/download.html页面下载

wget https://openresty.org/download/openresty-1.13.6.1.tar.gz
tar -xzvf openresty-1.13.6.1.tar.gz
cd openresty-1.13.6.1/
./configure
make -j2
sudo make install

安装后

cd /usr/local/openresty/nginx/sbin
./nginx start

将nginx添加到PATH变量中

PATH=/usr/local/openresty/nginx/sbin:$PATH
export PATH

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

运行下面的命令就可以添加OpenResty的仓库
sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

sudo yum install -y openresty

sudo yum install -y openresty-resty


列出所有 openresty 仓库里头的软件包:
sudo yum --disablerepo="*" --enablerepo="openresty" list available

复制
cp /usr/local/openresty/nginx/sbin/nginx /usr/local/bin
nginx -v

参考:http://openresty.org/cn/linux-packages.html

composer

更新composer版本
composer selfupdate

php开发者该知道的5个Composer小技巧
http://www.phpcomposer.com/5-features-to-know-about-composer-php/

不编辑composer.json的情况下安装库
composer require "monolog/monolog:1.2.*"

使用国内镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com

nginx 编译安装

yum -y update
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel

wget http://nginx.org/download/nginx-1.12.2.tar.gz
wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz

tar zxvf nginx-1.12.2.tar.gz
tar zxf LuaJIT-2.0.5.tar.gz
tar zxvf v0.3.0.tar.gz
tar zxvf v0.10.9rc7.tar.gz
————————————————————————————-
cd LuaJIT-2.0.5
make install PREFIX=/usr/local/LuaJIT
export LUAJIT_LIB=/usr/local/LuaJIT/lib
export LUAJIT_INC=/usr/local/LuaJIT/include/luajit-2.0
————————————————————————————-

groupadd www
useradd -g www www -s /bin/bash/false

cd nginx-1.12.2
./configure –prefix=/etc/nginx –user=www –group=www –sbin-path=/usr/sbin/nginx –modules-path=/usr/lib64/nginx/modules –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –pid-path=/var/run/nginx.pid –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp –http-scgi-temp-path=/var/cache/nginx/scgi_temp –user=nginx –group=nginx –with-compat –with-file-aio –with-threads –with-http_addition_module –with-http_auth_request_module –with-http_dav_module –with-http_flv_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_mp4_module –with-http_random_index_module –with-http_realip_module –with-http_secure_link_module –with-http_slice_module –with-http_ssl_module –with-http_stub_status_module –with-http_sub_module –with-http_v2_module –with-mail –with-mail_ssl_module –with-stream –with-stream_realip_module –with-stream_ssl_module –with-stream_ssl_preread_module –with-cc-opt=’-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC’ –with-ld-opt=’-Wl,-z,relro -Wl,-z,now -pie’ –add-module=/data/download/ngx_devel_kit-0.3.0 –add-module=/data/download/lua-nginx-module-0.10.9rc7

make && make install
echo “/usr/local/LuaJIT/lib” >> /etc/ld.so.conf
ldconfig

ln -s /usr/local/LuaJIT/lib/libluajit-5.1.so.2 /usr/lib
ldconfig
————————————————————————————-
cd /etc/nginx/
git clone https://github.com/loveshell/ngx_lua_waf.git

在nginx.conf http段添加下面内容
lua_package_path “/etc/nginx/ngx_lua_waf/?.lua”;
lua_shared_dict limit 10m;
init_by_lua_file /etc/nginx/ngx_lua_waf/init.lua;
access_by_lua_file /etc/nginx/ngx_lua_waf/waf.lua;

在/etc/nginx/ngx_lua_waf/wafconf/下的post文件头部添加一行
\sor\s+
————————————————————————————-
======重启=====
nginx -tc /etc/nginx/nginx.conf
nginx -s reload -c /etc/nginx/nginx.conf

netstat -luntp|grep 80
————————————————————————————-
mkdir /data/www
chown -R www:www /data/www

php-cp

cd /data/download/
git clone https://github.com/swoole/php-cp.git
cd /php-cp
phpize && ./configure && make && make install
echo “extension=connect_pool.so” > /etc/php.d/connection_pool.ini
–重启 php-fpm
systemctl restart php-fpm

–配置
cp ./config.ini.example /etc/pool.ini
make -m 755 /var/log/php-connection-pool
chmod +x ./pool_server
cp ./pool_server /usr/local/bin/pool_server

–运维
pool_server start
pool_server stop
pool_server restart
pool_server status //查看服务状态