Showing posts with label WHM. Show all posts
Showing posts with label WHM. Show all posts

Thursday, October 31, 2019

Find and clear log files in Linux

Objective:

Find and clear the files with extension of *.log, usually log files.

Commands:

find . -type f -iname *.log -exec tee {} \; </dev/null

This command will find the files with extension of 'log' and empty that file. Which means file will be there and data of that file will be cleared.

If you are using cPanel, there will be a directory called "virtfs", in that case you can use following command.

find /home -type f -iname *.log -not -path "./virtfs/*" -exec tee {} \; </dev/null

Please note, in WHM / cPanel server, this will clear logs including created by server.

So, If you need to do this manually for specific file, you can simply use any of following commands,

# > file.name

# :> file.name

# true > file.name

# echo "" > file.name

# echo  > file.name

# dd if=/dev/null of=logfile

# dd if=/dev/null > logfile

Still there are several methods to clear it.

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 !!!

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, March 11, 2017

Copy all Incoming Outgoing Emails - Employee monitor

How can we monitor employee's email conversations ?

If we are running company, It's too impotent to monitoring employee's email conversations which is traveled by company domain name. If you are using WHM with Exim mail server, it's too easy.

Let's consider "domain.com" is your company domain, you have 50's of mail IDs. You are having a mail ID "monitor@domain.com" and you need to archive / monitor all your mails incoming and outgoing mails to "monitor@domain.com".

To do this, you must have access to server with ssh (root access) and WHM (root access).

1. "/usr/local/cpanel/etc/exim/sysfilter/options" is path where you can store all custom filters.

#cd /usr/local/cpanel/etc/exim/sysfilter/options

2. Create a empty file for store your filter rules. You can create as much of filter as you want, so create a file with understandable name with domain name, replace domain_com to your company domain name.

#vim incoming_outgoing_domain_com

3. Copy paste bellow code to this file and replace "domain.com" to your company domain name and "monitor@domain.com" to your mail that you created for archive all mails,

For incoming mails only,

if ("$h_to:, $h_cc:, $h_bcc" contains "domain.com")
then
     unseen deliver "monitor@domain.com"
endif

For outgoing mails only,

if $sender_address: contains "domain.com"
then
     unseen deliver "monitor@domain.com"
endif

For incoming and outgoing mails,

if ("$h_to:, $h_cc:, $h_bcc" contains "domain.com")
   or ("$sender_address:" contains "domain.com")
then
   unseen deliver "monitor@domain.com"
endif


Note: Forwarding to other domains, outside server won't work.

Monday, September 7, 2015

Import Plesk mails to WHM cPanel mails - vice versa

Before start to the solution, I'll explain my situation,

I've 2 servers with Parallels Plesk - 11.5.30 and WHM - 11.50. Plesk have Postfix mail server and WHM have exim mail server.

My task is to migrate a domain example.com from Plesk installed server to WHM installed server.

Now I've moved files to new server, But how can I move mails from Plesk to WHM. It's really hard thing to do, because both have different mail server.

After lot of reference, I can see that horde will help on this.

Okay, Let's see what is Horde, It is a webmail client, slimier to squirrelmail, roundcube mail etc. It is used to check our mails on server with web interface.

So how it help us to import mails that located in server with Plesk control panel to server with WHM control panel.

Trick

1. How to Enable Horde web-mail on plesk.

Login in to your Plesk control panel, click "Tools & Settings" on left menu, click "Updates and Upgrades" under Panel, new window will open, click Add/Remove Components, on list under "Plesk webmails support" select "Horde web-mail support", if not selected and click remove another one. It'll take few min to install.

2. In WHM control panel, we don't have to do much work because by default there is option to choose our web-mail client.

3. Login in to Horde Web-mail client on plesk server, Right click Inbox, click Export. It'll ask to download file, use default option and click ok.

4. MBOX file will be downloaded.

5. Login to web-mail on WHM server, as same Right click and choose Import. It'll ask for mbox file, choose downloaded file.

6. It'll take few some time based on your mails count and size.

That's it.

Advantages:
It's very quick method to import, no need any configuration changes.

Disadvantages:
It's too hard if we have large amount of mail boxes.

Monday, December 23, 2013

Enable / Disable Webmail options on WHM panel

Currently we can choose Horde Webmail, RoundCube webmail, SquirrelMail webmail.

We can Enable or Disable, what all are should be available to client by WHM. For select this use bellow steps for it,

1. Login to WHM panel
2. From left site pane, select Server Configuration -> Tweak Settings
3. Click Mail tab, and there we can see lot of mail settings,
4. Find Enable Horde Webmail, Enable RoundCube webmail, Enable SquirrelMail webmail
5. Using On,Off radio selection, we can Enable or Disable webmail options.
6. Select option and click save.