http2 technology to build finishing nginx http2

Use nginx to build a http2 site preparation required:

1, the domain name .com .net available (domestic domain need icp record)

2, a cloud host, you can configure the software to install the free server

3, https certificate

http2 based on https, so the first configured https access

In this paper, ecs Ali cloud operating system CentOS 6.5 (the tutorial for people to use linux foundation, the article does not cover, install the build environment, yum packages such basic things)

Https certificate purchase, you can buy on Taobao, the price ranging from tens to thousands.

Use Code compile and install nginx  http://nginx.org/en/download.html

Currently using the latest version of nginx-1.14.2.tar.gz

nginx http2 module supports, need to use the 1.0.2 OpenSSL  http://nginx.org/en/docs/http/ngx_http_v2_module.html

To download a decompression openssl-1.0.2j.tar.gz

Start compiling nginx module and enable ssl http2

./configure --with-http_ssl_module --with-http_v2_module --prefix=/usr/local/nginx/ --with-openssl=/home/openssl-1.0.2j
make && make install

View running nginx -V version and support

/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.14.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
built with OpenSSL 1.0.2j 26 Sep 2016
TLS SNI support enabled
configure arguments: --with-http_ssl_module --with-http_v2_module --prefix=/usr/local/nginx/ --with-openssl=/home/openssl-1.0.2j

Configuration ssl http2 

/ usr / local / nginx / conf / ssl
certificates purchased put here
xxx.com.key xxx.com.pem

/usr/local/nginx/conf/nginx.conf vi
the listen 443 ssl HTTP2; after the written version # 1.1

server_name www.xxx.com; # fill in the certificate binding domain

ssl_certificate /usr/local/nginx/conf/ssl/xxx.com.pem; # specify the location of the certificate, the absolute path
ssl_certificate_key /usr/local/nginx/conf/ssl/xxx.com.key; # absolute path, supra
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # configured in accordance with the agreement
ssl_ciphers ECDHE-RSA-AES128-GCM -SHA256: HIGH: aNULL: MD5: RC4:!!!! DHE; # configured in this package
ssl_prefer_server_ciphers on;

Use Firefox browser to access (Firefox can be better displayed header information)

Add php7 support

./configure --prefix=/usr/local/php7 --with-pcre-dir --enable-mysqlnd --with-zlib-dir --enable-zip --with-libxml-dir \
--with-iconv-dir --with-openssl-dir --with-freetype-dir --enable-gd-jis-conv --with-gd --with-curl --enable-fpm --enable-mbstring

cd /usr/local/php7/etc
cp php-fpm.conf.default php-fpm.conf

cd /usr/local/php7/etc/php-fpm.d
mv www.conf.default www.conf

修改 nginx.conf
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}


/usr/local/php7/sbin/php-fpm

/usr/local/nginx/sbin/nginx -s reload

 

Guess you like

Origin www.cnblogs.com/ningci/p/11665520.html