Otu esi etinye Nginx PageSpeed ​​​​Module na Ubuntu 20.04

Google PageSpeed ​​modul, nke a makwaara dị ka mod_PageSpeed ​​​​bụ ngwugwu Apache HTTP ma ọ bụ Nginx nke na-emepe emepe nwere modul na-enyere aka ịkwalite saịtị gị site na iji nzacha dị iche iche na ibe na-ebuli ụdị ihe nkesa, Javascript, na HTML faịlụ na ihe oyiyi site na caching na idegharị n'etiti n'elu. atụmatụ.

Ị ga-amụta ka esi wụnye ma mee nhazi ntọala na Nginx PageSpeed ​​​​na sava Ubuntu 20.04 na ntuziaka anyị.

Prerequisites

  • Ubuntu 20.04 OS (20.10 na 21.04 nwere ike iji)
  • Melite ngwungwu sistemụ ụbọchị
  • Nweta mgbọrọgwụ ma ọ bụ ikike sudo.
  • Nginx Mainline ma ọ bụ Stable na nke dị ugbu a.
  • Curl, Git, Unzip, na Wget ngwungwu arụnyere.

Lelee maka mmelite na sistemụ Ubuntu 20.04 gị:

sudo apt update && sudo apt upgrade -y

Wụnye ngwungwu achọrọ curl, nweta wee wepụ ya:

sudo apt install unzip wget curl git && sudo apt update -y

Ị ga-achọkwa ịwụnye ngwugwu ndị a maka akụkụ dị iche iche nke ntuziaka a.

Wụnye ngwugwu PageSpeed ​​​​kpọmkwem chọrọ:

sudo apt install dpkg-dev uuid-dev make

Iji wụnye Nginx Mainline, nke masịrị, gaa na nke anyị Otu esi etinye Nginx Mainline na Ubuntu 20.04 ndu.


Advertisement


Budata ngwugwu Nginx Source

Ị ga-achọ ịkọwapụta"ngx_pagespeed modul"site na isi iyi dị ka modul ike. Ọ bụrụ na i mebeghị nke a na mbụ, anyị ga-ekpuchi otu esi emepụta ndekọ maka ịchịkọta maka modul a taa na n'ọdịnihu, dịka oge ọ bụla ị na-emelite Nginx gị site na njikwa ngwugwu APT, ị ga-achọkwa ibudata isi mmalite ahụ. ma chịkọtagharịa modul ndị dị ike.

Mepụta ndekọ isi mmalite Nginx.

sudo mkdir -p /usr/local/src/nginx

Ugbu a gaa na akwụkwọ ndekọ aha gị ekepụtara ọhụrụ site na CD.

cd /usr/local/src/nginx

Na-esote, budata ngwugwu Nginx dị ka iwu sudo dị n'okpuru.

sudo apt source nginx

Ị ga-enweta mmepụta na-esonụ. Mara na ị ga-ahụ ozi agọnarị. Enwere ike ileghara nke a anya.

$ sudo apt source nginx
 [sudo] password for bytesboss: 
 Reading package lists… Done
 Need to get 1,184 kB of source archives.
 Get:1 http://nginx.org/packages/mainline/ubuntu focal/nginx nginx 1.21.0-1~focal (dsc) [1,515 B]
 Get:2 http://nginx.org/packages/mainline/ubuntu focal/nginx nginx 1.21.0-1~focal (tar) [1,064 kB]
 Get:3 http://nginx.org/packages/mainline/ubuntu focal/nginx nginx 1.21.0-1~focal (diff) [119 kB]
 Fetched 1,184 kB in 3s (441 kB/s)
 dpkg-source: info: extracting nginx in nginx-1.21.0
 dpkg-source: info: unpacking nginx_1.21.0.orig.tar.gz
 dpkg-source: info: unpacking nginx_1.21.0-1~focal.debian.tar.xz
 W: Download is performed unsandboxed as root as file 'nginx_1.21.0-1~focal.dsc' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)

Na-esote, iji gosi na ebudatala isi iyi, pịnye iwu a.

ls -l

Ihe mmepụta kwesịrị ịbụ, dịka ọmụmaatụ.

$ ls -l
 total 1164
 drwxr-xr-x 10 root root    4096 Jun 20 19:07 nginx-1.21.0
 -rw-r--r--  1 root root  118568 May 25 06:21 nginx_1.21.0-1~focal.debian.tar.xz
 -rw-r--r--  1 root root    1515 May 25 06:21 nginx_1.21.0-1~focal.dsc
 -rw-r--r--  1 root root 1063682 May 25 06:21 nginx_1.21.0.orig.tar.gz

Budata ngwugwu isi mmalite ngx_pagespeed

N'akụkụ nke ọzọ nke ntuziaka ahụ, ị ​​ga-achọ ibudata "ngx_pagespeed" isi ngwugwu. A na-atụ aro ka iji Git mechie isi mmalite ngwa ngwa, n'ihi na ị nwere ike ịdọrọ mmelite ngwa ngwa ma emesịa wee chịkọtaghachi n'ọdịnihu.

Ugbu a, n'akụkụ a, ị nwere nhọrọ abụọ ugbu a v1.13.35.2-kwụsi ike ngalaba nchekwa ma ọ bụ v1.14.33.1-RC1 alaka ụlọ ọrụ tupu ahapụ ya. Ha abụọ nwere nsogbu ugbu a. Aro ga-abụ ịga na Git wee gụọ ndepụta ahụ nke ugbu a okwu ịhụ ma ọ dị nke ọ bụla ga-emetụta gị karịa nke ọzọ.

N'ime ntuziaka anyị, anyị hụrụ na ịwụnye ụdị ntọhapụ ahụ na-arụ ọrụ kacha mma. Agbanyeghị kwụsiri ike nwere ike ịbara gị uru karịa, ọ bụ oku siri ike ịme.

Nke mbụ, CD banye na ndekọ:

cd /usr/local/src

Ugbu a mechie isi iyi ngx_pagespeed git:

sudo git clone https://github.com/apache/incubator-pagespeed-ngx.git

Ihe atụ mmepụta:

$ sudo git clone https://github.com/apache/incubator-pagespeed-ngx.git
 Cloning into 'incubator-pagespeed-ngx'…
 remote: Enumerating objects: 84048, done.
 remote: Counting objects: 100% (7/7), done.
 remote: Compressing objects: 100% (7/7), done.
 remote: Total 84048 (delta 1), reused 3 (delta 0), pack-reused 84041
 Receiving objects: 100% (84048/84048), 78.83 MiB | 17.93 MiB/s, done.
 Resolving deltas: 100% (64835/64835), done.

Enwere ike ime akụkụ nke ọzọ n'ụzọ abụọ dị iche iche, kwụsiri ike ma ọ bụ tupu ahapụ ya. A ga-edepụta ha abụọ n'okpuru.

ngx_pagespeed kwụsiri ike - Akwadoro

CD n'ime isi mmalite clone ngx_pagespeed, wee lelee alaka ụlọ ọrụ kwụsiri ike kachasị ọhụrụ.

CD n'ime ndekọ ọsọ ọsọ ibe:

cd incubator-pagespeed-ngx

Lelee mwepụta ibe akwụkwọ kwụsiri ike kacha ọhụrụ:

sudo git checkout latest-stable

Ihe atụ mmepụta:

$ cd incubator-pagespeed-ngx
 bytesboss@ubuntu:/usr/local/incubator-pagespeed-ngx$ sudo git checkout latest-stable
 Note: switching to 'latest-stable'.

You are in 'detached HEAD' state. You can look around, make experimental
 changes and commit them, and you can discard any commits you make in this
 state without impacting any branches by switching back to a branch.
 If you want to create a new branch to retain commits you create, you may
 do so (now or later) by using -c with the switch command. Example:

 git switch -c 

 Or undo this operation with:

 git switch -

 Turn off this advice by setting config variable advice.detachedHead to false
 HEAD is now at 11ba8ea54 Update PSOL_BINARY_URL
 bytesboss@ubuntu:/usr/local/incubator-pagespeed-ngx$ 

Ugbu a, ị gaara achọpụtala na njedebe nke mmepụta "PSOL_BINARY_URL” e bipụtara ya. Njikọ nbudata PSOL URL bụ ọba akwụkwọ nkwalite ngwa ngwa nke kwesịrị ibudata na alaka ụlọ ọrụ ị na-eji, nlele GIT.

Ka ịchọta URL nke ọba akwụkwọ iji budata, pịnye iwu na-esonụ iji kpughee.

Jiri iwu nwamba ka ịchọta URL:

cat PSOL_BINARY_URL

Ihe atụ mmepụta:

:/usr/local/incubator-pagespeed-ngx$ cat PSOL_BINARY_URL
 https://dl.google.com/dl/page-speed/psol/1.13.35.2-$BIT_SIZE_NAME.tar.gz

Rịba ama, mmepụta nwere"$BIT_SIZE_NAME". Nke a maka, ọtụtụ mmadụ ga-abụ x64.

Na-esote, budata ọba akwụkwọ nyocha nke PageSpeed ​​​​(PSOL), ka anyị nwee ike ịga n'ihu.

Budata ebe nchekwa ọba akwụkwọ siri ike PSOL:

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

Ihe atụ mmepụta:

--2021-06-20 19:28:15--  https://dl.google.com/dl/page-speed/psol/1.13.35.2-x64.tar.gz
 Resolving dl.google.com (dl.google.com)… 142.250.66.174, 2404:6800:4006:80e::200e
 Connecting to dl.google.com (dl.google.com)|142.250.66.174|:443… connected.
 HTTP request sent, awaiting response… 200 OK
 Length: 18740791 (18M) [application/x-tar]
 Saving to: ‘1.13.35.2-x64.tar.gz’
 1.13.35.2-x64.tar.gz       100%[======================================>]  17.87M  26.3MB/s    in 0.7s    
 2021-06-20 19:28:17 (26.3 MB/s) - ‘1.13.35.2-x64.tar.gz’ saved [18740791/18740791]

Ugbu a wepụ ihe ndekọ ahụ. Nke a ga - eme "psol” ndekọ na-akpaghị aka na wepụ faịlụ. Ị ga-enweta mbipụta ndepụta ogologo, mana ụlọ akwụkwọ niile dị njikere ka achịkọta ya dị ka modul ike na isi Nginx gị ozugbo emechara.

Wepụ ebe nchekwa:

sudo tar xvf 1.13.35.2-x64.tar.gz

Mwepụta tupu ngx_pagespeed – ịkpachara anya

Usoro maka iji modul ngx_pagespeed ewepụtara na ọba akwụkwọ PSOL ka dị ka alaka ụlọ ọrụ kwụsiri ike. Ya mere, ihe niile ị ga-eme bụ ịgbanwe ụfọdụ nhọrọ gburugburu dị ka kwa n'okpuru.

CD n'ime isi iyi nke clone ngx_pagespeed, wee lelee alaka kacha ọhụrụ tupu ewepụtara ya. Mara, alaka ụlọ ọrụ ewepụtara tupu ahapụ ya ga-enwe ike ịgbanwe n'ọdịnihu. 

Ya mere, ị ga-aga na ọrụ Github alaka wee chọta nke kacha ọhụrụ. Ugbu a, ngalaba 36 bụ ngalaba ewepụtara tupu ewepụtara ya "v1.14.33.1-RC1". Anyị ga-awụpụ nzọụkwụ banyere cloning, na-ezo aka azụ na "stable" maka ntuziaka.

CD n'ime ndekọ ọsọ ọsọ ibe:

cd incubator-pagespeed-ngx

Lelee alaka ibe ibe akwụkwọ tupu ewepụtara ya dị 36:

sudo git checkout 36

Ihe atụ mmepụta:

$ sudo git checkout 36
 Note: switching to '36'.
 You are in 'detached HEAD' state. You can look around, make experimental
 changes and commit them, and you can discard any commits you make in this
 state without impacting any branches by switching back to a branch.
 If you want to create a new branch to retain commits you create, you may
 do so (now or later) by using -c with the switch command. Example:
 git switch -c 
 Or undo this operation with:
 git switch -
 Turn off this advice by setting config variable advice.detachedHead to false
 HEAD is now at 11ba8ea54 Update PSOL_BINARY_URL
 bytesboss@ubuntu:/usr/local/incubator-pagespeed-ngx$ 

Ugbu a, ị gaara achọpụtala na njedebe nke mmepụta "PSOL_BINARY_URL” e bipụtara ya. Njikọ nbudata PSOL URL bụ ọba akwụkwọ nkwalite ngwa ngwa nke kwesịrị ibudata na alaka ụlọ ọrụ ị na-eji, nlele GIT.

Ka ịchọta URL nke ọba akwụkwọ iji budata, pịnye iwu na-esonụ iji kpughee.

Jiri iwu nwamba ka ịchọta URL:

cat PSOL_BINARY_URL

Ihe atụ mmepụta:

:/usr/local/incubator-pagespeed-ngx$ cat PSOL_BINARY_URL
 https://dist.apache.org/repos/dist/release/incubator/pagespeed/1.14.36.1/x64/psol-1.14.36.1-apache-incubating-$BIT_SIZE_NAME.tar.gz

Rịba ama, mmepụta nwere"$BIT_SIZE_NAME". Nke a maka, ọtụtụ mmadụ ga-abụ x64.

Na-esote, budata ọba akwụkwọ nyocha nke PageSpeed ​​​​(PSOL), ka anyị nwee ike ịga n'ihu.

Budata ebe nchekwa ọba akwụkwọ siri ike PSOL:

wget sudo tar xvf psol-1.14.36.1-apache-incubating-x64.tar.gz 

Wepụ ebe nchekwa:

sudo tar xvf psol-1.14.36.1-apache-incubating-x64.tar.gz 

Advertisement


Jiri modul ngx_pagespeed kpokọta Nginx

Ọzọ, ị ga-eji modul ngx_pagespeed chịkọta isi iyi Nginx ị budata na ọba akwụkwọ PSOL.

Mbụ, CD gaa na akwụkwọ ndekọ aha Nginx gị. Mara, nọmba ụdị Nginx nwere ike ịdị iche.

cd /usr/local/src/nginx/nginx-1.21.0

Na-esote, wụnye ndabere ntọala maka isi mmalite Nginx.

sudo apt build-dep nginx

Ihe atụ mmepụta:

$ sudo apt build-dep nginx
 Reading package lists… Done
 Reading package lists… Done
 Building dependency tree       
 Reading state information… Done
 The following NEW packages will be installed:
   dh-systemd diffstat quilt
 0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
 Need to get 331 kB of archives.
 After this operation, 1,016 kB of additional disk space will be used.
 Do you want to continue? [Y/n] 

Ị ga-enweta [Y/n], tinye"Y”Ka ị gaa n'ihu.

Ugbu a, ị ga-achịkọta modul ngx_pagespeed na "-ọkọlọtọ nwere kọmpat". Usoro a ga-eme ka modul faịlụ n'ọdịnihu "ngx_pagespeed.so” dakọtara na sava Nginx gị nọ n'ọrụ.

Tinye modul ike:

sudo ./configure --with-compat --add-dynamic-module=/usr/local/src/incubator-pagespeed-ngx

Na-esote, mee modulu. Usoro a ga-aga ihe dị ka nkeji 1 na kacha.

Mee modul:

sudo make modules

Ọmụmaatụ na njedebe nke mmecha:

objs/ngx_pagespeed_modules.o \
 /usr/local/src/incubator-pagespeed-ngx/psol/lib/Release/linux/x64/pagespeed_automatic.a -lstdc++ -lrt -pthread -lm -luuid \
 -shared
 make[1]: Leaving directory '/usr/local/src/nginx-1.21.0'

Ugbu a, detuo ihe emere ọhụrụ"ngx_pagespeed.so" modul gaa na ndekọ ihe nkesa Nginx gị na-arụ ọrụ. Ebe ndị ahụ nwere ike ịdịgasị iche dabere na nrụnye gị, mana nke a kwesịrị ịbụ otu maka ọtụtụ ndị mmadụ.

Bugharịa modul:

sudo cp objs/ngx_pagespeed.so /etc/nginx/modules/

Nhọrọ:

sudo cp objs/ngx_pagespeed.so /usr/share/nginx/modules/

Budata modul ngx_pagespeed na Nginx

Ugbu a oge eruola ibunye modul ngx_pagespeed na Nginx. Anyị ga-eji nchịkọta ederede nano maka nke a. Nke mbụ, mepee "" gịnginx.conf" faịlụ.

sudo nano /etc/nginx/nginx.conf

Ugbu a, tinye ahịrị na-esonụ na mmalite nke faịlụ, ihe atụ n'okpuru.

###add module###
 load_module modules/ngx_pagespeed.so;
 
##realistic example in working environment###
 user www-data;
 worker_rlimit_nofile 100000;
 worker_processes  auto;
 error_log  /var/log/nginx/error.log warn;
 pid        /var/run/nginx.pid;
 load_module modules/ngx_http_modsecurity_module.so;
 load_module modules/ngx_http_brotli_filter_module.so;
 load_module modules/ngx_http_brotli_static_module.so;
 load_module modules/ngx_http_headers_more_filter_module.so;
 load_module modules/ngx_pagespeed.so; ##### insert with other modules ###

Iji mechaa, nwalee nhazi Nginx gị na iwu ịgba ọsọ akọrọ, mgbe ahụ ọ bụrụ na ọ dị mma malitegharịa ihe nkesa Nginx.

sudo nginx -t

Nsonaazụ kwesịrị ịbụ:

$ sudo nginx -t
 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
 nginx: configuration file /etc/nginx/nginx.conf test is successful

Ọ bụrụ na Nginx syntax dị mma, malitegharịa ọrụ Nginx:

sudo systemctl restart nginx

Advertisement


Mepụta cache ọsọ ọsọ

Tupu ị hazie ihe nzacha gị, ịkwesịrị ịmepụta ndekọ cache maka Nginx pagespeed iji chekwaa faịlụ echekwara na ntụgharị onyonyo. Enwere ike ịgbanwe nke a ka ọ bụrụ ebe ị họọrọ; Otú ọ dị, anyị ga-eme ya n'okpuru nchekwa Nginx maka ntuziaka.

Mepụta ndekọ cache:

sudo mkdir -p /etc/nginx/ngx_pagespeed_cache

Tọọ onye ọrụ www-data ka onye nwe ya (dị mkpa):

sudo chown -R www-data:www-data /etc/nginx/ngx_pagespeed_cache

Haziri ndị na-ebufe PageSpeed

Ugbu a, enwere ụzọ ole na ole ị nwere ike isi na-edozi ihe nzacha ngwa ngwa ibe gị, ma ọ nweghị nke ziri ezi ma ọ bụ na-ezighị ezi. Agbanyeghị, maka ntuziaka a, anyị ga-emepụta "pagespeed.conf" faịlụ.

Ihe kpatara nke a bụ n'ihi na nhazi ngwa ngwa peeji nwere ike ịghọ aghụghọ ma na-enwekarị ike imebi weebụsaịtị. Ọ bụrụ na ịchọrọ ịtụgharị modul ngwa ngwa ngwa ngwa, ị nwere ike ikwu okwu megide ahịrị pagespeed.conf gụnyere na ngọngọ sava gị.

Mepụta folda ọsọ ọsọ ibe:

sudo mkdir -p /etc/nginx/pagespeed

Mepụta faịlụ pagespeed.conf:

sudo nano /etc/nginx/pagespeed-example.com.conf

Na-esote, anyị ga-agafe nzacha nke edobere nchekwa maka ọtụtụ weebụsaịtị. Agbanyeghị, enwere ike ịgbanwe nke a ma gbanwee ka ọ bụrụ oke nhọrọ dị iche iche n'ọdịniihu, mana ị ga-achọ nyocha nke a site na ileta akwụkwọ ahụ nke ọma.

###enable pagespeed on the server block###
 pagespeed on;
 pagespeed Domain https://www.example.com;
 pagespeed Domain https://example.com;

###Add this line if your website runs on HTTPS###
 pagespeed FetchHttps enable;

###Set up admin location###
 admin console
 pagespeed Statistics on;
 pagespeed StatisticsLogging on;
 pagespeed StatisticsLoggingIntervalMs 60000;
 pagespeed StatisticsLoggingMaxFileSizeKb 1024;
 pagespeed MessageBufferSize 100000;
 pagespeed LogDir /var/log/pagespeed;
 pagespeed AdminPath /pagespeed_admin;

###SECURE THE LOCATION FROM BAD BOTS AND MALICOUS ACTORS###
 location ~ ^/pagespeed_admin {
    allow 127.0.0.1;
    allow your-own-IP-address;
    deny all;
 }


###Specify the file cache folder that you created earlier###
 pagespeed FileCachePath /etc/nginx/ngx_pagespeed_cache;

###Set the cache settings, you can play around with these numbers###
 pagespeed FileCacheSizeKb            102400;
 pagespeed FileCacheCleanIntervalMs   3600000;
 pagespeed FileCacheInodeLimit        500000;
 pagespeed LRUCacheKbPerProcess     1024;
 pagespeed LRUCacheByteLimit        16384;

###OPTIONAL: use Memcached to further increase performance of pagespeed###
 pagespeed MemcachedThreads 1;
 pagespeed MemcachedServers "localhost:11211";

###Ensure requests for pagespeed optimized resources go to the pagespeed handler###
 and no extraneous headers get set.
 location ~ ".pagespeed.([a-z].)?[a-z]{2}.[^.]{10}.[^.]+" {
   add_header "" "";
 }
 location ~ "^/pagespeed_static/" { }
 location ~ "^/ngx_pagespeed_beacon$" { }

###Set the most common safe filters###
 pagespeed RewriteLevel CoreFilters;

Ugbu a, o nwere ike ịbụ na ị chọpụtala na anyị degharịrị aha n'ime akwụkwọ ndekọ peeji nke emepụtara ọhụrụ faịlụ ntọlite ​​​​“pagespeed-example.com.conf". Emere nke a dị ka a ga-asị na ị na-akwado ọtụtụ weebụsaịtị n'otu sava ahụ. Ụfọdụ nwere ike ịchọ nhazi ngwa ngwa dị iche iche, yabụ ikewa faịlụ ahazi ga-eme ka nhazi gị ghara ịdị njọ.

Nhọrọ nzacha edobere bụ "CoreFilters" dị ka re-dee larịị. N'ozuzu, PageSpeed ​​​​na-enye ọkwa idegharị ugboro atọ, nke bụ "CoreFilters, Passthrough na ebuli maka bandwit". Dị ka ị nwere ike chọpụtala site na nkwupụta mbụ, "CoreFilters" adịghị mma maka ọtụtụ weebụsaịtị ma jiri ya mee ihe dị ka ndabere maka ule.

Corefilter nwere:

  •   tinye_isi - Na-agbakwunye a  mmewere na akwụkwọ ma ọ bụrụ na ọ dịbeghị.
  •   ikpokọta_css - Na-ejikọta ọtụtụ ihe CSS n'ime otu.
  •   mix_javascript - Na-ejikọta ọtụtụ ihe edemede n'ime otu.
  •   convert_meta_tags - Na-agbakwụnye nkụnye eji isi mee nzaghachi maka mkpado meta ọ bụla nwere njirimara http-equiv.
  •   gbasaa_cache - Na-agbatị ogologo ndụ cache nke CSS, JS na akụrụngwa onyonyo nke emebeghị nke ọma site na iji hash ọdịnaya bịanye aka na URL.
  •   fallback_rewrite_css_urls - Na-edegharị akụrụngwa ezoro ezo na faịlụ CSS ọ bụla nke enweghị ike ịtụgharị ma ọ bụ belata.
  •   flatten_css_ibubata - Inline CSS site n'imetu iwu @ mbubata niile.
  •   inline_css - Tinye obere faịlụ CSS n'ime akwụkwọ HTML.
  •   inline_import_to_link - Inline  mkpado nwere naanị CSS @imports site n'ịtụgharị ha ka ọ bụrụ otu  mkpado.
  •   inline_javascript - Tinye obere faịlụ JS n'ime akwụkwọ HTML.
  •   degharịa_css - Na-edegharị faịlụ CSS ka ewepu oke ocha na nkọwa, yana, ọ bụrụ na enyere ya aka, degharịa ma ọ bụ gbatịa ihe onyonyo ndị zoro aka na faịlụ CSS. Na OptimizeForBandwit mode, mwepu a na-eme na ebe na-agbanweghị URL.
  •   degharịa_ihe onyonyo - Na-ebuli onyonyo, na-edegharị ha ọzọ, na-ewepụ pikselụ gafere, na itinye obere onyonyo. Na OptimizeForBandwit mode, mwepu a na-eme na ebe na-agbanweghị URL. 
  •   degharịa_javascript Na-edegharị faịlụ Javascript iji wepụ oke ọcha na nkọwa. Na OptimizeForBandwit mode, mwepu a na-eme na ebe na-agbanweghị URL. 
  •   jiri_url degharịa ụdị_style - Degharịa CSS n'ụdị ụdị ma ọ bụrụ na o nwere ederede 'url(' site na itinye nzacha rewrite_css ahaziri na ya.

Ugbu a, ị nwere ike ịbawanye CoreFilters n'ihu site n'ịgbakwunye ọbụna ihe nzacha. Agbanyeghị, m ga-adụ ọdụ ka ịme nyocha dị ka ihe nzacha ndị ọzọ hà nhata ihe ize ndụ nke imebi weebụsaịtị gị. Ọ bụ nka dị mma iji google pagespeed, ọmụmaatụ n'okpuru ụfọdụ nhọrọ ndị ọzọ.

###css optimization filters###
 pagespeed EnableFilters outline_css;
 pagespeed EnableFilters inline_google_font_css;
 pagespeed EnableFilters move_css_above_scripts;
 pagespeed EnableFilters move_css_to_head;
 pagespeed EnableFilters prioritize_critical_css;

###html optimization filters###
 pagespeed EnableFilters combine_heads;
 pagespeed EnableFilters collapse_whitespace;
 pagespeed EnableFilters convert_meta_tags;
 pagespeed EnableFilters elide_attributes;
 pagespeed EnableFilters pedantic;
 pagespeed EnableFilters remove_comments;
 pagespeed EnableFilters remove_quotes;
 pagespeed EnableFilters trim_urls;

###javascript optimization filters###
 pagespeed EnableFilters canonicalize_javascript_libraries;
 pagespeed EnableFilters defer_javascript;

###image optimization filters###
 pagespeed EnableFilters dedup_inlined_images;
 pagespeed EnableFilters inline_preview_images;
 pagespeed EnableFilters resize_mobile_images;
 pagespeed EnableFilters lazyload_images;
 pagespeed EnableFilters strip_image_color_profile;
 pagespeed EnableFilters strip_image_meta_data;
 pagespeed EnableFilters jpeg_subsampling;
 pagespeed EnableFilters convert_png_to_jpeg;
 pagespeed EnableFilters resize_rendered_image_dimensions;
 pagespeed EnableFilters insert_image_dimensions;
 pagespeed NoTransformOptimizedImages on;
 pagespeed EnableFilters sprite_images;

Ozugbo emechara, CTRL + O ka ị chekwaa, wee pụọ CTRL + X.

Tinye ahịrị ndị a, nwalee, ma malitegharịa ozugbo ịtọlitechara iji tinye nke a na ngọngọ nkesa gị.

Jiri nchịkọta akụkọ nano iji mepee ngọngọ nkesa:

sudo nano /etc/nginx/sites-available/example.com.conf

Tinye ahịrị ndị a ka ịtinye nzacha:

include /etc/nginx/pagespeed/pagespeed-example.com.conf;

Nwalee ihe nkesa Nginx gị tupu ịmalitegharịa:

sudo nginx -t

Ọ bụrụ na nginx syntax gị dị mma na enweghị mmejọ, malitegharịa ọrụ Nginx:

sudo systemctl restart nginx

Advertisement


Nkwado Ntụgharị WebP

Iji mepụta onyonyo WebP, wụnye ngwugwu ndị a na sistemụ arụmọrụ Ubuntu 20.04 gị.

sudo apt install imagemagick php7.4-imagick ffmpeg

Nyochaa ngx_pagespeed na-arụ ọrụ

Ịrụsi ọrụ ike arụpụtala ihe. Ugbu a, ịchọrọ ịhụ ma PageSpeed ​​​​na-arụ ọrụ. Anyị ga-eme nke a site na iji iwu curl, dịka ọmụmaatụ n'okpuru.

curl -I -p https://www.example.com

Ị ga-ahụ na mmepụta akụkụ a dị ka ndị a:

x-page-speed: 1.13.35.2-0

Advertisement


Bugharịa ngx_pagespeed

Modul ngx_pagespeed enweghị ọrụ bu ụzọ buo ibu, nke nwere ike na-akụda mmụọ ebe ọ nwere ike ịga ọtụtụ nleta tupu echekwabara ihe nke ọma wee kwalite ya. Nke a nwere ike ịka njọ ma ọ bụrụ na ị ga-ehichapụ cache ugboro ole na ole n'ụbọchị, na-ahapụghị ọkwa nkwalite weebụsaịtị gị n'enweghị ihe ọ bụla.

Agbanyeghị, itinye iwu a ka ibu ụzọ weta ibe weebụ gị niile ma ọ bụrụ na ịtọlitela ramdisk. Ọzọkwa, ị nwere ike ịtọ nke a na cronjob maka ọdịnihu ime kwa elekere, kwa ụbọchị ma ọ bụ kwa izu. Gaa leta Crontab.guru ọ bụrụ na ịchọrọ enyemaka ịmepụta oge cron.

Bugharịa ramdisk ngwa ngwa ibe:

sudo wget -m -p -E -k -P /tmp/ramdisk/ https://www.example.com/

Ọrụ Cronjob 1 kwa elekere:

00 */1 * * * sudo wget -m -p -E -k -P /tmp/ramdisk/ https://www.example.com/

Ihe enyemaka obodo maka ọsọ ibe


Advertisement


Nchọpụta nsogbu nsogbu

Overview

Otu n'ime ndụmọdụ kachasị maka ịchọ na nbipu nsogbu na PageSpeed ​​​​bụ iji?PageSpeedFilters=+debug oke njedebe URL gị. Ọmụmaatụ, "https://www.linuxcapable.com/?PageSpeedFilters=+debug".

Ozugbo i bulitere ibe ahụ, lelee isi mmalite webụ wee gaa na akụkụ ndị na-enye gị nsogbu, ị ga-ahụkwa ozi ndị fọdụrụ na koodu isi mmalite gị na-agwa gị ihe njehie nwere ike ịbụ.

Rịba ama, ozugbo ị doziri ihe nzacha PageSpeed ​​​​ gị, ịkwesịrị ịmeghachi ibe ahụ ugboro ole na ole. Ọ bụrụ na ị na-eji Igwe ojii ma ọ bụ ọrụ yiri ya, wee hụ na ị ga-ehichapụ cache. Otu ihe ahụ na-aga maka plugins ọ bụla na-eme cache.

Njehie 1 ọmụmaatụ:

Ọ bụrụ na ịchọta na ị ga-ahụ njehie a.

<--The preceding resource was not rewritten because its domain (www.example.com) is not authorized-->

Nke a bụ n'ozuzu n'ihi na ị depụtaghị ngalaba aha na ndepụta ekwenyere maka ngx_pagespeed. Iji dozie nke a, tinye ihe ndị a na faịlụ nhazi ngwa ngwa ibe gị.

pagespeed Domain https://www.linuxcapable.com;
pagespeed Domain https://linuxcapable.com;

More ịbịa ...

Okwu na mmechi

PageSpeed ​​​​bụ ụzọ magburu onwe ya nke ịkwalite weebụsaịtị gị n'oge ndị a ebe SEO njikarịcha na Google Search na-adabere na ọsọ ọsọ ụbọchị ndị a karịa n'afọ ndị gara aga. N'oge na-adịbeghị anya, Google emelitere algọridim ha na Julaị 2021 nke na-etinyekwu ike na otu ibe weebụ na-ebu ngwa ngwa, nke nwere ike gbanwee ogo njin ọchụchọ gị nke ukwuu.

Akụrụngwa dịkwa egwu dị ka ọ na-arụ ọrụ na azụ azụ ọ bụghị mgbakwunye mgbakwunye na-arụ ọrụ site na ngwa weebụ dị ka WordPress. Otú ọ dị, PageSpeed ​​​​nwere ike ịdị mgbagwoju anya; O yikarịrị ka ọ ga-ewe gị ụbọchị ole na ole ruo ọbụna izu ole na ole iji nweta nhazi kacha mma maka weebụsaịtị gị. Akwụghachila ngx_pagespeed naanị wee pụọ. Ekwesịrị ime nnwale, yana ọtụtụ nzacha ị na-agbakwunye, ka ihe egwu dị elu nwere ike imebi weebụsaịtị gị.

Tupu ịmalite iji nzacha na-akpakọrịta, gaa na Google PageSpeed ​​​​ akwụkwọ. Ọ ga-enye gị azịza miri emi na ihe ize ndụ dị na ya na ihe ndị ọzọ nzacha ọ bụla nwere ike ime na ebe nrụọrụ weebụ gị. Ọtụtụ ndị mmadụ na-ahapụ iji PageSpeed ​​​​ebe ọ bụ na ha enweghị ike itinye mgbalị iji nweta ya nke ọma n'ihi na ọ na-ewe oge na nkụda mmụọ. Mana ọ bụrụ na ịmee, mgbe ahụ ọ nwere ike gbanwee webụsaịtị gị site na ugboro abụọ ruo 10 ngwa ngwa.

Ọ bụrụ na ị nwere ajụjụ, nweere onwe gị ịhapụ ikwu okwu n'okpuru.

google peeji nke
Idenye aha
Gwa nke
1 Comment
Inline nzaghachi
Lee echiche niile

Ntuzi dị egwu, amaghị m maka ụdị ntọhapụ mbụ yana inwe ike iji nginx tinye ya.

1
0
Ga-ahụ n'anya gị echiche, biko okwu.x