From mod_pagespeed’s docs, I quote:
mod_pagespeed is an open-source Apache module that automatically optimizes web pages and resources on them. It does this by rewriting the resources using filters that implement web performance best practices. Webmasters and web developers can use mod_pagespeed to improve the performance of their web pages when serving content with the Apache HTTP Server.
mod_pagespeed includes several filter that optimize JavaScript, HTML and CSS stylesheets. It also includes filters for optimizing JPEG and PNG images. The filters are based on a set of best practices known to enhance web page performance. Webmasters who set up mod_pagespeed in addition to configuring proper caching and compression on their Apache distribution should expect to see an improvement in the loading time of the pages on their websites.
Sounds interesting. Mod_pagespeed is brand new, and running it with Apache on a Cpanel server is a very easy task. While you can follow the instructions mentioned here to build from source, you can also use the binary.
But then, it fails to install correctly on a Cpanel server as it requires httpd package. Still, we can extract the files from the binary and copy it over to the necessary paths to get it up and running in a few minutes time 🙂 This is how I did it on a Apache v2.2 + CPanel server running on CentOS 5.5 (32-bit):
[root@server2 ~]# cd /usr/src [root@server2 src]# wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_i386.rpm [root@server2 src]# mkdir mod-pagespeed [root@server2 src]# cd mod-pagespeed [root@server2 mod-pagespeed]# rpm2cpio ../mod-pagespeed-beta_current_i386.rpm | cpio -idmv ./etc/cron.daily/mod-pagespeed ./etc/httpd/conf.d/pagespeed.conf ./usr/lib/httpd/modules/mod_pagespeed.so ./var/mod_pagespeed/cache ./var/mod_pagespeed/files 3135 blocks [root@server2 mod-pagespeed]# cp ./etc/httpd/conf.d/pagespeed.conf /usr/local/apache/conf/ [root@server2 mod-pagespeed]# cp ./usr/lib/httpd/modules/mod_pagespeed.so /usr/local/apache/modules/ [root@server2 mod-pagespeed]# chmod 755 /usr/local/apache/modules/mod_pagespeed.so [root@server2 mod-pagespeed]# mkdir /var/mod_pagespeed/{cache,files} -p [root@server2 mod-pagespeed]# chown nobody:nobody /var/mod_pagespeed/*
Mod_pagespeed needs mod_deflate to be loaded in Apache. If it is not yet installed, you can just include the same from apache source, like:
[root@server2 mod-pagespeed]# /usr/local/apache/bin/apxs -c -i
/home/cpeasyapache/src/httpd-2.2.14/modules/filters/mod_deflate.c
Now, edit /usr/local/apache/conf/pagespeed.conf and change the LoadModule lines to point to these paths:
LoadModule pagespeed_module modules/mod_pagespeed.so
# Only attempt to load mod_deflate if it hasn’t been loaded already.
<IfModule !mod_deflate.c>
LoadModule deflate_module modules/mod_deflate.so
And finally, include pagespeed.conf in /usr/local/apache/conf/httpd.conf:
Include “conf/pagespeed.conf”
and then restart apache:
[root@server2 mod-pagespeed]# service httpd restart
If everything is fine, apache will start normally and as your domains begin to get hits, you will see data being written in to /var/mod_pagespeed/*. Just a reminder that this module seems to write a lot of data in apache error log. You might need to monitor the server load and i/o stats for some time to ensure that everything is stable.
NOTE: The above guide is strictly for 32-bit servers. If you are running on 64-bit, then you need the 64-bit package (.rpm). Please check the comments section for its url.
Hello!
I tried the above, but I try to restart apache, I get:
httpd: Syntax error on line 4 of /usr/local/apache/conf/httpd.conf: Syntax error on line 1 of /usr/local/apache/conf/pagespeed.conf: Cannot load /usr/local/apache/modules/mod_pagespeed.so into server: /usr/local/apache/modules/mod_pagespeed.so: requires glibc 2.5 or later dynamic linker
Any suggestions?
@Yannis Check your glibc package version and upgrade if necessary.., it should fix this issue
This is the error I get
httpd: Syntax error on line 42 of /usr/local/apache/conf/httpd.conf: Syntax error on line 1 of /usr/local/apache/conf/pagespeed.conf: Cannot load /usr/local/apache/modules/mod_pagespeed.so into server: /usr/local/apache/modules/mod_pagespeed.so: wrong ELF class: ELFCLASS32
@Chirag, You are trying to use 32-bit rpm on your 64-bit machine.. You need to get 64-bit rpm
Just a note to say that these instructions are 32 bit only.
@Auser, thanks for reminding.. I am adding this info in a few minutes..
https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_x86_64.rpm for 64 bit. Repeat the same but with this file. Should have added this in with my last comment.
Hello,
First great howto but it seems that this don`t work on my end because I think the configuration is wrong.
Can you give us the full content of your pagespeed.conf
Because i can`t get this working with my cpanel server.
The module is installed and it`s seems that it`s loaded but it`s not configured correctly i think.
Please share with us how you configure yours.
Best regards,
Hristofor Georgiev
System Administrator
SkyIT Ltd.
@Hristofor, I did not make any further change in pagespeed.conf other than the two lines that I mentioned in my doc.
how do we upgrade glibc? is it safe to upgrade?
@Yannis, Upgrading glibc should be safe
Hello,
I try this howto again but this don`t work again I have cpanel server with around 100 sites on it but when i run this module nothing is happening the cache folder is empty and the files folder is empty too also the statistics doesn`t show anything.
Are sure that this module is working on your end ?
Regards,
Hristofor Georgiev
@Hristofor, What exactly is not working?
[…] I have also found a nice installation instruction for cpanel server here […]
Hi Admin,
It`s not working at all. There is no files in the cashe or files folder no info in the statistics page.
I think it don`t work at all.
@Hristofor, Is apache starting after you make the changes? Any errors you notice in /usr/local/apache/logs/error_log? I am more than glad to help you in getting this working, but I need some more info as to what exactly is wrong.. Perhaps the info I asked for is a perfect way to start 🙂
Mod_pagespeed is an AWESOME idea. I know that it works on a base CentOS box fine. I am now trying to get this to work on a Cpanel server as well.
I really appreciate the article. I am however having an issue with site loads after doing this.
In Firefox I get the following error now when visiting my test site:
The connection has timed out
The server at ssl.64bitsmartermail.com is taking too long to respond.
If I look at the /usr/local/apache/logs/error_log I see the following last lines:
[Fri Nov 12 07:02:44 2010] [notice] suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
[Fri Nov 12 07:02:44 2010] [notice] ModSecurity for Apache/2.5.12 (http://www.modsecurity.org/) configured.
[Fri Nov 12 07:02:45 2010] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.3.3 mod_perl/2.0.4 Perl/v5.8.8 configured -- resuming normal operations
[Fri Nov 12 07:05:31 2010] [notice] Graceful restart requested, doing restart
[Fri Nov 12 07:05:31 2010] [error] (9)Bad file descriptor: apr_socket_accept: (client socket)
[Fri Nov 12 07:05:32 2010] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.3.3 mod_perl/2.0.4 Perl/v5.8.8 configured -- resuming normal operations
[Fri Nov 12 08:15:23 2010] [notice] SIGHUP received. Attempting to restart
[Fri Nov 12 08:15:24 2010] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.3.3 mod_perl/2.0.4 Perl/v5.8.8 configured -- resuming normal operations
[Fri Nov 12 08:17:49 2010] [warn] http://ssl.64bitsmartermail.com/whm-server-status/:15: Unclosed element `dt'
[Fri Nov 12 08:20:01 2010] [warn] http://ssl.64bitsmartermail.com/whm-server-status:15: Unclosed element `dt'
This is a testing server so I expect to break things here and there. LOL
Just looking for an assist on this one.
@Krishna, /usr/lib64/httpd/modules/mod_pagespeed.so is not the correct path.. Move it over to /usr/local/apache/modules/ , and change to the path to module in mod_pagespeed conf and try again..
[…] 要求 apache 2.2,然而尽管服务器的 apache 版本符合要求,仍然报错。参考这篇文章安装(原作者似乎出现了一个很难察觉的笔误,本文是经 Yculer […]
Hello,
I got the following error can any one help me to fix it?
httpd: Syntax error on line 30 of /usr/local/apache/conf/httpd.conf: Syntax error on line 1 of /usr/local/apache/conf/pagespeed.conf: Cannot load /usr/lib64/httpd/modules/mod_pagespeed.so into server: /usr/lib64/httpd/modules/mod_pagespeed.so: cannot open shared object file: No such file or directory
It doesn’t work!!
@Tingya, What happ?