编译安装php和mysql

wget http://cn.php.net/distributions/php-7.1.8.tar.gz

yum instal  curl-devel libmcrypt-devel

./configure –prefix=/work/apps/php –with-config-file-path=/work/apps/php/etc \
–with-curl –with-mysqli –with-mcrypt \
–with-pdo-mysql –with-zlib –without-pdo-sqlite \
–without-pear –without-sqlite3 –disable-cgi –disable-ipv6 \
–disable-phar –enable-fpm –enable-mbstring –enable-maintainer-zts

给php提速,训练成适合自己网站的

make prof-gen
sapi/cgi/php-cgi -T 100 /data/htdocs/wordpress/index.php >/dev/null
make prof-clean
make prof-use && make install

cp php.ini-production /work/apps/php/etc/php.inc
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

切换目录
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf

wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.37.tar.gz
groupadd mysql
useradd -r -g mysql mysql
cmake . -DCMAKE_INSTALL_PREFIX=/work/apps/mysql -DMYSQL_DATADIR=/work/data/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DENABLE_DOWNLOADS=1
make && make install
chown -R mysql:mysql /work/apps/mysql
chown -R mysql:mysql /work/data/mysql
cd /work/apps/mysql

scripts/mysql_install_db –basedir=/work/apps/mysql –datadir=/work/data/mysql –user=mysql  –skip-name-resolve

nginx启用HTTP2特性,开启brotli压缩

本站编译环境如下

nginx version: nginx/*****
built by gcc ***** GCC)
built with OpenSSL 1.*****
TLS SNI support enabled
configure arguments: –prefix=/work/apps/nginx –with-http_stub_status_module –without-select_module –without-poll_module –with-debug –with-http_ssl_module –with-http_realip_module –with-http_v2_module –http-log-path=/data/log/nginx/access.log –error-log-path=/data/log/nginx/nginx_error.log –pid-path=/var/run/nginx.pid –with-openssl=/work/apps/openssl –add-module=/work/soft/gitsoft/ngx_brotli

修改编译选项
configure的选项中加入--with-http_v2_module,由于HTTP2需要SSL的支持,因此如缺少--with-http_ssl_module选项,还需要加入--with-http_ssl_module

使用git下载brotli

git clone https://github.com/google/ngx_brotli.git

要使用git submodule update 更新brotli的子模块,否则编译不完整

brotli 配置如下

brotli on;
brotli_comp_level 6;
brotli_buffers 16 8k;
brotli_min_length 20;
brotli_types *;

brotli可以和gzip共存,brotli 需要https才可使用