How to install mod pagespeed on cpanel server

Friday, January 31, 2014

mod_pagespeed speeds up your site and reduces page load time. This open-source Apache HTTP server module automatically applies web performance best practices to pages, and associated assets (CSS, JavaScript, images) without requiring that you modify your existing content or workflow.
Automatic website and asset optimization
Latest web optimization techniques
40+ configurable optimization filters
Free, open-source, and frequently updated
Deployed by individual sites, hosting providers, CDNs
Pagespeed requires mod deflate module. You can verify this module whether installed on your server.
httpd -l | grep mod_deflate
or try to install mod deflate
How to install mod pagespeed on cpanel server?
Solution : 1
Installing mod_pagespeed for cPanel Apache installation on CentOS is really quite easy. Connect your server SSH via root user.
cd /usr/local/src
mkdir mod_pagespeed
cd mod_pagespeed
Download the mod_pagespeed RPM to build. Please make sure which arch is your server. If you have a 32-bit install of CentOS you can find your appropriate package on Google’s Installing mod_pagespeed From Packages page.
yum install at  # if you do not already have ‘at’ installed
Mostly apache version 2.2 support for this mod pagespeed version (httpd >= 2.2 is needed by mod-pagespeed-stable-

rpm2cpio mod-pagespeed-stable_current_x86_64.rpm | cpio -idmv
Copy mod file to apache module directory
cp usr/lib64/httpd/modules/ /usr/local/apache/modules/

chmod 755 /usr/local/apache/modules/

mkdir -p /var/mod_pagespeed/{cache,files}

chown nobody.nobody /var/mod_pagespeed/*
Open pagespeed configuration file.
vi /usr/local/apache/conf/pagespeed.conf
LoadModule pagespeed_module /usr/local/apache/modules/

    ModPagespeed on
ModPagespeedFetchWithGzip on
SetOutputFilter DEFLATE

    AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html

ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"
ModPagespeedGeneratedFilePrefix      "/var/mod_pagespeed/files/"

ModPagespeedRewriteLevel PassThrough

ModPagespeedFileCacheSizeKb          102400
ModPagespeedFileCacheCleanIntervalMs 3600000
ModPagespeedLRUCacheKbPerProcess     1024
ModPagespeedLRUCacheByteLimit        16384
ModPagespeedCssInlineMaxBytes        2048
ModPagespeedImageInlineMaxBytes      2048
ModPagespeedCssImageInlineMaxBytes   2048
ModPagespeedJsInlineMaxBytes         2048
ModPagespeedCssOutlineMinBytes       3000
ModPagespeedJsOutlineMinBytes        3000

ModPagespeedEnableFilters extend_cache,combine_css,move_css_to_head,rewrite_javascript,rewrite_images,add_head,rewrite_css,collapse_whitespace,remove_comments,remove_quotes,sprite_images,convert_meta_tags
ModPagespeedRespectVary on

          SetHandler mod_pagespeed_beacon

        Order allow,deny
        Allow from localhost
        Allow from
        SetHandler mod_pagespeed_statistics
Make a copy of your apache configuration httpd.conf file.
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf_back
Edit and include the pagespeed configuration.
vi /usr/local/apache/conf/httpd.conf
Include “/usr/local/apache/conf/pagespeed.conf”
Save and restart apache service.
/etc/init.d/httpd restart
Thats finished… Test your page speed modules on website headers.
curl -I
HTTP/1.1 200 OK
Date: Wed, 17 Oct 2012 06:58:03 GMT
Server: Apache
Cache-Control: max-age=0, no-cache
Vary: Accept-Encoding
Connection: close
Content-Type: text/html
You have successfully installed mod_pagespeed module on your cPanel server.

Solution : 2

Mod_Pagespeed  install using easyapache

You can install it by using following steps
tar -C /var/cpanel/easy/apache/custom_opt_mods  -xzf mod_pagespeed-cust-opts.tar.gz
Thats it, now you can run and enable mod pagespeed

Solution : 3

Install Google’s mod_pagespeed.

Create a file called /etc/yum.repos.d/mod-pagespeed.repo
For 32-Bit
For 64-Bit
Install mod_pagespeed module through Yum
yum install at  # if you do not already have ‘at’ installed
yum --enablerepo=mod-pagespeed install mod-pagespeed
Above command creates following directories and files.
/etc/cron.daily/mod-pagespeed : mod_pagespeed cron script for checking and installing latest updates.
/etc/httpd/conf.d/pagespeed.conf : The main configuration file for Apache.
/usr/lib/httpd/modules/ : mod_pagespeed module for Apache.
/var/www/mod_pagespeed/cache : File caching direcotry for web sites.
/var/www/mod_pagespeed/files : File generate prefix for web sites.
Please make sure file included in your httpd.conf.
To verify mod_pagespeed module, create php info page anywhere in your domain or localhost and check it.

You will see “X-Mod-Pagespeed” section in the HTTP header, like
Turning the Module On and Off
If you don’t want to use mod_pagespeed completely, you can Turn Off by inserting the following line to pagespeed.conf file at the top.
ModPagespeed off
Turn On module
ModPagespeed on
Thats all..

Social CSS Snippets and Ideas – Live Editable Examples

Sunday, January 19, 2014

We all know the importance of Social networks, almost every website today has some sort of social media share or like button.
In this post, i will share some interesting social CSS code snippets that i have gathered or made myself. You can use them as a starting point to make your own. Some of them are animated using CSS3, others are just buttons or icons. They are easy to customize and you can play with them directly. I hope you will  find them useful and enjoy them as much as i did. let the ideas flow !

CSS Live Editable Examples

All of the examples below are hosted on codepen, feel free to customize them to suit your needs.

Social CSS Snippet – example 1

Social CSS Snippet – example 2

Social CSS Snippet – example 3

Social CSS Snippet – example 4

Social CSS Snippet – example 5

Social CSS Snippet – example 6

Social CSS Snippets and Ideas – Live Editable Examples

If you like those examples -share them !

Simple & Cool Live Examples of Image on hover Css effect

We will be playing with Image on hover effects using CSS  and One image only. I’ve created four simple examples that will work in all  browsers and another six cooler ones that will work only on webkit browsers.
They are all hosted on Codepen so you can directly play with the code and learn in the process. I  didn’t  even make any extra div to confuse you – all the images are in their main IMG tag. I’ll try to keep it short and sweet so you can absorb it even if you never touched CSS before.
In all the examples below we use this two simple things :
img {here is the code of the initial state of the image}
img:hover { here is the code of the hover state of the image}
 src="http://link to the image">
This extra div below ↓ is used  to center things on the Screen JUST IGNORE IT
The first four live examples will work in all the modern browsers
box shadow browser support 
Lets get this party started…
Simple & Cool Live Examples of Image on hover Css effect

Shrink Image on hover

In this example we have  :hover  using height and width to change the size of the image, by adding  transition: all 1s ease;  to img we  make that change  from bigger- to smaller look smooth, changing the 1s  to 1,1s will make the transition last longer and setting it to 0,9s will make it last shorter.

Enlarge Image on hover

In this example we just change the  height and width to be bigger rather than smaller. Compare the css with the first example above and you will understand what i mean.

Rotate Image on hover

In this example we have transition again but this time in  :hover instead of the image size we have  transform: rotate(360deg); which does exactly what it says – it rotates the image 360 degrees.

Tilt Image on hover

In this example the  360 is changed to 15 degrees so it just tilts a little bit.
Simple & Cool Live Examples of Image on hover Css effect

Now for the webkit browsers the effects are much more interesting, yet also very simple to create

Blur Image on hover

Again in the img we use the transition but this time in the :hover we have added a filter -webkit-filter: blur(5px); changing the 5px to more or less will change the blur strength.

Decolorize Image on hover

This time the filter is  -webkit-filter: grayscale(100%); again setting the100% to less will change the effect

Darken Image on hover

Here we have  -webkit-filter: brightness(100%); in img again as initial state and than by adding  -webkit-filter: brightness(0%); to :hover we trigger the change. and of course again you can set up the filters % to your needs.

Hue-rotate Image on hover

In this cool example we have added the filter -webkit-filter: hue-rotate(333deg); 

Drop shadow Image on hover

For drop shadow we use -webkit-filter: drop-shadow(10px 7px 1px grey)

Opacity Image on hover

In this last example we have  -webkit-filter: opacity(0.3); as a filter.
And that concludes my Image on hover Css effect article.

I suggest that you bookmark this page and use it as a starting point anytime you wish to practice and experiment.

You can also check some other cool stuff that i have about CSS.
If you like this article please be kind to share it on your favorite social networks below.

How To (Automatically) Backup Your Website Into Dropbox or

Tuesday, October 22, 2013

As owners of websites, one of the more important things you should do is to regularly backup the website. Most web hosting providers will enable daily or weekly backups, mainly for their disaster recovery purpose only. If you want to personally oversee a backup of your website, you can do it by yourself using the Backup function in hosting control panels like cPanel, Plesk and DirectAdmin. As a webmaster or domain owner, you are responsible for this task.
A good backup should have following criteria:
  • Backup your data as frequently as possible.
  • Give higher priority to critical data like database and web contents. Try to exclude temporary files.
  • Your backup should NOT be saved inside the same server.
  • Your backup should be retrievable and accessible anytime, anywhere.
  • You should get notified for every backup status which has been scheduled.
  • Your backup should be compressed, if disk space or bandwidth is your concern.
It is good if you can have your one FTP server to store backup remotely. But, what if the FTP server is down? How can we automate the backup task with limited access to the server? How can you be sure that the availability is always there? Cloud storage is your answer.
Cloud storage is becoming the best way to store files. Popular providers like Amazon S3, Dropbox, iCloud and are offering these facilities for free with some limitations. But, none of them are supporting FTP as the medium to transfer while almost all of webhosting providers only allow this transfer method.
Here’s where Backup Box/ comes in. Backup Box helps you securely transfer anything on an FTP server to your Dropbox account. Actually, Backup Box can integrate your FTP account with cloud storage providers like Amazon, GitHub, and Flickr as well. At this very moment, only Dropbox integration is supported while the others are still under development. It is free to use, with limited features like monthly backup schedule and immediate transfer schedule. In this post, I am focusing on preparing the backup data for weekly backup while running on cPanel server.
Backup Box
We can use this tool with various ways of implementation such as 1, directly copying the web directory using FTP and transferring to Dropbox (compressed or uncompressed) or 2, creating a compressed backup (cPanel backup) and using FTP to fetch the backup to Dropbox.
Before we proceed with the tutorial, ensure that you have following required information:
  • An FTP account which is mapped to your web directory. Get it from your hosting control panel.
  • A Dropbox account. You can register here for free
  • Or A Copy account. You can register here for free. (Recommended)
  • A Backup Box account. You can register here for free or movers account at

Web Directory > FTP > Dropbox

Since the database is also important, we need to prepare the database backup and put it into our web directory. If you are running on Linux hosting, you can use a task scheduler called a cron job with some help from mysqldump. In cPanel, it is located under cPanel > Advanced > Cron jobs.
Let’s use the following data as an example:
  1. Web directory path: /home/username/public_html  
  2. cPanel username: mycpanel  
  3. cPanel password: mypass123$  
Create a new weekly cron job and use the following command:
  1. mysqldump --opt -Q -u mycpanel -p'mypass123$' --all-databases > /home/username/public_html/databases.sql  

Here’s An Example:

This will create an SQL backup file which includes all the databases under your cPanel account. Login into Backup Box. On the left panel, login into the FTP account by clicking the ‘gear’ icon. On the right panel, login into your Dropbox account.
You can choose Transfer public_html as a folder in the Transfer Options. This will transfer the whole public_html folder including all files into your Dropbox account. You can now start the immediate transfer by clicking Review. This will transfer the public_html folder to Dropbox. Once done, you can create Monthly schedule to automate this backup task monthly. Just click Monthly > select Date and Time > Finalize and Run. Note: If you want to use weekly or daily backup, you need to upgrade your subscription as stated in the website. Do not forget to change the cron job setting based on when you want the backup schedule to happen

CPanel Backup > FTP > Dropbox

The good thing about cPanel is you can generate your own backup automatically using cPanel API. In this case, we will use PHP script to run on schedule to generate backup. Since the backup location needs to be exclusively for Backup Box, we will need to create an FTP account which is mapped to a new backup folder.
Go to cPanel > FTP and create an FTP account as the screenshot below. Do not create the FTP directory under public_html because it is accessible publicly via web browser (unless you protect the directory with a password):
We need to use PHP with cPanel API to trigger the backup process. Download this file ( and unzip it. You should see 2 files, cpanel-backup.php and Change all required information inside cpanel-backup.php as below:
  1. // Credentials for cPanel account  
  2. $source_server_ip = ""; // Server IP or domain name eg: or cpanel.domain.tld  
  3. $cpanel_account = ""; // cPanel username  
  4. $cpanel_password = ""; // cPanel password  
  6. // Credentials for FTP to Backup Box  
  7. $ftpacct = ""; // FTP account  
  8. $ftppass = ""; // FTP password  
  9. $email_notify = ''; // Email address for backup notification  
Save the file and upload both files into your public_html directory using FTP. You can start to generate a backup by accessing the PHP file directly via browser, which is usually .
In order to automate cPanel backup creation, we need to setup a weekly cron job into cPanel and use following command:
  1. php -q /home/username/public_html/cpanel-backup.php  
Here is a sample:
Login into Backup Box. On the left panel, login into the FTP account (use the backup box FTP account) and in the right panel, login into your Dropbox account:
Since we store backup files into a dedicated folder, we can only transfer the contents of it. Select Transfer only the contents of / in the Transfer Options as the transfer method.
You can now start the immediate transfer by clicking Review. This will transfer the public_html folder to Dropbox. Once done, you can create Monthly schedule to automate this backup task monthly. Just click Monthly > select Date and Time > Finalize and Run.
Note: If you want to use weekly or daily backup, you need to upgrade your subscription as stated in the website. If you do, do not forget to change the cron job setting according to your backup schedule. Another thing, the PHP script will delete all previous cPanel backup before it generate new backups. This to make sure your backup will not eat up much disk space.

Convert root filesystem to LVM

Thursday, September 19, 2013

I converted root filesystem to lvm since the root partition was huge and I needed more flexibility in managing the partitions. Besides, lvm would also enable for easy backups with lvm snapshots.
I had a sizable swap partition of 2GB which I used to transfer my root files to and rebooted to it, prior to the conversion.
Please know what you are doing prior and make sure to create backups.
  1. This is what the partitions looked like prior to the change:
    # df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda3             228G  1.4G  215G   1% /
    /dev/sda1              99M   17M   77M  19% /boot
    none                 1014M     0 1014M   0% /dev/shm
    # fdisk -l
    Disk /dev/sda: 250.0 GB, 250000000000 bytes
    255 heads, 63 sectors/track, 30394 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          13      104391   83  Linux
    /dev/sda2              14         267     2040255   82  Linux swap
    /dev/sda3             268       30394   241995127+  83  Linux
  2. With the current setup, I have a better sized partition, and can further create/resize partitions to add or remove at will:
    # df -h
    Filesystem            Size  Used Avail Use% Mounted on
                           24G  1.3G   22G   6% /
    /dev/sda1              99M   19M   75M  21% /boot
    none                 1014M     0 1014M   0% /dev/shm
    # fdisk -l
    Disk /dev/sda: 250.0 GB, 250000000000 bytes
    255 heads, 63 sectors/track, 30394 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          13      104391   83  Linux
    /dev/sda2              14         267     2040255   83  Linux swap
    /dev/sda3             268       30394   241995127+  8e  Linux LVM
  3. I had a sizable swap partition of 2GB, so I turned it off.
    # swapoff -a
  4. Formated the swap partition as ext3 and copied over the root files:
    # mke2fs -j /dev/sda2
    # mount /dev/sda2 /mnt/
    # find / -xdev | cpio -pvmd /mnt
  5. Once the files were transfered. I then edited the "/mnt/etc/fstab" file to reflect the new root.
    /dev/sda2      /    ext3       defaults 1 1
  6. Add a grub section to use "/dev/sda2" as the new root.
    title CentOS (2.6.9-55.0.9.ELsmp.sda2)
            root (hd0,0)
            kernel /vmlinuz-2.6.9-55.0.9.ELsmp ro root=/dev/sda2
            initrd /initrd-2.6.9-55.0.9.ELsmp.img
  7. After reboot the original root (/dev/sda3) is no longer mounted and is free to work with.
  8. Change the partition type from Linux to LVM (8e).
          # fdisk /dev/sda
          Command (m for help): t
          Partition number (1-4): 3
          Hex code (type L to list codes): 8e
          Changed system type of partition 4 to 8e (Unknown)
          Command (m for help): w
  9. Inform the Operating System for the partition table changes.
  10. Initialize LVM
          # vgscan
  11. Make the new partition into a Physical Volume.
          # pvcreate /dev/sda3          
  12. Create a new volume group.
          # vgcreate vg0 /dev/sda3
  13. Create a logical volume to hold the new root (/).
          # lvcreate -L 24G -n lvroot0 vg0
  14. Make a filesystem in the logical volume and copy the root files onto it.
          # mke2fs -j /dev/vg0/lvroot0
          # mount /dev/vg0/lvroot0 /mnt
          # yum update kernel
          # find / -xdev | cpio -pvmd /mnt
  15. Additionally, since the new root is now lvm, the initrd image file should have support for it else kernel will not be able to find root on reboot and end up with a kernel panic.
    Note: At this stage, instead of creating a new image, I update the kernel so that the new image supports lvm. LVM support can also be checked via extracting the initrd image file and checking for lvm binary in the bin folder.
    # mkdir -p /tmp/kill/00
    # cd /tmp/kill/00
    # gunzip < /boot/initrd-2.6.9-55.0.9.ELsmp.img | cpio -id
    # ls -al bin/lvm
    -r-x------ 1 root root 1417512 May 24 14:38 bin/lvm
    If image does not have the lvm binary, create and move it to the /boot folder.
    # chroot /mnt
    # mount -t proc /proc /proc
    # mount -t sysfs /sys /sys
    # vgmknodes -v
    # mkinitrd -v 2.6.9-55.0.9.ELsmp
  16. Edit "/mnt/etc/fstab" on the new root so that / is mounted on /dev/vg0/lvroot0.
    /dev/vg0/lvroot0       /    ext3       defaults 1 1
  17. Add grub section to use "/dev/vg0/lvroot0" to boot to.
    title CentOS (2.6.9-55.0.9.ELsmp.lvroot0)
            root (hd0,0)
            kernel /vmlinuz-2.6.9-55.0.9.ELsmp ro root=/dev/vg0/lvroot0
            initrd /
  18. Reboot, and enjoy the flexibility of lvm!!

Follow by Email

Search This Blog


Most Reading