nginx加载ngx_pagespeed

简介:

1、下载ngx_pagespeed

github  https://github.com/pagespeed/ngx_pagespeed

wget https://github.com/pagespeed/ngx_pagespeed/archive/latest-stable.tar.gz

1
2
3
4
5
6
7
8
9
10
11
tar  zxvf latest-stable. tar .gz
[root@web ngi] # ll ngx_pagespeed-latest-stable
total 129720
-rw-rw-r-- 1 root   root     12306 Sep 16 03:18 config
-rw-rw-r-- 1 root   root       284 Sep 16 03:18 config. make
-rw-rw-r-- 1 root   root      2881 Sep 16 03:18 cpp_feature
-rw-rw-r-- 1 root   root     11342 Sep 16 03:18 LICENSE
-rw-rw-r-- 1 root   root      1474 Sep 16 03:18 README.md
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 scripts
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 src
drwxrwxr-x 2 root   root      4096 Sep 16 03:18  test

2、下载pagespeed

wget https://dl.google.com/dl/page-speed/psol/1.11.33.4.tar.gz

1
2
3
4
5
6
7
8
9
10
11
12
tar  zxvf 1.11.33.4. tar .gz -C ngx_pagespeed-latest-stable
[root@web ngi] # ll ngx_pagespeed-latest-stable
total 129720
-rw-rw-r-- 1 root   root     12306 Sep 16 03:18 config
-rw-rw-r-- 1 root   root       284 Sep 16 03:18 config. make
-rw-rw-r-- 1 root   root      2881 Sep 16 03:18 cpp_feature
-rw-rw-r-- 1 root   root     11342 Sep 16 03:18 LICENSE
drwxr-x--- 4 163798 5000      4096 Sep 15 21:57 psol
-rw-rw-r-- 1 root   root      1474 Sep 16 03:18 README.md
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 scripts
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 src
drwxrwxr-x 2 root   root      4096 Sep 16 03:18  test

3、在nginx目录增加page-speed模块

1
2
3
4
5
cd  nginx-1.2.0
. /configure  --user=web --group=web --prefix= /usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module --with-md5= /usr/lib  --with-sha1= /usr/lib  --add-module=.. /ngx_pagespeed-latest-stable
会出现下面错误
build_from_source= false
error: module ngx_pagespeed requires the pagespeed optimization library

4、需要升级gcc,下面转一个简单点的方法

cd /etc/yum.repos.d && wget http://people.centos.org/tru/devtools-2/devtools-2.repo
然后
yum -y install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
这个将安装的文件放在了
/opt/rh/devtoolset-2

继续编译

1
2
3
4
5
6
7
8
9
10
11
12
. /configure  --user=web --group=web --prefix= /usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module --with-md5= /usr/lib  --with-sha1= /usr/lib  --add-module=.. /ngx_pagespeed-latest-stable  --with-cc= /opt/rh/devtoolset-2/root/usr/bin/gcc
make
如果你是在线编译就可以不用 make  install
mv  /usr/local/nginx/sbin/nginx  /usr/local/nginx/sbin/oldnginx
cp  objs /nginx  /usr/local/nginx/sbin/
查看一下是否正确
/usr/local/nginx/sbin/nginx  -t
nginx: the configuration  file  /usr/local/nginx/conf/nginx .conf syntax is ok
nginx: configuration  file  /usr/local/nginx/conf/nginx .conf  test  is successful
接下来就可以重启了
sudo  make  upgrade
/usr/local/nginx/sbin/nginx  -s reload



fix1、临时更改环境变量

export PATH="/opt/rh/devtoolset-2/root/usr/bin:$PATH"   


 本文转自 ninnycalf 51CTO博客,原文链接:http://blog.51cto.com/314258/1859842


相关文章
|
缓存 JavaScript 应用服务中间件
Nginx+Tomcat代理环境下JS无法完全加载问题
Nginx+Tomcat代理环境下JS无法完全加载问题
216 0
|
XML JSON 算法
宝塔面板Nginx开启Brotli压缩,提升网站加载速度
前言 Google 认为互联网用户的时间是宝贵的,他们的时间不应该消耗在漫长的网页加载中,因此在 2015 年 9 月 Google 推出了无损压缩算法 Brotli。Brotli 通过变种的 LZ77 算法、Huffman 编码以及二阶文本建模等方式进行数据压缩,与 Gzip相比效率提升约 17-25%。这里简单说一下如何在宝塔面板Nginx开启Brotli压缩。 正文 下载Brotli cd /www/server#下载brotligit clone https://github.com/google/ngx_brotli.gitcd ngx_brotli#更新brotligit subm
637 0
宝塔面板Nginx开启Brotli压缩,提升网站加载速度
|
10月前
|
JavaScript 前端开发 应用服务中间件
vue项目加载慢,Nginx页面优化
vue项目加载慢,Nginx页面优化
330 0
|
算法 应用服务中间件 nginx
宝塔面板Nginx开启Brotli压缩,提升网站加载速度-【给网站提提速】
Google 认为互联网用户的时间是宝贵的,他们的时间不应该消耗在漫长的网页加载中,因此在 2015 年 9 月 Google 推出了无损压缩算法 `Brotli`。`Brotli` 通过变种的 `LZ77` 算法、Huffman 编码以及二阶文本建模等方式进行数据压缩,与 `Gzip`相比效率提升约 `17-25%`。这里简单说一下如何在宝塔面板Nginx开启Brotli压缩。
426 0
宝塔面板Nginx开启Brotli压缩,提升网站加载速度-【给网站提提速】
|
前端开发 JavaScript 应用服务中间件
记录_vuecli的打包部署(无法加载elementui和静态资源、centos7中nginx部署)
记录_vuecli的打包部署(无法加载elementui和静态资源、centos7中nginx部署)
140 0
|
应用服务中间件 nginx
systemctl 启动/停止/重新加载 nginx
systemctl 启动/停止/重新加载 nginx
1109 0
|
网络协议 安全 应用服务中间件
二、Nginx | 实用模块介绍与加载
二、Nginx | 实用模块介绍与加载
二、Nginx | 实用模块介绍与加载
|
存储 Kubernetes 应用服务中间件
k8s部署nginx使用nfs挂载路径以及configmap加载nginx.conf
k8s部署nginx使用nfs挂载路径以及configmap加载nginx.conf
1016 0
|
应用服务中间件 PHP nginx