apache / incubator-pagespeed-cpanel

mod_pagespeed module for CPanel WHM
Other
144 stars 50 forks source link

Easyapache overwrites pagespeed.conf #24

Open stigoleg opened 9 years ago

stigoleg commented 9 years ago

Hi, Thanks for this great plugin. Easyapache will overwrite pagespeed.conf, deleting all custom rules. Is there a simple fix for this?

Prajithp commented 9 years ago

Before you run /scripts/easyapache in the future, create these files:

vi /scripts/preeasyapache

Place the following content into the file:

#!/bin/bash
if [ -e "/usr/local/apache/conf/pagespeed.conf" ]; then
   cp -prf /usr/local/apache/conf/pagespeed.conf /root/
fi

Next, create this file

vi /scripts/posteasyapache

Place the following content into the file:

if [ -e "/usr/local/apache/conf/pagespeed.conf" ]; then
   mv /usr/local/apache/conf/pagespeed.conf /usr/local/apache/conf/pagespeed.conf _easy
   cp -prf /root/pagespeed.conf /usr/local/apache/conf/pagespeed.conf
   /etc/init.d/httpd restart
fi

The first script copies the existing pagespeed config file to /root/ at the beginning of the Apache build. The second script copies pagespeed.conf back into /usr/local/apache/conf/ folder, and restarts Apache at the end of the build.

After saving these files, ensure they can execute:

chmod +x /scripts/preeasyapache
chmod +x /scripts/posteasyapache

cPanel EasyApache Hooks: https://documentation.cpanel.net/display/EA/Script+Hooks