Configure specific domains through AWS SES and others through local exim

In this post we will see how we can configure some domains in the server to relay through the amazon ses service and other domains which we dont want to go through ses to send via the local exim MTA.

First create the file /etc/excludeindomains and add the domains which you dont want to route through ses.

The format should be :

Next create a file /etc/excludeoutdomains and add the same domains in the following format :

These 2 files are for both incoming and outgoing mails. 

Add the following line under the Section CONFIG ( you will see similar lines there )

domainlist exclude_receiver_domains = lsearch;/etc/excludeindomains 
domainlist exclude_sender_domains = lsearch;/etc/excludeoutdomains

Next add the following lines in Section: ROUTERSTART

You need to write this in the section which we mention about the ses relaying. ( after the ” begin routers ” line )

domains = !+exclude_receiver_domains: !+local_domains 
senders = !*@+exclude_sender_domains

Rest you can follow in this documentation :

Just make sure you dont overwrite the ‘domains’ thing mentioned above as ‘domains = ! +local_domains’ as given in aws doc. This should not be domains = ! +local_domains if you want domains which should not route through ses. It should rather be as ( as mentioned above )

domains = !+exclude_receiver_domains: !+local_domains
senders = !*@+exclude_sender_domains

That’s it, wait a min though, dont forget to restart your exim 😉

Issue with Roundcube attachments in Plesk

Facing issues in uploading attachments to roundcube ? Last day, was not able to attach a PDF through webmail.

Apache error logs showed the following :

[Date [:error] [pid 12345:tid 123456789] [client xx.xx.xx.xx] [client xx.xx.xx.xx] ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required.

Even though mod_security isn’t loaded, faced this issue.

Error was a bug in Plesk. To fix, go to Plesk – Tools & Settings > Web Application Firewall (ModSecurity) and enable it, then disable it.

Configuring automated ec2 -volume’s snapshots !

Taking automatic snapshots of ec2 volumes is currently not as ‘automatic’ as the case with an RDS instance in which we can fully automate it.

However with AWS Ops Automator and CloudFormation, we can come up with a solution to automate the creation / deletion of snapshots.

1.1) First, launch CloudFormation and create a new stack :


1.2) After clicking on create new stack, select the option 

Give the URL as :

1.3) Give the stack a name in the next page and specify the paramters below it. Dont forget to give the 

1.4) Select the next page, leave the options page as default and click next.

Review the options and tick on

and go ahead with create.

Give 5-10 mins for the stack creation to be completed.

Once complete, you will find

Step 2) Next step would be to launch the task template ( for creating snaps) 

To do that,

2.1) Open the s3 console in the account in which the above ops automator stack was created

2.2) There would be 2 buckets created, open the one with the keyword configuration, it would be something like opsworks-configuration-xxx. Open it and click on the configuration folder. Now, select the applicable template. First, we would take a template to create the snapshot every ‘x’ hours.

2.3) So, look for the template Ec2CreateSnapshot.template and copy the Link associated with the file ( template )

2.4) Now, go back to CloudFormation and create another stack.

2.5) In the option, 

2.6) Give the stack name, something like createsnap which would help to distinguish from other stacks.

2.7) Fill in the paramters like task description etc, The time interval would be a cron time. To run everyday at 3 am, it would be : 0 3 */1 * *

2.8) Give the paramters like, Regions, Timezone.

2.9) Take a note about ‘

What you set here, would go as the tag which we will add to our ec2-instances.

So, set something like
would mean ‘snapshot-time’ is the tag and its value is 3.

Also, note the Snapshot volume options.

2.10) Dont forget to add “

I added something like : volume-source=auto
So my config looks like :


Go ahead and press Next.

Press Next in the options page without modifying anything,

Review and press create and wait for the stack to be created.

Step 3 ) Next, we would be creating the stack to remove the older snapshots.

3.1) Go to the s3 console as we did with the previous stack, select the configuration folder, this time copy the link of the template –


3.2) Go to ClouldFormation and select Create new stack, in the select template, 

3.3) Give the stack a name and go through the parameters.

3.4) As with the previous stack, give the task interval in cron format.

3.5) The tag filter value here would be the tags that will look in the snapshots to be deleted. In the previous stack, we set the tags for the snapshots to be volume-source=auto ( step 2.10)

So give that value here as the tag filter.

3.6) You can either select 

My config looks something like this :

Remember to put 0 in retention days option if you are using retension count and vice-versa.

So, with that the Cloudformation and ops automator are set up. Next is to tag the ec2 which needs the snapshot to be taken
What we had set during the snapshot creation stack was snapshot-time=3 ( step 2.9 )

So, go to the EC2 console – Instances – Select the instance, Actions -> Instance settings – Add/Edit tags. 

Add the key – snapshot-time and value as 3.

This should get the snapshot creation at the time we specify and delete it in the way we specify either looking at the retention count / days.

Error when starting php-fpm on a virtualmin centos

Last day ran into an issue in which the php-fpm service was facing an issue and httpd service was failing to start.

On checking the logs, could see this :

Date [proxy:error] [pid] 111  connection refused:FCGI:attempt to connect to (*) failed

Date [proxy_fcgi:error][pid] client ip : failed to make connection to backend:

Could see that proxy:fcgi was set to run on the same port in which php-fpm was configured to listen on.

Edit the file – /etc/php-fpm.d/www.conf and find this line :

listen =

change the listening port to something different than what proxy_fcgi is using.

Restart the php-fpm service.


Connecting to Mariadb/MySQL RDS from phpMyAdmin

The Amazon RDS ( AWS RDS ) – Managed relational database service from aws is a real blessing these days. Since its managed by aws, you don’t have to worry about the patching / administration / backups / restore aspects of it. All you need to do is upload the codes into it and make sure the connection between ec2 ( web-servers in this case ) and RDS is all good.

But, what if you want to manage the tables / dbs of the rds ? There is no way in which you can login into it directly and execute any codes.

You can make use of phpMyAdmin to login to the rds and manage it.

1) Install phpMyAdmin in the ec2-server ( Based on the linux distro it varies ) On a centos release, it comes with the EPEL Repository.

yum install epel-release ( installing the repo )
yum install phpmyadmin

2) Once installed, open the conf file at /etc/httpd/conf.d/phpMyAdmin.conf

You will find parameters which specify Require ip and Allow from which would be default to

3) Find your local public IP and replace the localhost entires with the public IP.

4) Restart the httpd service and make sure you can access phpMyAdmin at http://serverip/phpmyadmin.

If Step 3 is not done properly, you will get a 403 Forbidden error.

With this, the installations steps are complete, however, logging now to phpMyAdmin would give you only the option to manage the dbs on the local server now. To have the choice to connect to the RDS do the following :

1) Open the File – /etc/phpMyAdmin/ ( on centos this would be the path )

2) Find the section –

* End of servers configuration

Just above it, type in the following :

$cfg['Servers'][$i]['host'] = ''; ( rds endpoint )
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['verbose'] = 'hostname'; ( hostname of the ec2 )
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = TRUE;

Save the config file. Now when you login to http://serverip/phpmyadmin/ you will get a dropdown to select the server, instead of localhost, select the server which we just added.

In case the above dropdown to select the server is not showing up, it would be a case of missing permissions / ownership.

Make sure the /etc/phpMyAdmin/ folder has the permission – 755
and the /etc/phpMyAdmin/ file – 644

Note : The above was done on a virtualmin centos7 server.


Error when updating email address of DNS zone – cPanel / WHM

When trying to update the email address in DNS zone of a domain from cPanel / WHM, do you get an error like this :

“Unable to parse zone: There was an error while loading the zone for Please correct any errors in this zone manually and try again. The exact error from the parser was: : [] zon”

Very small mistake though 😀

When changing the email address, be sure not to use an “@” symbol. Instead, use a dot “.”, and be sure to add a trailing dot as well.

For example, if you wanted to change the email address to, you’d change this to:


What a minor one was that 😀

locale error in CentOS 6 !

Recently saw the issue in newly build CentOS6 VMs ( For me it was Virtuozzo based VMs ) :

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)

Saw this error even after installing cPanel in the VPS.

This warning popped up every time you ran a command in shell, though it did not cause any issues

The fix was to run the following command :

localedef --no-archive -i en_US -f UTF-8 en_US.UTF-8

Should be good now !


Convert mp4 videos to mpg format !

At times, you will want to convert the mp4 videos to mpg format, which the common DVD players and the older TV’s support directly.

To do this, you can use the FFmpeg for Windows.

Download the program from :

Extract the zip file and copy the bin folder in the zip folder to your preferred drive, let it be C.

You may give the path like C:\ffmpeg\bin

Once done, copy the mp4 file to be converted  ( sourcefile.mp4 ) to this path, ie C:\ffmpeg\bin.

Open command line and run the following commands :

cd C:\ffmpeg\bin

ffmpeg -i sourcefile.mp4 -target pal-dvd -ps 2000000000 -aspect 16:9 targetfile.mpg

You will find the converted video file in the same path, ie C:\ffmpeg\bin


Issue with CurlSSL on CentOS 4 ! ( Ye, too old :P )

We are talking about CentOS 4 and CurLSSL here. We may have some legacy users facing this issue in enabling CurLSSL.

This was the error encountered :

vtls/openssl.c: In function `Curl_ossl_init’:
make[2]: *** [vtls/libcurl_la-openssl.lo] Error 1
make[2]: Leaving directory `/home/cpeasyapache/src/curl-7/lib’
make[1]: Leaving directory `/home/cpeasyapache/src/curl-7/lib’
dryrun test ‘Find Curl SSL path for PHP 5’ did not return true
!! Dry run failed for ‘Cpanel::Easy::PHP5::CurlSSL’ skipping option !!
— End opt ‘CurlSSL’ —
checking for cURL support… no
checking if we should use cURL for url streams… no
vtls/openssl.c:753: error: `CONF_MFLAGS_DEFAULT_SECTION’ undeclared (first use in this function)

When building curlssl in /home/cpeasyapache/src/curl-7,  this error can be corrected by adding the following :


to  the file –


Once this is done, we were able to complete the curlssl compile with ‘make’

You should be able to implement this by moving the old curlssl away and manually installing the modified source tree;

mv /opt/curlssl /opt/curlssl.old

cd /home/cpeasyapache/src/curl-7

make install

EasyApache should use this installed version when it builds next and you will see CurLSSL enabled !