(dv):Install mod pagespeed
- This page was last modified on May 10, 2012, at 12:50.
From (mt) Community Wiki
Contents |
Overview
mod_pagespeed is an Apache module that automatically optimizes Javascript, HTML, CSS, and images (JPG and PNG). See Google's summary for more information.
These changes are made dynamically as the page is being served, so they can be applied without having to modify your original code - convenient if you normally use a CMS to maintain your website.
- Link to Google's official download page: http://code.google.com/speed/page-speed/download.html
- (mt) Media Temple does not support the installation and configuration of software not installed at the time of service activation. Please consult our (dv) Scope of Support for further explanation.
- mod_pagespeed can increase your RAM consumption.
Requirements
- Enable root access.
- Install the Developer Tools.
- Install YUM if you haven't already. (dv) 4.0 have YUM already installed.
- Apache 2.2 or later - this is standard on the (dv) Dedicated-Virtual Server product line.
Instructions
- Log into your server with a root or sudo user via SSH.
- Install YUM if you haven't already. (dv) 4.0 have YUM already installed.
-
Install at
yum install at
- Install the mod_pagespeed RPM:
rpm -i https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm
- If you get the following error:
error: skipping https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm - transfer failed - Unknown or unexpected error
Perform the next steps. Otherwise, you can skip to the last two steps (restarting Apache).
-
Use wget to download the RPM:
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm
-
Import Google's key:
rpm --import http://dl.google.com/linux/linux_signing_key.pub
-
Install the RPM:
rpm -i mod-pagespeed-beta_current_x86_64.rpm
- Restart apache:
/etc/init.d/httpd restart
-
Test that mod_pagespeed is installed by creating a PHP Info page:
phpinfo.php
<?php phpinfo(); ?>
Upload this file to your domain, then navigate to it in your browser. Finally, search for "Pagespeed" using your browser's find function (CTRL-F) to see if mod_pagespeed has been installed successfully.
Under "HTTP Response Headers", you should see "X-Mod-Pagespeed".
Install from source (not recommended)
This install was preformed on a modified (dv) 3.5 running Plesk 9.5.3. Despite this, the below install process should be universal.
Requirements
- Root access enabled. For more information, please read: (dv):Enable root access.
- Developer Tools installed.
- SVN repository.
Install dependencies
1. You will need to download the required dependencies in order to install mod_pagespeed. Log into your server as root over SSH. Run the following commands:
yum groupinstall 'Web Server' yum install at subversion gcc-c++ gcc44
2. The Chromium depot tools are required to build mod_pagespeed. Run the following commands, via SSH, one at a time:
mkdir -p ~/bin cd ~/bin/ svn co http://src.chromium.org/svn/trunk/tools/depot_tools
3. Next, add Chromium depot tools to command line:
export PATH=$PATH:~/bin/depot_tools/
Compile mod_pagespeed
1. You will need to checkout mod_pagespeed from the Google Code SVN repository.
mkdir ~/mod_pagespeed cd ~/mod_pagespeed gclient config https://modpagespeed.googlecode.com/svn/trunk/src gclient update --force
2. Now, run the make command with the BUILDTYPE=Release flag.
cd ~/mod_pagespeed/src make BUILDTYPE=Release
3. Wait...
4. Install mod_pagespeed
cd install ./centos.sh staging
This should output something similar to:
+ exec make APACHE_CONTROL_PROGRAM=/etc/init.d/httpd APACHE_USER=apache APACHE_DOC_ROOT=/var/www/html staging
rm -rf /tmp/mod_pagespeed.install
mkdir -p /tmp/mod_pagespeed.install
sed -e s@HOSTNAME@example.com@g \
-e s@APACHE_DOC_ROOT@/var/www/html@g \
-e s@MOD_PAGESPEED_FILE_ROOT@/var/mod_pagespeed@g \
-e s@APACHE_MODULES@/etc/httpd/modules@g \
-e "s@SLURP_DIR_COMMAND@#ModPagespeedSlurpDirectory ...@g" \
-e "s@SLURP_READ_ONLY_COMMAND@#ModPagespeedSlurpReadOnly on@g" \
< pagespeed.conf.template > /tmp/mod_pagespeed.install/pagespeed.conf
sed -e s@HOSTNAME@example.com@g \
-e s@APACHE_DOC_ROOT@/var/www/html@g \
-e s@MOD_PAGESPEED_FILE_ROOT@/var/mod_pagespeed@g \
-e s@APACHE_MODULES@/etc/httpd/modules@g \
-e "s@SLURP_DIR_COMMAND@#ModPagespeedSlurpDirectory ...@g" \
-e "s@SLURP_READ_ONLY_COMMAND@#ModPagespeedSlurpReadOnly on@g" \
< proxy.conf.template > /tmp/mod_pagespeed.install/proxy.conf
echo "LoadModule pagespeed_module /etc/httpd/modules/mod_pagespeed.so" \
> /tmp/mod_pagespeed.install/pagespeed.load
echo "LoadModule deflate_module /etc/httpd/modules/mod_deflate.so" \
>> /tmp/mod_pagespeed.install/pagespeed.load
cp -rp mod_pagespeed_example /tmp/mod_pagespeed.install
cp ../out/Release/libmod_pagespeed.so /tmp/mod_pagespeed.install/mod_pagespeed.so
5. a. To preview which commands will be run by the install process:
./centos.sh -n install
b. If you are content with the output:
./centos.sh install
6. Restart Apache; within the same directory, the following command will restart your Apache server:
sudo ./centos.sh stop start
Attempting to run ./centos.sh test will result in a wget error. This can be bypassed by changing the following lines in system_test.sh:
$WGET --version | head -1 | grep 1.12 >/dev/null
to
$WGET --version | head -1 | grep 1.11 >/dev/null
The third test will fail, however.
Edit pagespeed.conf
1. Ensure that your ModPagespeedFileCachePath and ModPagespeedGeneratedFilePrefix are set to an writable directory:
vi /etc/httpd/conf.d/pagespeed.conf
2. Make the following changes:
ModPagespeedFileCachePath "/var/mod_pagespeed/cache/" ModPagespeedGeneratedFilePrefix "/var/mod_pagespeed/files/"
3. Create the directories:
mkdir /var/mod_pagespeed/ /var/mod_pagespeed/cache/ var/mod_pagespeed/files/