Using a custom php.ini when using FAST CGI (fcgi) in Cpanel WHM

When using FastCGI (FCGI) as the loader for PHP, traditional php_values in the .htaccess file as well as custom php.ini files in the public_html directory no longer work. Instead we must create a wrapper for the main FCGI binary that causes the php.ini to be loaded from it’s current working directory instead of the server-wide one.

Edit the .htaccess file in the directory you want to use a custom PHP configuration for and add the following lines to the bottom of the file:

AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php5.fcgi

Next, you’ll need to copy your your main server php.ini which is located in /usr/local/lib/. Also note that it needs to have the correct ownership.

cd /home/user/public_html/cgi-bin/
cp -a /usr/local/lib/php.ini .
chown user:user php.ini
chgrp user:user php.ini

Create a file in your current directory (cgi-bin) called  php5.fcgi as defined above and add the following:

exec /usr/local/cpanel/cgi-sys/php5

Finally, make sure the ownership and permissions are correct on this file:

chown user:user php5.fcgi && chmod 0755 php5.fcgi
chgrp user:user php5.fcgi && chmod 0755 php5.fcgi

You can now edit the php.ini inside cgi-bin/ and change the desired values. You can verify they are set properly by inserting the phpinfo() function inside a PHPscript on that user account.

Linux Recursive GREP search excluding directories example

This command will search for text inside files in a directory while excluding some directories you do not want to search in.

This is helpful when a search is going slow due to a directory that might contain thousands of files that you are not interested in searching through, such as an images or cache directory.

grep -r –exclude-dir=product_images –exclude-dir=cache –exclude-dir=.svn search term *




How to use whatis and xargs linux commands

Have you ever wanted to know what the commands various commands in linux do?  Such as the commands in:


Move to the bin directory of your choice and follow the example below:

cd /bin
ls | xargs whatis | less

You will get an output of the command and a summary of it’s function:


basename             (3p)  – return the last component of a pathname

bash                 (1)  – GNU Bourne-Again SHell

bash [builtins]      (1)  – bash built-in commands, see bash(1)

bash [sh]            (1)  – GNU Bourne-Again SHell

ca                   (1ssl)  – sample minimal CA application

cat                  (1)  – concatenate files and print on the standard output

cat                  (1p)  – concatenate and print files

chgrp                (1)  – change group ownership

chgrp                (1p)  – change the file group ownership

chmod                (1)  – change file mode bits

chmod                (1p)  – change the file modes

chmod                (2)  – change permissions of a file

chmod                (3p)  – change mode of a file

chown                (1)  – change file owner and group