Benutzer-Werkzeuge

Webseiten-Werkzeuge


tachtler:apache_http_server_centos_7_-_mod_pagespeed_-_pagespeed_module

Apache HTTP Server CentOS 7 - mod_pagespeed - PageSpeed Module

Der Apache HTTP Server ist ein Open Source Webserver und der seit 1996 am meisten im Internet eingesetzte Webserver weltweit. Der freie und quell offenen Webserver wird von der Apache Software Foundation zur Verfügung gestellt und weiterentwickelt.

Um die im Apache HTTP Server verwendeten Ressourcen mit einem eindeutigem Hash-Wert im Dateinamen automatisiert zu versehen und dadurch

  • Bilder optimieren, komprimieren und skalieren
  • CSS & JavaScript optimierung
  • Cache-Erweiterung, Domain sharding und Domain rewriting
  • optimiertes Laden von JavaScript und Bildressourcen
  • uvm.

kann das Module

zum Einsatz kommen.

Ab hier werden root-Rechte zur Ausführung der nachfolgenden Befehle benötigt. Um root zu werden geben Sie bitte folgenden Befehl ein:

$ su -
Password: 

Herunterladen

Nachfolgend soll ein rpm-Paket unter nachfolgendem externen Link, mir nachfolgendem Befehl, heruntergeladen werden:

# wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm -P /tmp
--2018-03-02 10:40:03--  https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
Resolving dl-ssl.google.com (dl-ssl.google.com)... 66.102.1.93, 66.102.1.190, 66.102.1.136, ...
Connecting to dl-ssl.google.com (dl-ssl.google.com)|66.102.1.93|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7607004 (7.3M) [application/x-redhat-package-manager]
Saving to: ‘/tmp/mod-pagespeed-stable_current_x86_64.rpm’

100%[======================================>] 7,607,004   1.39MB/s   in 5.3s

2018-03-02 10:40:08 (1.38 MB/s) - ‘/tmp/mod-pagespeed-stable_current_x86_64.rpm’ saved [7607004/7607004]

Installation

Nachdem das rpm-Paket

erfolgreich heruntergeladen wurde, kann mit nachfolgendem Befehl, das rpm-Paket - httpd-mod_jk installiert werden:

# yum localinstall /tmp/mod-pagespeed-stable_current_x86_64.rpm
Loaded plugins: changelog, priorities
Examining mod-pagespeed-stable_current_x86_64.rpm: mod-pagespeed-stable-1.13.35.2-0.x86_64
Marking mod-pagespeed-stable_current_x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mod-pagespeed-stable.x86_64 0:1.13.35.2-0 will be installed
--> Processing Dependency: at for package: mod-pagespeed-stable-1.13.35.2-0.x86_64
--> Running transaction check
---> Package at.x86_64 0:3.1.13-22.el7_4.2 will be installed
--> Finished Dependency Resolution

Changes in packages about to be updated:


Dependencies Resolved

================================================================================
 Package    Arch   Version           Repository                            Size
================================================================================
Installing:
 mod-pagespeed-stable
            x86_64 1.13.35.2-0       /mod-pagespeed-stable_current_x86_64  21 M
Installing for dependencies:
 at         x86_64 3.1.13-22.el7_4.2 updates                               51 k

Transaction Summary
================================================================================
Install  1 Package (+1 Dependent package)

Total size: 21 M
Total download size: 51 k
Installed size: 21 M
Is this ok [y/d/N]: y
Downloading packages:
at-3.1.13-22.el7_4.2.x86_64.rpm                            |  51 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : at-3.1.13-22.el7_4.2.x86_64                                  1/2
  Installing : mod-pagespeed-stable-1.13.35.2-0.x86_64                      2/2
Redirecting to /bin/systemctl start atd.service
job 1 at Sat Mar  3 04:08:00 2018
  Verifying  : mod-pagespeed-stable-1.13.35.2-0.x86_64                      1/2
  Verifying  : at-3.1.13-22.el7_4.2.x86_64                                  2/2

Installed:
  mod-pagespeed-stable.x86_64 0:1.13.35.2-0

Dependency Installed:
  at.x86_64 0:3.1.13-22.el7_4.2

Complete!

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit den Paket httpd-mod_jk installiert wurden.

# rpm -qil mod-pagespeed-stable
Name        : mod-pagespeed-stable
Version     : 1.13.35.2
Release     : 0
Architecture: x86_64
Install Date: Sat 03 Mar 2018 04:06:18 AM CET
Group       : System Environment/Daemons
Size        : 21756729
License     : Apache Software License
Signature   : DSA/SHA1, Wed 31 Jan 2018 08:26:02 PM CET, Key ID a040830f7fac5991
Source RPM  : mod-pagespeed-stable-1.13.35.2-0.src.rpm
Build Date  : Thu 25 Jan 2018 10:40:52 PM CET
Build Host  : oschaaf-centos-6-35-mps-build.c.modpagespeed-162420.internal
Relocations : (not relocatable)
Packager    : mod_pagespeed developers <mod-pagespeed-dev@googlegroups.com>
Vendor      : Google Inc.
URL         : https://github.com/pagespeed/mod_pagespeed/
Summary     : Apache 2 module to optimize web content.
Description :
mod_pagespeed is an Apache module that aims to speed up load time of pages by applying web performance best
practices automatically.
/etc/cron.daily/mod-pagespeed
/etc/httpd/conf.d/pagespeed.conf
/etc/httpd/conf.d/pagespeed_libraries.conf
/usr/bin/pagespeed_js_minify
/usr/lib64/httpd/modules/mod_pagespeed.so
/usr/lib64/httpd/modules/mod_pagespeed_ap24.so
/var/cache/mod_pagespeed
/var/log/pagespeed

/etc/cron.daily/mod-pagespeed

Die Konfigurationsdatei

  • /etc/cron.daily/mod-pagespeed

bewirkt, dass eine Repository-Konfigurationsdatei für Paket-Updates erstellt wird, da dies während der mod-pagespeed-Installation nicht möglich ist, da das Repository zu diesem Zeitpunkt gesperrt ist.

Die so erzeugte Repository-Konfigurationsdatei befindet sich wie gewohnt in nachfolgendem Verzeichnis mit nachfolgendem Namen:

  • /etc/yum.repos.d/mod-pagespeed.repo

und hat nachfolgenden Inhalt:

[mod-pagespeed]
name=mod-pagespeed
baseurl=http://dl.google.com/linux/mod-pagespeed/rpm/stable/x86_64
enabled=1
gpgcheck=1

/var/cache/mod_pagespeed

Das neu erstelle Verzeichnis /var/cache/mod_pagespeed beinhaltet die „gecachten“ Dateien, welche zur Laufzeit erstellt werden.

/var/log/pagespeed

Das neu erstelle Verzeichnis /var/log/pagespeed beinhaltet die LOG-Dateien, welche zur Laufzeit erzeugt werden.

Konfiguration

/etc/httpd/conf.d/pagespeed.conf

Nachfolgende Konfigurationsdatei in nachfolgendem Verzeichnis mit nachfolgendem Namen

  • /etc/httpd/conf.d/pagespeed.conf

ist die Hauptkonfigurationsdatei und beinhaltet alle Direktiven an einem Ort um das Modul betreiben zu können:

# Attempt to load mod_version if it wasn't loaded or compiled in (eg on Debian)
<IfModule !mod_version.c>
  LoadModule version_module /usr/lib64/httpd/modules/mod_version.so
</IfModule>
 
<IfVersion < 2.4>
  LoadModule pagespeed_module /usr/lib64/httpd/modules/mod_pagespeed.so
</IfVersion>
<IfVersion >= 2.4.2>
  # As default pagespeed.conf configuration uses old-style ACLs using
  # 'allow' and 'deny', we load mod_access_compat in Apache 2.4. If that's a
  # problem, the blocks using that can be converted to the newer 'Require'
  # syntax.
  <IfModule !access_compat_module>
    LoadModule access_compat_module /usr/lib64/httpd/modules/mod_access_compat.so
  </IfModule>
 
  LoadModule pagespeed_module /usr/lib64/httpd/modules/mod_pagespeed_ap24.so
</IfVersion>
 
# Only attempt to load mod_deflate if it hasn't been loaded already.
<IfModule !mod_deflate.c>
 LoadModule deflate_module /usr/lib64/httpd/modules/mod_deflate.so
</IfModule>
<IfModule pagespeed_module>
    # Turn on mod_pagespeed. To completely disable mod_pagespeed, you
    # can set this to "off".
    ModPagespeed on
 
    # Direct Apache to send all HTML output to the mod_pagespeed
    # output handler.
    AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
 
    # If you want mod_pagespeed process XHTML as well, please uncomment this
    # line.
    # AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER application/xhtml+xml
 
    # The ModPagespeedFileCachePath directory must exist and be writable
    # by the apache user (as specified by the User directive).
    ModPagespeedFileCachePath            "/var/cache/mod_pagespeed/"
 
    # LogDir is needed to store various logs, including the statistics log
    # required for the console.
    ModPagespeedLogDir "/var/log/pagespeed"
 
    # The locations of SSL Certificates is distribution-dependent.
    ModPagespeedSslCertDirectory "/etc/pki/tls/certs"
    ModPagespeedSslCertFile /etc/pki/tls/cert.pem
 
    # If you want, you can use one or more memcached servers as the store for
    # the mod_pagespeed cache.
    # ModPagespeedMemcachedServers localhost:11211
 
    # A portion of the cache can be kept in memory only, to reduce load on disk
    # (or memcached) from many small files.
    # ModPagespeedCreateSharedMemoryMetadataCache "/var/cache/mod_pagespeed/" 51200
 
    # Override the mod_pagespeed 'rewrite level'. The default level
    # "CoreFilters" uses a set of rewrite filters that are generally
    # safe for most web pages. Most sites should not need to change
    # this value and can instead fine-tune the configuration using the
    # ModPagespeedDisableFilters and ModPagespeedEnableFilters
    # directives, below. Valid values for ModPagespeedRewriteLevel are
    # PassThrough, CoreFilters and TestingCoreFilters.
    #
    # ModPagespeedRewriteLevel PassThrough
 
    # Explicitly disables specific filters. This is useful in
    # conjuction with ModPagespeedRewriteLevel. For instance, if one
    # of the filters in the CoreFilters needs to be disabled for a
    # site, that filter can be added to
    # ModPagespeedDisableFilters. This directive contains a
    # comma-separated list of filter names, and can be repeated.
    #
    # ModPagespeedDisableFilters rewrite_images
 
    # Explicitly enables specific filters. This is useful in
    # conjuction with ModPagespeedRewriteLevel. For instance, filters
    # not included in the CoreFilters may be enabled using this
    # directive. This directive contains a comma-separated list of
    # filter names, and can be repeated.
    #
    # ModPagespeedEnableFilters rewrite_javascript,rewrite_css
    # ModPagespeedEnableFilters collapse_whitespace,elide_attributes
 
    # Explicitly forbids the enabling of specific filters using either query
    # parameters or request headers. This is useful, for example, when we do
    # not want the filter to run for performance or security reasons. This
    # directive contains a comma-separated list of filter names, and can be
    # repeated.
    #
    # ModPagespeedForbidFilters rewrite_images
 
    # How long mod_pagespeed will wait to return an optimized resource
    # (per flush window) on first request before giving up and returning the
    # original (unoptimized) resource. After this deadline is exceeded the
    # original resource is returned and the optimization is pushed to the
    # background to be completed for future requests. Increasing this value will
    # increase page latency, but might reduce load time (for instance on a
    # bandwidth-constrained link where it's worth waiting for image
    # compression to complete). If the value is less than or equal to zero
    # mod_pagespeed will wait indefinitely for the rewrite to complete before
    # returning.
    #
    # ModPagespeedRewriteDeadlinePerFlushMs 10
 
    # ModPagespeedDomain
    # authorizes rewriting of JS, CSS, and Image files found in this
    # domain. By default only resources with the same origin as the
    # HTML file are rewritten. For example:
    #
    #   ModPagespeedDomain cdn.myhost.com
    #
    # This will allow resources found on http://cdn.myhost.com to be
    # rewritten in addition to those in the same domain as the HTML.
    #
    # Other domain-related directives (like ModPagespeedMapRewriteDomain
    # and ModPagespeedMapOriginDomain) can also authorize domains.
    #
    # Wildcards (* and ?) are allowed in the domain specification. Be
    # careful when using them as if you rewrite domains that do not
    # send you traffic, then the site receiving the traffic will not
    # know how to serve the rewritten content.
 
    # If you use downstream caches such as varnish or proxy_cache for caching
    # HTML, you can configure pagespeed to work with these caches correctly
    # using the following directives. Note that the values for
    # ModPagespeedDownstreamCachePurgeLocationPrefix and
    # ModPagespeedDownstreamCacheRebeaconingKey are deliberately left empty here
    # in order to force the webmaster to choose appropriate value for these.
    #
    # ModPagespeedDownstreamCachePurgeLocationPrefix
    # ModPagespeedDownstreamCachePurgeMethod PURGE
    # ModPagespeedDownstreamCacheRewrittenPercentageThreshold 95
    # ModPagespeedDownstreamCacheRebeaconingKey
 
    # Other defaults (cache sizes and thresholds):
    #
    # ModPagespeedFileCacheSizeKb          102400
    # ModPagespeedFileCacheCleanIntervalMs 3600000
    # ModPagespeedLRUCacheKbPerProcess     1024
    # ModPagespeedLRUCacheByteLimit        16384
    # ModPagespeedCssFlattenMaxBytes       102400
    # ModPagespeedCssInlineMaxBytes        2048
    # ModPagespeedCssImageInlineMaxBytes   0
    # ModPagespeedImageInlineMaxBytes      3072
    # ModPagespeedJsInlineMaxBytes         2048
    # ModPagespeedCssOutlineMinBytes       3000
    # ModPagespeedJsOutlineMinBytes        3000
    # ModPagespeedMaxCombinedCssBytes      -1
    # ModPagespeedMaxCombinedJsBytes       92160
 
    # Limit the number of inodes in the file cache. Set to 0 for no limit.
    # The default value if this paramater is not specified is 0 (no limit).
    ModPagespeedFileCacheInodeLimit        500000
 
    # Bound the number of images that can be rewritten at any one time; this
    # avoids overloading the CPU.  Set this to -1 to remove the bound.
    #
    # ModPagespeedImageMaxRewritesAtOnce      8
 
    # You can also customize the number of threads per Apache process
    # mod_pagespeed will use to do resource optimization. Plain
    # "rewrite threads" are used to do short, latency-sensitive work,
    # while "expensive rewrite threads" are used for actual optimization
    # work that's more computationally expensive. If you live these unset,
    # or use values <= 0 the defaults will be used, which is 1 for both
    # values when using non-threaded MPMs (e.g. prefork) and 4 for both
    # on threaded MPMs (e.g. worker and event). These settings can only
    # be changed globally, and not per virtual host.
    #
    # ModPagespeedNumRewriteThreads 4
    # ModPagespeedNumExpensiveRewriteThreads 4
 
    # Randomly drop rewrites (*) to increase the chance of optimizing
    # frequently fetched resources and decrease the chance of optimizing
    # infrequently fetched resources. This can reduce CPU load. The default
    # value of this parameter is 0 (no drops).  90 means that a resourced
    # fetched once has a 10% probability of being optimized while a resource
    # that is fetched 50 times has a 99.65% probability of being optimized.
    #
    # (*) Currently only CSS files and images are randomly dropped.  Images
    # within CSS files are not randomly dropped.
    #
    # ModPagespeedRewriteRandomDropPercentage 90
 
    # Many filters modify the URLs of resources in HTML files. This is typically
    # harmless but pages whose Javascript expects to read or modify the original
    # URLs may break. The following parameters prevent filters from modifying
    # URLs of their respective types.
    #
    # ModPagespeedJsPreserveURLs on
    # ModPagespeedImagePreserveURLs on
    # ModPagespeedCssPreserveURLs on
 
    # When PreserveURLs is on, it is still possible to enable browser-specific
    # optimizations (for example, webp images can be served to browsers that
    # will accept them).  They'll be served with Vary: Accept or Vary:
    # User-Agent headers as appropriate.  Note that this may require configuring
    # reverse proxy caches such as varnish to handle these headers properly.
    #
    # ModPagespeedEnableFilters in_place_optimize_for_browser
 
    # Internet Explorer has difficulty caching resources with Vary: headers.
    # They will either be uncached (older IE) or require revalidation.  See:
    # http://blogs.msdn.com/b/ieinternals/archive/2009/06/17/vary-header-prevents-caching-in-ie.aspx
    # As a result we serve them as Cache-Control: private instead by default.
    # If you are using a reverse proxy or CDN configured to cache content with
    # the Vary: Accept header you should turn this setting off.
    #
    # ModPagespeedPrivateNotVaryForIE on
 
    # Settings for image optimization:
    #
    # Lossy image recompression quality (0 to 100, -1 just strips metadata):
    # ModPagespeedImageRecompressionQuality 85
    #
    # Jpeg recompression quality (0 to 100, -1 uses ImageRecompressionQuality):
    # ModPagespeedJpegRecompressionQuality -1
    # ModPagespeedJpegRecompressionQualityForSmallScreens 70
    #
    # WebP recompression quality (0 to 100, -1 uses ImageRecompressionQuality):
    # ModPagespeedWebpRecompressionQuality 80
    # ModPagespeedWebpRecompressionQualityForSmallScreens 70
    #
    # Timeout for conversions to WebP format, in
    # milliseconds. Negative values mean no timeout is applied. The
    # default value is -1:
    # ModPagespeedWebpTimeoutMs 5000
    #
    # Percent of original image size below which optimized images are retained:
    # ModPagespeedImageLimitOptimizedPercent 100
    #
    # Percent of original image area below which image resizing will be
    # attempted:
    # ModPagespeedImageLimitResizeAreaPercent 100
 
    # Settings for inline preview images
    #
    # Setting this to n restricts preview images to the first n images found on
    # the page.  The default of -1 means preview images can appear anywhere on
    # the page (if those images appear above the fold).
    # ModPagespeedMaxInlinedPreviewImagesIndex -1
 
    # Sets the minimum size in bytes of any image for which a low quality image
    # is generated.
    # ModPagespeedMinImageSizeLowResolutionBytes 3072
 
    # The maximum URL size is generally limited to about 2k characters
    # due to IE: See http://support.microsoft.com/kb/208427/EN-US.
    # Apache servers by default impose a further limitation of about
    # 250 characters per URL segment (text between slashes).
    # mod_pagespeed circumvents this limitation, but if you employ
    # proxy servers in your path you may need to re-impose it by
    # overriding the setting here.  The default setting is 1024
    # characters.
    #
    # ModPagespeedMaxSegmentLength 250
 
    # Uncomment this if you want to prevent mod_pagespeed from combining files
    # (e.g. CSS files) across paths
    #
    # ModPagespeedCombineAcrossPaths off
 
    # Renaming JavaScript URLs can sometimes break them.  With this
    # option enabled, mod_pagespeed uses a simple heuristic to decide
    # not to rename JavaScript that it thinks is introspective.
    #
    # You can uncomment this to let mod_pagespeed rename all JS files.
    #
    # ModPagespeedAvoidRenamingIntrospectiveJavascript off
 
    # Certain common JavaScript libraries are available from Google, which acts
    # as a CDN and allows you to benefit from browser caching if a new visitor
    # to your site previously visited another site that makes use of the same
    # libraries as you do.  Enable the following filter to turn on this feature.
    #
    # ModPagespeedEnableFilters canonicalize_javascript_libraries
 
    # The following line configures a library that is recognized by
    # canonicalize_javascript_libraries.  This will have no effect unless you
    # enable this filter (generally by uncommenting the last line in the
    # previous stanza).  The format is:
    #    ModPagespeedLibrary bytes md5 canonical_url
    # Where bytes and md5 are with respect to the *minified* JS; use
    # js_minify --print_size_and_hash to obtain this data.
    # Note that we can register multiple hashes for the same canonical url;
    # we do this if there are versions available that have already been minified
    # with more sophisticated tools.
    #
    # Additional library configuration can be found in
    # pagespeed_libraries.conf included in the distribution.  You should add
    # new entries here, though, so that file can be automatically upgraded.
    # ModPagespeedLibrary 43 1o978_K0_LNE5_ystNklf http://www.modpagespeed.com/rewrite_javascript.js
 
    # Explicitly tell mod_pagespeed to load some resources from disk.
    # This will speed up load time and update frequency.
    #
    # This should only be used for static resources which do not need
    # specific headers set or other processing by Apache.
    #
    # Both URL and filesystem path should specify directories and
    # filesystem path must be absolute (for now).
    #
    # ModPagespeedLoadFromFile "http://example.com/static/" "/var/www/static/"
 
 
    # Enables server-side instrumentation and statistics.  If this rewriter is
    # enabled, then each rewritten HTML page will have instrumentation javacript
    # added that sends latency beacons to /mod_pagespeed_beacon.  These
    # statistics can be accessed at /mod_pagespeed_statistics.  You must also
    # enable the mod_pagespeed_statistics and mod_pagespeed_beacon handlers
    # below.
    #
    # ModPagespeedEnableFilters add_instrumentation
 
    # The add_instrumentation filter sends a beacon after the page onload
    # handler is called. The user might navigate to a new URL before this. If
    # you enable the following directive, the beacon is sent as part of an
    # onbeforeunload handler, for pages where navigation happens before the
    # onload event.
    #
    # ModPagespeedReportUnloadTime on
 
    # Uncomment the following line so that ModPagespeed will not cache or
    # rewrite resources with Vary: in the header, e.g. Vary: User-Agent.
    # Note that ModPagespeed always respects Vary: headers on html content.
    # ModPagespeedRespectVary on
 
    # Uncomment the following line if you want to disable statistics entirely.
    #
    # ModPagespeedStatistics off
 
    # These handlers are central entry-points into the admin pages.
    # By default, pagespeed_admin and pagespeed_global_admin present
    # the same data, and differ only when
    # ModPagespeedUsePerVHostStatistics is enabled.  In that case,
    # /pagespeed_global_admin sees aggregated data across all vhosts,
    # and the /pagespeed_admin sees data only for a particular vhost.
    #
    # You may insert other "Allow from" lines to add hosts you want to
    # allow to look at generated statistics.  Another possibility is
    # to comment out the "Order" and "Allow" options from the config
    # file, to allow any client that can reach your server to access
    # and change server state, such as statistics, caches, and
    # messages.  This might be appropriate in an experimental setup.
    <Location /pagespeed_admin>
        Order allow,deny
        Allow from localhost
        Allow from 127.0.0.1
        SetHandler pagespeed_admin
    </Location>
    <Location /pagespeed_global_admin>
        Order allow,deny
        Allow from localhost
        Allow from 127.0.0.1
        SetHandler pagespeed_global_admin
    </Location>
 
    # Enable logging of mod_pagespeed statistics, needed for the console.
    ModPagespeedStatisticsLogging on
 
    # Page /mod_pagespeed_message lets you view the latest messages from
    # mod_pagespeed, regardless of log-level in your httpd.conf
    # ModPagespeedMessageBufferSize is the maximum number of bytes you would
    # like to dump to your /mod_pagespeed_message page at one time,
    # its default value is 100k bytes.
    # Set it to 0 if you want to disable this feature.
    ModPagespeedMessageBufferSize 100000
</IfModule>

Anschließend sollte nachfolgender Inhalt in die Konfigurationsdatei - /etc/httpd/conf.d/pagespeed.conf - wie nachfolgend dargestellt angepasst werden:

# Attempt to load mod_version if it wasn't loaded or compiled in (eg on Debian)
<IfModule !mod_version.c>
  LoadModule version_module /usr/lib64/httpd/modules/mod_version.so
</IfModule>
 
<IfVersion < 2.4>
  LoadModule pagespeed_module /usr/lib64/httpd/modules/mod_pagespeed.so
</IfVersion>
<IfVersion >= 2.4.2>
  # As default pagespeed.conf configuration uses old-style ACLs using
  # 'allow' and 'deny', we load mod_access_compat in Apache 2.4. If that's a
  # problem, the blocks using that can be converted to the newer 'Require'
  # syntax.
  <IfModule !access_compat_module>
    LoadModule access_compat_module /usr/lib64/httpd/modules/mod_access_compat.so
  </IfModule>
 
  LoadModule pagespeed_module /usr/lib64/httpd/modules/mod_pagespeed_ap24.so
</IfVersion>
 
# Only attempt to load mod_deflate if it hasn't been loaded already.
<IfModule !mod_deflate.c>
 LoadModule deflate_module /usr/lib64/httpd/modules/mod_deflate.so
</IfModule>
 
# Tachtler - DISABLED - Moved to VHOST configuration!
<IfModule pagespeed_module>
    # Turn on mod_pagespeed. To completely disable mod_pagespeed, you
    # can set this to "off".
    # Tachtler
    # default:  ModPagespeed on
    ModPagespeed off
 
 
    # Direct Apache to send all HTML output to the mod_pagespeed
    # output handler.
    # AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
 
    # If you want mod_pagespeed process XHTML as well, please uncomment this
    # line.
    # AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER application/xhtml+xml
 
    # The ModPagespeedFileCachePath directory must exist and be writable
    # by the apache user (as specified by the User directive).
    # ModPagespeedFileCachePath            "/var/cache/mod_pagespeed/"
 
    # LogDir is needed to store various logs, including the statistics log
    # required for the console.
    # ModPagespeedLogDir "/var/log/pagespeed"
 
    # The locations of SSL Certificates is distribution-dependent.
    # ModPagespeedSslCertDirectory "/etc/pki/tls/certs"
    # ModPagespeedSslCertFile /etc/pki/tls/cert.pem
 
    # If you want, you can use one or more memcached servers as the store for
    # the mod_pagespeed cache.
    # ModPagespeedMemcachedServers localhost:11211
 
    # A portion of the cache can be kept in memory only, to reduce load on disk
    # (or memcached) from many small files.
    # ModPagespeedCreateSharedMemoryMetadataCache "/var/cache/mod_pagespeed/" 51200
 
    # Override the mod_pagespeed 'rewrite level'. The default level
    # "CoreFilters" uses a set of rewrite filters that are generally
    # safe for most web pages. Most sites should not need to change
    # this value and can instead fine-tune the configuration using the
    # ModPagespeedDisableFilters and ModPagespeedEnableFilters
    # directives, below. Valid values for ModPagespeedRewriteLevel are
    # PassThrough, CoreFilters and TestingCoreFilters.
    #
    # ModPagespeedRewriteLevel PassThrough
 
    # Explicitly disables specific filters. This is useful in
    # conjuction with ModPagespeedRewriteLevel. For instance, if one
    # of the filters in the CoreFilters needs to be disabled for a
    # site, that filter can be added to
    # ModPagespeedDisableFilters. This directive contains a
    # comma-separated list of filter names, and can be repeated.
    #
    # ModPagespeedDisableFilters rewrite_images
 
    # Explicitly enables specific filters. This is useful in
    # conjuction with ModPagespeedRewriteLevel. For instance, filters
    # not included in the CoreFilters may be enabled using this
    # directive. This directive contains a comma-separated list of
    # filter names, and can be repeated.
    #
    # ModPagespeedEnableFilters rewrite_javascript,rewrite_css
    # ModPagespeedEnableFilters collapse_whitespace,elide_attributes
 
    # Explicitly forbids the enabling of specific filters using either query
    # parameters or request headers. This is useful, for example, when we do
    # not want the filter to run for performance or security reasons. This
    # directive contains a comma-separated list of filter names, and can be
    # repeated.
    #
    # ModPagespeedForbidFilters rewrite_images
 
    # How long mod_pagespeed will wait to return an optimized resource
    # (per flush window) on first request before giving up and returning the
    # original (unoptimized) resource. After this deadline is exceeded the
    # original resource is returned and the optimization is pushed to the
    # background to be completed for future requests. Increasing this value will
    # increase page latency, but might reduce load time (for instance on a
    # bandwidth-constrained link where it's worth waiting for image
    # compression to complete). If the value is less than or equal to zero
    # mod_pagespeed will wait indefinitely for the rewrite to complete before
    # returning.
    #
    # ModPagespeedRewriteDeadlinePerFlushMs 10
 
    # ModPagespeedDomain
    # authorizes rewriting of JS, CSS, and Image files found in this
    # domain. By default only resources with the same origin as the
    # HTML file are rewritten. For example:
    #
    #   ModPagespeedDomain cdn.myhost.com
    #
    # This will allow resources found on http://cdn.myhost.com to be
    # rewritten in addition to those in the same domain as the HTML.
    #
    # Other domain-related directives (like ModPagespeedMapRewriteDomain
    # and ModPagespeedMapOriginDomain) can also authorize domains.
    #
    # Wildcards (* and ?) are allowed in the domain specification. Be
    # careful when using them as if you rewrite domains that do not
    # send you traffic, then the site receiving the traffic will not
    # know how to serve the rewritten content.
 
    # If you use downstream caches such as varnish or proxy_cache for caching
    # HTML, you can configure pagespeed to work with these caches correctly
    # using the following directives. Note that the values for
    # ModPagespeedDownstreamCachePurgeLocationPrefix and
    # ModPagespeedDownstreamCacheRebeaconingKey are deliberately left empty here
    # in order to force the webmaster to choose appropriate value for these.
    #
    # ModPagespeedDownstreamCachePurgeLocationPrefix
    # ModPagespeedDownstreamCachePurgeMethod PURGE
    # ModPagespeedDownstreamCacheRewrittenPercentageThreshold 95
    # ModPagespeedDownstreamCacheRebeaconingKey
 
    # Other defaults (cache sizes and thresholds):
    #
    # ModPagespeedFileCacheSizeKb          102400
    # ModPagespeedFileCacheCleanIntervalMs 3600000
    # ModPagespeedLRUCacheKbPerProcess     1024
    # ModPagespeedLRUCacheByteLimit        16384
    # ModPagespeedCssFlattenMaxBytes       102400
    # ModPagespeedCssInlineMaxBytes        2048
    # ModPagespeedCssImageInlineMaxBytes   0
    # ModPagespeedImageInlineMaxBytes      3072
    # ModPagespeedJsInlineMaxBytes         2048
    # ModPagespeedCssOutlineMinBytes       3000
    # ModPagespeedJsOutlineMinBytes        3000
    # ModPagespeedMaxCombinedCssBytes      -1
    # ModPagespeedMaxCombinedJsBytes       92160
 
    # Limit the number of inodes in the file cache. Set to 0 for no limit.
    # The default value if this paramater is not specified is 0 (no limit).
    # ModPagespeedFileCacheInodeLimit        500000
 
    # Bound the number of images that can be rewritten at any one time; this
    # avoids overloading the CPU.  Set this to -1 to remove the bound.
    #
    # ModPagespeedImageMaxRewritesAtOnce      8
 
    # You can also customize the number of threads per Apache process
    # mod_pagespeed will use to do resource optimization. Plain
    # "rewrite threads" are used to do short, latency-sensitive work,
    # while "expensive rewrite threads" are used for actual optimization
    # work that's more computationally expensive. If you live these unset,
    # or use values <= 0 the defaults will be used, which is 1 for both
    # values when using non-threaded MPMs (e.g. prefork) and 4 for both
    # on threaded MPMs (e.g. worker and event). These settings can only
    # be changed globally, and not per virtual host.
    #
    # ModPagespeedNumRewriteThreads 4
    # ModPagespeedNumExpensiveRewriteThreads 4
 
    # Randomly drop rewrites (*) to increase the chance of optimizing
    # frequently fetched resources and decrease the chance of optimizing
    # infrequently fetched resources. This can reduce CPU load. The default
    # value of this parameter is 0 (no drops).  90 means that a resourced
    # fetched once has a 10% probability of being optimized while a resource
    # that is fetched 50 times has a 99.65% probability of being optimized.
    #
    # (*) Currently only CSS files and images are randomly dropped.  Images
    # within CSS files are not randomly dropped.
    #
    # ModPagespeedRewriteRandomDropPercentage 90
 
    # Many filters modify the URLs of resources in HTML files. This is typically
    # harmless but pages whose Javascript expects to read or modify the original
    # URLs may break. The following parameters prevent filters from modifying
    # URLs of their respective types.
    #
    # ModPagespeedJsPreserveURLs on
    # ModPagespeedImagePreserveURLs on
    # ModPagespeedCssPreserveURLs on
 
    # When PreserveURLs is on, it is still possible to enable browser-specific
    # optimizations (for example, webp images can be served to browsers that
    # will accept them).  They'll be served with Vary: Accept or Vary:
    # User-Agent headers as appropriate.  Note that this may require configuring
    # reverse proxy caches such as varnish to handle these headers properly.
    #
    # ModPagespeedEnableFilters in_place_optimize_for_browser
 
    # Internet Explorer has difficulty caching resources with Vary: headers.
    # They will either be uncached (older IE) or require revalidation.  See:
    # http://blogs.msdn.com/b/ieinternals/archive/2009/06/17/vary-header-prevents-caching-in-ie.aspx
    # As a result we serve them as Cache-Control: private instead by default.
    # If you are using a reverse proxy or CDN configured to cache content with
    # the Vary: Accept header you should turn this setting off.
    #
    # ModPagespeedPrivateNotVaryForIE on
 
    # Settings for image optimization:
    #
    # Lossy image recompression quality (0 to 100, -1 just strips metadata):
    # ModPagespeedImageRecompressionQuality 85
    #
    # Jpeg recompression quality (0 to 100, -1 uses ImageRecompressionQuality):
    # ModPagespeedJpegRecompressionQuality -1
    # ModPagespeedJpegRecompressionQualityForSmallScreens 70
    #
    # WebP recompression quality (0 to 100, -1 uses ImageRecompressionQuality):
    # ModPagespeedWebpRecompressionQuality 80
    # ModPagespeedWebpRecompressionQualityForSmallScreens 70
    #
    # Timeout for conversions to WebP format, in
    # milliseconds. Negative values mean no timeout is applied. The
    # default value is -1:
    # ModPagespeedWebpTimeoutMs 5000
    #
    # Percent of original image size below which optimized images are retained:
    # ModPagespeedImageLimitOptimizedPercent 100
    #
    # Percent of original image area below which image resizing will be
    # attempted:
    # ModPagespeedImageLimitResizeAreaPercent 100
 
    # Settings for inline preview images
    #
    # Setting this to n restricts preview images to the first n images found on
    # the page.  The default of -1 means preview images can appear anywhere on
    # the page (if those images appear above the fold).
    # ModPagespeedMaxInlinedPreviewImagesIndex -1
 
    # Sets the minimum size in bytes of any image for which a low quality image
    # is generated.
    # ModPagespeedMinImageSizeLowResolutionBytes 3072
 
    # The maximum URL size is generally limited to about 2k characters
    # due to IE: See http://support.microsoft.com/kb/208427/EN-US.
    # Apache servers by default impose a further limitation of about
    # 250 characters per URL segment (text between slashes).
    # mod_pagespeed circumvents this limitation, but if you employ
    # proxy servers in your path you may need to re-impose it by
    # overriding the setting here.  The default setting is 1024
    # characters.
    #
    # ModPagespeedMaxSegmentLength 250
 
    # Uncomment this if you want to prevent mod_pagespeed from combining files
    # (e.g. CSS files) across paths
    #
    # ModPagespeedCombineAcrossPaths off
 
    # Renaming JavaScript URLs can sometimes break them.  With this
    # option enabled, mod_pagespeed uses a simple heuristic to decide
    # not to rename JavaScript that it thinks is introspective.
    #
    # You can uncomment this to let mod_pagespeed rename all JS files.
    #
    # ModPagespeedAvoidRenamingIntrospectiveJavascript off
 
    # Certain common JavaScript libraries are available from Google, which acts
    # as a CDN and allows you to benefit from browser caching if a new visitor
    # to your site previously visited another site that makes use of the same
    # libraries as you do.  Enable the following filter to turn on this feature.
    #
    # ModPagespeedEnableFilters canonicalize_javascript_libraries
 
    # The following line configures a library that is recognized by
    # canonicalize_javascript_libraries.  This will have no effect unless you
    # enable this filter (generally by uncommenting the last line in the
    # previous stanza).  The format is:
    #    ModPagespeedLibrary bytes md5 canonical_url
    # Where bytes and md5 are with respect to the *minified* JS; use
    # js_minify --print_size_and_hash to obtain this data.
    # Note that we can register multiple hashes for the same canonical url;
    # we do this if there are versions available that have already been minified
    # with more sophisticated tools.
    #
    # Additional library configuration can be found in
    # pagespeed_libraries.conf included in the distribution.  You should add
    # new entries here, though, so that file can be automatically upgraded.
    # ModPagespeedLibrary 43 1o978_K0_LNE5_ystNklf http://www.modpagespeed.com/rewrite_javascript.js
 
    # Explicitly tell mod_pagespeed to load some resources from disk.
    # This will speed up load time and update frequency.
    #
    # This should only be used for static resources which do not need
    # specific headers set or other processing by Apache.
    #
    # Both URL and filesystem path should specify directories and
    # filesystem path must be absolute (for now).
    #
    # ModPagespeedLoadFromFile "http://example.com/static/" "/var/www/static/"
 
 
    # Enables server-side instrumentation and statistics.  If this rewriter is
    # enabled, then each rewritten HTML page will have instrumentation javacript
    # added that sends latency beacons to /mod_pagespeed_beacon.  These
    # statistics can be accessed at /mod_pagespeed_statistics.  You must also
    # enable the mod_pagespeed_statistics and mod_pagespeed_beacon handlers
    # below.
    #
    # ModPagespeedEnableFilters add_instrumentation
 
    # The add_instrumentation filter sends a beacon after the page onload
    # handler is called. The user might navigate to a new URL before this. If
    # you enable the following directive, the beacon is sent as part of an
    # onbeforeunload handler, for pages where navigation happens before the
    # onload event.
    #
    # ModPagespeedReportUnloadTime on
 
    # Uncomment the following line so that ModPagespeed will not cache or
    # rewrite resources with Vary: in the header, e.g. Vary: User-Agent.
    # Note that ModPagespeed always respects Vary: headers on html content.
    # ModPagespeedRespectVary on
 
    # Uncomment the following line if you want to disable statistics entirely.
    #
    # ModPagespeedStatistics off
 
    # These handlers are central entry-points into the admin pages.
    # By default, pagespeed_admin and pagespeed_global_admin present
    # the same data, and differ only when
    # ModPagespeedUsePerVHostStatistics is enabled.  In that case,
    # /pagespeed_global_admin sees aggregated data across all vhosts,
    # and the /pagespeed_admin sees data only for a particular vhost.
    #
    # You may insert other "Allow from" lines to add hosts you want to
    # allow to look at generated statistics.  Another possibility is
    # to comment out the "Order" and "Allow" options from the config
    # file, to allow any client that can reach your server to access
    # and change server state, such as statistics, caches, and
    # messages.  This might be appropriate in an experimental setup.
    #<Location /pagespeed_admin>
    #    Order allow,deny
    #    Allow from localhost
    #    Allow from 127.0.0.1
    #    SetHandler pagespeed_admin
    #</Location>
    #<Location /pagespeed_global_admin>
    #    Order allow,deny
    #    Allow from localhost
    #    Allow from 127.0.0.1
    #    SetHandler pagespeed_global_admin
    #</Location>
 
    # Enable logging of mod_pagespeed statistics, needed for the console.
    # ModPagespeedStatisticsLogging on
 
    # Page /mod_pagespeed_message lets you view the latest messages from
    # mod_pagespeed, regardless of log-level in your httpd.conf
    # ModPagespeedMessageBufferSize is the maximum number of bytes you would
    # like to dump to your /mod_pagespeed_message page at one time,
    # its default value is 100k bytes.
    # Set it to 0 if you want to disable this feature.
    # ModPagespeedMessageBufferSize 100000
</IfModule>
* Dies ist nur eine Beispielkonfiguration.

Erläuterung der Änderung:

  •     # Tachtler
        # default:  ModPagespeed on
        ModPagespeed off

Deaktivieren der globalen Anwendung des Moduls.

:!: WICHTIG - Alle Konfigurationen sollen in ein VHOST vorgenommen werden und nur auch für diesen gelten! - Siehe auch nachfolgenen internen Link:

:!: HINWEIS - Die Bedeutung der einzelnen Befehle kann in der Dokumentation PageSpeed Modules - PageSpeed Configuration detailliert nachgelesen werden.

/etc/httpd/conf.d/pagespeed_libraries.conf

Nachfolgende Konfigurationsdatei in nachfolgendem Verzeichnis mit nachfolgendem Namen

  • /etc/httpd/conf.d/pagespeed_libraries.conf

ist eine Sammlung von gängigen Bibliotheken im WEB-Umfeld, welche durch das Modul verwendet werden

:!: HINWEIS - Diese Konfigurationsdatei wird automatisiert generiert. Es wird während eines Updates von PageSpeed Modules durch den rpm-Paket-Manager auf dem neuesten Stand gehalten, wenn die Datei NICHT bearbeiten wird !!!.

:!: HINWEIS - Zusätzliche Inhalte für die ModpagespeedLibrary-Einträge können in der Konfigurationsdatei

  • /etc/httpd/conf.d/pagespeed.conf

hinzugefügt werden, anstatt diese hier, in der Konfigurationsdatei /etc/httpd/conf.d/pagespeed_libraries.conf einzufügen.

:!: WICHTIG - Diese Datei sollte nur bearbeitet werden, wenn die Standardeinträge geändern oder deaktivieren werden sollen. Um alle Einträge zu deaktivieren, kann einfach der Parameter

  • canonicalize_javascript_libraries

in der Konfigurationsdatei

  • /etc/httpd/conf.d/pagespeed.conf

deaktiviert werden!

/etc/httpd/conf.d/vhost.conf

Falls kein virtueller Host definiert ist, können folgende Konfigurationsangaben ebenfalls in der Datei /etc/httpd/conf/httpd.conf definiert werden.

:!: WICHTIG - Nachfolgende Konfiguration DEAKTIVIERT die inhaltliche Optimierung von css- und js-Dateien!

:!: HINWEIS - Dies kann erforderlich sein, falls eine CSS/JS-Framework zu Einsatz kommt!

Nachfolgend ein Beispiel für einen virtuellen Host:

#
# www.tachtler.net (Homepage)
#
<VirtualHost *:80>
        ServerAdmin webmaster@tachtler.net
        ServerName www.tachtler.net
        ServerAlias www.tachtler.net
        ServerPath /
 
        DocumentRoot "/var/www/html"
        <Directory "/var/www/html">
                Options -Indexes +FollowSymLinks
                # Tachtler (enable for .htaccess file support)
                # AllowOverride AuthConfig
                AllowOverride None
                # Tachtler (enable for unlimited access)
                Require all granted
        </Directory>
 
        # Tachtler
        # ----------------------------------------------------------
        # Implement caching capabilities by using mod_expire module
        # to speed up the page with specified max-age by resources.
        # ----------------------------------------------------------
        <IfModule expires_module>
                # Tachtler (Cache-Control: max-age: 5 minutes (300))
                <FilesMatch "\.(js)$">
                        #Header set Cache-Control "public, max-age=300"
                        ExpiresActive On
                        ExpiresDefault "access plus 5 minutes"
                        ExpiresByType text/javascript "access plus 5 minutes"
                        ExpiresByType application/javascript "access plus 5 minutes"
                        ExpiresByType application/x-javascript "access plus 5 minutes"
                </FilesMatch>
                # Tachtler (Cache-Control: max-age: 1 week (604800))
                <FilesMatch "\.(css)$">
                        #Header set Cache-Control "public, max-age=604800"
                        ExpiresActive On
                        ExpiresDefault "access plus 1 week"
                        ExpiresByType text/css "access plus 1 week"
                </FilesMatch>
                # Tachtler (Cache-Control: max-age: 1 mount (2628000))
                <FilesMatch "\.(ico|png)$">
                        #Header set Cache-Control "public, max-age=2628000"
                        ExpiresActive On
                        ExpiresDefault "access plus 1 months"
                        ExpiresByType image/x-icon "access plus 1 month"
                        ExpiresByType image/png "access plus 1 months"
                </FilesMatch>
        </IfModule>
 
        # Tachtler
        # ----------------------------------------------------------
        # Implement caching capabilities by using the mod_pagespeed
        # module to speed up the page.
        # ----------------------------------------------------------
        <IfModule pagespeed_module>
                # Turn on mod_pagespeed. To completely disable mod_pagespeed, you
                # can set this to "off", or use "standby".
                ModPagespeed On
                # Direct Apache to send all HTML output to the mod_pagespeed
                # output handler.
                AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
                # The ModPagespeedFileCachePath directory must exist and be writable
                # by the apache user (as specified by the User directive).
                ModPagespeedFileCachePath "/var/cache/mod_pagespeed/"
                # LogDir is needed to store various logs, including the statistics log
                # required for the console.
                ModPagespeedLogDir "/var/log/pagespeed"
                # The locations of SSL Certificates is distribution-dependent.
                ModPagespeedSslCertDirectory "/etc/pki/tls/certs"
                ModPagespeedSslCertFile ${varSSLCertificateFile}
                # Override the mod_pagespeed 'rewrite level'. The default level
                # "CoreFilters" uses a set of rewrite filters that are generally
                # safe for most web pages. Most sites should not need to change
                # this value and can instead fine-tune the configuration using the
                # ModPagespeedDisableFilters and ModPagespeedEnableFilters
                # directives, below. Valid values for ModPagespeedRewriteLevel are
                # PassThrough, CoreFilters and TestingCoreFilters.
                # Tachtler
                # DEFAULT "CoreFilters":
                # add_head
                # combine_css
                # combine_javascript
                # convert_meta_tags
                # extend_cache
                # fallback_rewrite_css_urls
                # flatten_css_imports
                # inline_css
                # line_import_to_link
                # line_javascript
                # rewrite_css
                # rewrite_images
                # rewrite_javascript
                # rewrite_style_attributes_with_url
                ModPagespeedRewriteLevel PassThrough
                # Explicitly disables specific filters. This is useful in
                # conjuction with ModPagespeedRewriteLevel. For instance, if one
                # of the filters in the CoreFilters needs to be disabled for a
                # site, that filter can be added to
                # ModPagespeedDisableFilters. This directive contains a
                # comma-separated list of filter names, and can be repeated.
                # ModPagespeedDisableFilters rewrite_images
                # Explicitly enables specific filters. This is useful in
                # conjuction with ModPagespeedRewriteLevel. For instance, filters
                # not included in the CoreFilters may be enabled using this
                # directive. This directive contains a comma-separated list of
                # filter names, and can be repeated.
                ModPagespeedEnableFilters add_head,extend_cache,fallback_rewrite_css_urls,rewrite_images
                # Limit the number of inodes in the file cache. Set to 0 for no limit.
                # The default value if this paramater is not specified is 0 (no limit).
                ModPagespeedFileCacheInodeLimit 500000
                # Enable logging of mod_pagespeed statistics, needed for the console.
                ModPagespeedStatisticsLogging on
                # Tachtler
                ModPagespeedFetchHttps enable
                ModPagespeedDomain https://www.tachtler.net
                ModPagespeedLoadFromFileMatch "^https?://www.tachtler.net/" "/var/www/homepage/"
                ModPagespeedLoadFromFileRuleMatch Disallow .*
                ModPagespeedLoadFromFileRuleMatch Allow \.js$
                ModPagespeedLoadFromFileRuleMatch Allow \.css$
                ModPagespeedLoadFromFileRuleMatch Allow \.ico$
                ModPagespeedLoadFromFileRuleMatch Allow \.png$
        </IfModule>
 
        DirectoryIndex index.htm index.jsp
 
        ErrorLog logs/homepage_error.log
        SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
        CustomLog logs/homepage_access.log combined env=!forwarded
        CustomLog logs/homepage_access.log combined_proxypass env=forwarded
</VirtualHost>
* Dies ist nur eine Beispielkonfiguration.

:!: FIXME :!:

:!: Hier geht es weiter… | To be continued…

Cookies helfen bei der Bereitstellung von Inhalten. Durch die Nutzung dieser Seiten erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Rechner gespeichert werden. Weitere Information
tachtler/apache_http_server_centos_7_-_mod_pagespeed_-_pagespeed_module.txt · Zuletzt geändert: 2018/03/07 17:17 von klaus