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 : https://s3.amazonaws.com/solutions-reference/ops-automator/latest/ops-automator.template

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
snapshot-time=3
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 –

Ec2DeleteSnapshot.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 127.0.0.1:8000 (*) 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 = 127.0.0.1:8000

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 127.0.0.1

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/config.inc.php ( on centos this would be the path )

2) Find the section –

/*
* End of servers configuration
*/

Just above it, type in the following :

$i++;
$cfg['Servers'][$i]['host'] = 'xxx.rds.amazonaws.com'; ( 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/config.inc.php 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 domain.com. 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 test@domain.com, you’d change this to:

==============
test.domain.com.
==============

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 :

https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-20161104-b4e9252-win64-static.zip

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 :

#ifndef CONF_MFLAGS_DEFAULT_SECTION
#define CONF_MFLAGS_DEFAULT_SECTION 0x0
#endif

to  the file –

/home/cpeasyapache/src/curl-7/lib/vtls/openssl.c

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 !

 

PHP Error | HTTP Error 500.0 – Internal Server Error | C:\Program Files\PHP\vX.0\php-cgi.exe – The FastCGI process exited unexpectedly

IIS-PHP-Logo

After installing PHP on your IIS,  you might be stuck with the following error :

Http Error 500.0 FastCGI process exited unexpectedly. “

This error occurs when the Visual C++ Redistributable file to handle CGI process is not present in the system.

To resolve this issue you just need to install proper VC++ redistributable file.

So if you are facing this issue, and if the system does not have proper VC++ version, then just install the version of VC++ supported by the PHP version installed on your system to resolve this error.

List of PHP versions and the VC++ versions supported by it:

PHP version MVC version Supported VC++ version
PHP 7.0 VC 14 Build VC ++ 2015
PHP 5.6 VC 11 Build VC ++ 2012 / update4
PHP 5.5 VC 11 Build VC ++ 2012 / update4
PHP 5.3 VC 9 Build VC ++ 2008

So happy troubleshooting folks . 😉