Friday, October 12, 2018

disable_functions with Easy Apache 4 and PHP-FPM

Recently I've faced the issue about disable_functions !!!

I need to use 'shell_exec' for one of application with PHP.

By default php will disable some functions with php.ini file with "disable_functions" line.

It will look like,

disable_functions = "exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source"

If you wanna use these functions, you have to remove that function name from disable_functions line on php.ini.

Let's take a look on configurations,

I logged on my WHM and went to "Home »Software »MultiPHP INI Editor", By choosing my php version, I can see the file. Shockingly, disable_functions is empty. If it's empty, then how the function is getting disabled. And verified my php.ini file path. It's too respond same that "disable_functions" with empty value.

So I used phpinfo() in side website and checked. It's showing disable_function is active with 'shell_exec'.

So who is that enabling "disable_functions" field with 'shell_exec'.

Everything fine before upgrading to EA4 with PHP-FPM. So he must be doing these changes.

Yes, once I turn off PHP-FPM for the website. It's working. It's simple solution for single website. But, How to do this globally ? Will update shortly !!!

Edit crontab with VIM

How to change crontab editor from NANO to VIM ?

Usually google searches give following method, But it didn't work for me,

export EDITOR=/usr/bin/vim
crontab -e

or

EDITOR=vim crontab -e

At same time, following is working fine for me.

export VISUAL=/usr/bin/vim
crontab -e

VISUAL=vim crontab -e

Tuesday, September 18, 2018

cPanel MultiPHP Manager with PHP-FPM

We all know, cPanel is one of best server admin panel. It's best thing is Easy Apache. It is user friendly GUI platform for managing Apache and PHP in WHM panel. cPanel is going to withdraw support for EasyApache 3 (EA3) and asking every user to upgrade EA4.

Recently I've upgraded it, It's too simple process, you can do this with their official tutorial.

But, after upgraded and if you are enabled and using PHP-FPM (FastCGI Process Manager), you may face some slowdown on websites or you may face frequent "This site can't be reached" error message on browser.

This is happens due to max_children size may exceed. That means, the default value of max_children is set to 5 on PHP-FPM. You can trace this issue with below command,

root@server [~]#egrep 'example.*max_children' /opt/cpanel/ea-php56/root/usr/var/log/php-fpm/error.log

the above commend will help to find specific website, where example is domain name without extension and ea-php56 is php version, where it may ea-php70 or ea-php72 or any other based on your php version.

This will give result as mentioned bellow,
[18-Sep-2018 05:34:58] WARNING: [pool example_com] server reached max_children setting (5), consider raising it
[18-Sep-2018 08:28:00] WARNING: [pool example_com] server reached max_children setting (5), consider raising it
[18-Sep-2018 08:44:26] WARNING: [pool example_com] server reached max_children setting (5), consider raising it
[18-Sep-2018 08:44:55] WARNING: [pool example_com] server reached max_children setting (5), consider raising it
[18-Sep-2018 09:31:40] WARNING: [pool example_com] server reached max_children setting (5), consider raising it
[18-Sep-2018 09:57:16] WARNING: [pool example_com] server reached max_children setting (5), consider raising it


If you get result as mentioned above, you may need to adjust max_children value on bellow steps.

WHM Home > Software > MultiPHP Manager

If you are not sure about website name, you can use below command to get all results,

root@server [~]#egrep 'consider raising it' /opt/cpanel/ea-php56/root/usr/var/log/php-fpm/error.log

Saturday, July 21, 2018

Finding multiple folders in Linux with single command

Finding multiple folders with single commend on Linux is not a big deal.

I wanna know all temp / tmp and cache folders in websites, that are configured with WHM to exclude from the backup. Here is the command for that,


find /home/*/public_html \( -type d -iname "cache" -or -iname "tmp" -or -iname "temp" \)

To know size of these folders,

find /home/*/public_html \( -type d -iname "cache" -or -iname "tmp" -or -iname "temp" \) -exec du -sh {} \;

Friday, July 20, 2018

Finding files with in date range

Here is the command for find files that was modifed between 1st July 2018 to 20th July 2018 with it's details,

find . -type f -name "*.php" -newermt 2018-07-01 ! -newermt 2018-07-21 -exec ls -l {} \;

Please note, you have to mention next date of till date.

disable_functions with Easy Apache 4 and PHP-FPM

Recently I've faced the issue about disable_functions !!! I need to use 'shell_exec' for one of application with PHP. By de...