Sunday, August 24, 2014

// // Leave a Comment

Auto fix for file permissions and ownership [CPANEL]

suPHP and FastCGI require files and folders to have a specific set of permissions/ownership from other handlers. Without these permissions set you will see a lot of errors such as: “403 Forbidden”, “500 Internal Server Error”, or simply generic errors that commonly have the word ‘permission’ in them.
It can be very time consuming to track down and check file permissions across a whole server. Luckily, fixing this on a cPanel box can be scripted. This gives us a quick and very easy script you can wget to any cPanel server. Simply run the ‘fixperms’ script, specifying the user (or all users), sit back and watch the errors just disappear. I use this script daily in my administrative work and it never fails! It is simply a good generic fix if you cannot find your permission problem, or if you have just switched your handler and need a quick way to change every user account on the server.
Credit does not go to me though. A good buddy of mine, Colin R., wrote this for ServInt. Thanks Colin for making lives easier!
***WARNING!!! The following scripts are intended for suPHP or FastCGI. If you are not running either of these two handlers, be aware of how the script works and the changes it makes. The code is posted at the end of this article; please take a moment to review it. For example, when running DSO, some files/folders may need to be owned by ‘nobody’ in order to function properly (such as in certain WordPress functions or PHP based file uploads). Running this fixperms will set everything to USER:USER. Under DSO, this is potentially not a problem for most sites, except a few core functions may not work. You can always change specific files later if any errors pop up.
Furthermore, it is highly recommended that you run a full backup of your server before running fixperms or any other script that makes changes to multiple files.
This ‘fixperms’ script is intended for cPanel servers only. It is dependent on cPanel’s internal scripts and file structure. If you’re on anything else (such as Plesk), it will simply fail to run. It won’t be able to do anything.
I know that criteria sounds very specific, but those two conditions cover a large number of the reseller/multi-user hosting servers out there. And that’s really the crowd that would benefit most from an automated script such as this.
That all being said, if you are running suPHP or FastCGI, press on; for this script will work flawlessly for you and potentially save you a TON of time & hassle.

Fixperms – for one single user

To use the fixperms script, simply log into your server as root, wget the file from our server, then run it. Type in the cPanel username and it will run only for that particular account.
It does not matter which directory you are in when you run fixperms. You can be in the user’s home directory, the server root, etc. The script will not affect anything outside of the particular user’s folder.

Fixperms – for all of the users

If you would like fix the permissions for every user on your cPanel server, simply use the ‘-all’ option:

Verbosity of Fixperms

By default, the script runs in a ‘quiet’ mode with minimal display. However, if you’re like me, you may want to see everything that is happening. You can turn on verbosity and have the script print to the screen everything that is being changed. I find this extremely useful when fixing large accounts that have many files. You can watch the changes as a sort of ‘progress bar’ of completion. The ‘-v’ option can be used per account or with all accounts.
For one single account:
For all accounts:

The code itself, what’s in it?

I understand that it can be a big security concern to simply ‘wget’ a file from a website you found, and then blindly run it on a production server. I understand your fear; I’m right there with you and would likewise be leery and very hesitant. However, I promise you that there is no malicious intent in this or anything you will ever get from my site. I have pasted the content of the file below for your examination.
 
So there you have it. An effective permissions fix for your cPanel account. When you run this, people will think you’re a hero! So, go forth and save your users from the evils of site errors!
Read More

Friday, January 31, 2014

// // Leave a Comment

How to install mod pagespeed on cpanel server

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.
Features
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
mod_pagespeed
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 http://www.gnutoolbox.com/moddeflate-cpanel/
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-1.4.26.4-3396.x86_64)
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm

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

chmod 755 /usr/local/apache/modules/mod_pagespeed.so

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/mod_pagespeed.so


    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 127.0.0.1
        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://yourwebsite.com
HTTP/1.1 200 OK
Date: Wed, 17 Oct 2012 06:58:03 GMT
Server: Apache
X-Mod-Pagespeed: 1.0.22.7-2005
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
 wget http://prajith.in/scripts/mod_pagespeed-cust-opts.tar.gz
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
/scripts/easyapache

Solution : 3

Install Google’s mod_pagespeed.

Create a file called /etc/yum.repos.d/mod-pagespeed.repo
For 32-Bit
[mod-pagespeed]
name=mod-pagespeed
baseurl=http://dl.google.com/linux/mod-pagespeed/rpm/stable/i386
enabled=1
gpgcheck=0
For 64-Bit
[mod-pagespeed]
name=mod-pagespeed
baseurl=http://dl.google.com/linux/mod-pagespeed/rpm/stable/x86_64
enabled=1
gpgcheck=0
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.so : 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 mod_pagespeed.so 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
X-Mod-Pagespeed
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..
Read More

Sunday, January 19, 2014

// // Leave a Comment

Social CSS Snippets and Ideas – Live Editable Examples

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 !
Read More
// // Leave a Comment

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 :
For CSS
img {here is the code of the initial state of the image}
and
img:hover { here is the code of the hover state of the image}
For HTML
 src="http://link to the image">
This extra div below ↓ is used  to center things on the Screen JUST IGNORE IT
style="text-align:center">
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.
Read More