pagespeed全称为PageSpeed modules,.一款开源的服务器模块,用来自动优化网站的。 PageSpeed modules可用于Web服务器软件Apache和Nginx,而ngx_pagespeed就是PageSpeed用于Nginx的模块名称。
ngx_pagespeed 是一个 Nginx 的扩展模块,可以加速你的网站,减少页面加载时间,它会自动将一些提升web性能的实践应用到网页和相关的资源(CSS、JS和图片)上,无需你修改内容和流程。
功能包括:
[*]图片优化: stripping meta-data, dynamic resizing, recompression
[*]小资源的内联
[*]延长缓存扩展
[*]HTML 重写
[*]推迟图片和 JS 的加载
[*]CSS & JavaScript 压缩、合并等
自动安装依赖关系和建立与ngx_pagespeed的最新稳定版本【引用】(ngx_pagespeed的第一个稳定版本:X-Mod-Pagespeed:1.12.34.2-β)的nginx的最新版本的主线运行:
本文以AMH 5.3编译环境为例(已编译安装好Nginx-1.10.1稳定版本):
[color=rgb(33, 33, 33)]先查看已编译参数:【以amh已安装的nginx版本实际路径为准,这里是nginx-1.10】
/usr/local/nginx-1.10/sbin/nginx -V[color=rgb(33, 33, 33)]复制编译参数:【复制下来configure arguments:后面内容,以你实际编译参数为准】
--prefix=/usr/local/nginx-1.10 --user=www --group=www --with-http_ssl_module --with-openssl=/home/usrdata/nginx-1.10/openssl-1.0.2h --with-http_gzip_static_module --with-http_v2_module --with-threads --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module[color=rgb(33, 33, 33)]运行谷歌官方的ngx_pagespeed模块自动安装脚本(适用于:RedHat, CentOS, or Fedora):
[color=rgb(33, 33, 33)]
本部分内容设定了隐藏,需要回复后才能看到
[color=rgb(33, 33, 33)]【编译安装获取帮助,请执行以下脚本,如果无需查看帮助请直接跳到下面一步:】
bash <(curl -f -L -sS https://ngxpagespeed.com/install) --help↓↓↓↓
[color=rgb(33, 33, 33)]自动安装脚本会下载最新的ngx_pagespeed模块(https://github.com/pagespeed/ngx ... e/latest-stable.zip)和最新的nginx(http://nginx.org/download/nginx-1.11.6.tar.gz),以及依赖的psol库(https://dl.google.com/dl/page-speed/psol/1.11.33.4.tar.gz):
[color=rgb(33, 33, 33)]当出现如图所示:
[color=rgb(33, 33, 33)]
图片:configure.jpg

[color=rgb(33, 33, 33)]输入我们刚刚复制下来的编译参数:
--prefix=/usr/local/nginx-1.10 --user=www --group=www --with-http_ssl_module --with-openssl=/home/usrdata/nginx-1.10/openssl-1.0.2h --with-http_gzip_static_module --with-http_v2_module --with-threads --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module[color=rgb(33, 33, 33)]回车后提示确认:
[color=rgb(33, 33, 33)]
图片:add-module.jpg

[color=rgb(33, 33, 33)]输入:Y
图片:nginx service.jpg
[color=rgb(33, 33, 33)]图片:Build nginx.jpg

[color=rgb(33, 33, 33)]编译安装好后,会提示安装最新的nginx,输入:Y
[color=rgb(33, 33, 33)]提示如下,就表示ngx_pagespeed模块安装编译完成:【应该已经编译安装好Nginx-1.10.1,所以是升级安装编译ngx_pagespeed模块到nginx内核】:
Nginx installed with ngx_pagespeed support compiled-in.
If this is a new installation you probably need an init script to
manage starting and stopping the nginx service. See:
http://wiki.nginx.org/InitScripts
You'll also need to configure ngx_pagespeed if you haven't yet:
https://developers.google.com/speed/pagespeed/module/configuration
You have new mail in /var/spool/mail/root
If this is a new installation you probably need an init script to
manage starting and stopping the nginx service. See:
http://wiki.nginx.org/InitScripts
You'll also need to configure ngx_pagespeed if you haven't yet:
https://developers.google.com/speed/pagespeed/module/configuration
You have new mail in /var/spool/mail/root
图片:configure ngx_pagespeed.jpg

ngx_pagespeed模块安装编译完成后会自动备份原nginx内核:
查看编译结果路径:/usr/local/nginx-1.10/sbin/
启用ngx_pagespeed模块并配置功能:
vi /usr/local/nginx-1.10/conf/nginx.conf查找:
http
{在其下行加入:【通用全局配置↓↓↓】
{在其下行加入:【通用全局配置↓↓↓】
本部分内容设定了隐藏,需要回复后才能看到
【注解:】(更高级配置请参考官方说明:https://developers.google.com/sp ... am-caching?hl=zh-CN)
# 启用ngx_pagespeed
pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
#禁用CoreFilters
pagespeed RewriteLevel PassThrough;
# 启用压缩空白过滤器
pagespeed EnableFilters collapse_whitespace;
# 启用JavaScript库卸载
pagespeed EnableFilters canonicalize_javascript_libraries;
# 把多个CSS文件合并成一个CSS文件
pagespeed EnableFilters combine_css;
# 把多个JavaScript文件合并成一个JavaScript文件
pagespeed EnableFilters combine_javascript;
# 删除带默认属性的标签
pagespeed EnableFilters elide_attributes;
# 改善资源的可缓存性
pagespeed EnableFilters extend_cache;
# 更换被导入文件的@import,精简CSS文件
pagespeed EnableFilters flatten_css_imports;
pagespeed CssFlattenMaxBytes 5120;
# 延时加载客户端看不见的图片 【注意:论坛启用远程附件的请勿开启此功能】
pagespeed EnableFilters lazyload_images;
# 启用JavaScript缩小机制
pagespeed EnableFilters rewrite_javascript;
# 启用图片优化机制
pagespeed EnableFilters rewrite_images;
# 预解析DNS查询
pagespeed EnableFilters insert_dns_prefetch;
# 重写CSS,首先加载渲染页面的CSS规则
pagespeed EnableFilters prioritize_critical_css;
# 嵌入小的外部css文件
pagespeed EnableFilters inline_css;
# 嵌入小js
pagespeed EnableFilters inline_javascript;
# 移除html注释
pagespeed EnableFilters remove_comments;
# 重要的样式优先
pagespeed EnableFilters prioritize_critical_css;
#延迟执行js
pagespeed EnableFilters defer_javascript;
#css移到js前
pagespeed EnableFilters move_css_above_scripts;
【注意:如果有更高使用需求各个环境网站差异化区别配置,需要将配置单独写入到:/home/wwwroot/环境名称/vhost/环境名称.conf (引用)】
创建 pagespeed 缓存目录:
本部分内容设定了隐藏,需要回复后才能看到
重启使配置生效:
init 6检测是否正常加载启用ngx_pagespeed模块:
访问:
本部分内容设定了隐藏,需要回复后才能看到
如果看到文件头:
本部分内容设定了隐藏,需要回复后才能看到
则证明正常安装启用ngx_pagespeed网站加速模块,
本部分内容设定了隐藏,需要回复后才能看到
如果你的环境是LAMP Apache环境,mod_pagespeed模块自动优化网站实现网站加速实现网站加速更简单!
参考资料:
Discuz! LAMP Apache环境使用谷歌mod_pagespeed模块自动优化网站实现网站加速
https://www.cgzz8.cn/t-24667-1-1.html
(出处: 草根吧)
用户被禁言,该主题自动屏蔽!
老规矩,先回后下!!!!!!!
看下能用吗
看看看看看
试试看看啊