清除WordPress头部大量冗余信息

//移除顶部多余信息
remove_action( ‘wp_head’, ‘feed_links’, 2 ); //去除文章feed
remove_action( ‘wp_head’, ‘rsd_link’ ); //针对Blog的远程离线编辑器接口
remove_action( ‘wp_head’, ‘wlwmanifest_link’ ); //Windows Live Writer接口
remove_action( ‘wp_head’, ‘parent_post_rel_link’, 10, 0 ); //移除后面文章的url
remove_action( ‘wp_head’, ‘start_post_rel_link’, 10, 0 ); //移除最开始文章的url
remove_action( ‘wp_head’, ‘wp_shortlink_wp_head’, 10, 0 );//自动生成的短链接
remove_action( ‘wp_head’, ‘wp_generator’ ); // 移除版本号
remove_action(‘wp_head’, ‘index_rel_link’);//当前文章的索引
remove_action(‘wp_head’, ‘feed_links_extra’, 3);// 额外的feed,例如category, tag页
remove_action(‘wp_head’, ‘adjacent_posts_rel_link’, 10, 0); // 上、下篇.
remove_action(‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10, 0 );//rel=pre
remove_action(‘wp_head’, ‘wp_shortlink_wp_head’, 10, 0 );//rel=shortlink
remove_action(‘wp_head’, ‘rel_canonical’ );
wp_deregister_script(‘l10n’);
remove_action(‘wp_head’,’rsd_link’);//移除head中的rel=”EditURI”
remove_action(‘wp_head’,’wlwmanifest_link’);//移除head中的rel=”wlwmanifest”
remove_action(‘wp_head’,’rsd_link’);//rsd_link移除XML-RPC
remove_filter(‘the_content’, ‘wptexturize’);//禁用半角符号自动转换为全角
remove_action(‘wp_head’, array($wp_widget_factory->widgets[‘WP_Widget_Recent_Comments’], ‘recent_comments_style’));

编译安装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才可使用