21st Feb2013

Speed up your WordPress with CloudFlare!

by Gyro

My web hosting services provider ServerPilot has integrated CloudFlare into the cPanel!

CloudFlare is Content Deliver Network (CDN) with 22 data centers across the globe, and according to google there are only 9 web services in the world that have more traffic than CloudFlare. It is free, and it will make your website's load lightning fast from anywhere in world!

Even if your website is hosted with a slow hosting provider elsewhere, you can use CloudFlare for free!

If you give CloudFlare a try, make sure you also get the CloudFlare WordPress Plugin! WIth it, you can turn on the "Developer Mode" from your WordPress admin panel -- a must when updating your site, as changes won't show up immediately if the Developer Mode is turned off.

Enjoy! :enjoy:

1174

21st Feb2013

Restore large mysql databases with nginx 504 Gateway Timeout

by Gyro

I had to restore a 36MB sql database today and kept getting a "504 Gateway Time-out".

After playing around with the config files, adding fastcgi_read_timeout to the settings for php5-fpm, and fiddling with the php.ini, I realized that this can be accomplished with one single line using ssh:

Assuming that you have packed the .sql file into a zip file, and you are currently in that folder:
# gunzip < databasebackup.sql.gz | mysql -DDATABASENAME -uUSERNAME -pPASSWORD

DATABASENAME = name of the database
USERNAME = mysql username
PASSWORD = mysql password

I hope this helps when trying to restore large mysql databases with nginx 504 Gateway Timeout

2337

11th Feb2013

WHMCS: Round up product prices for secondary currencies

by Gyro

Today, I actually assisted my hosting provider in setting up secondary currencies in WHMCS, the billing and support system for/from cpanel! :)

They only wanted full numbers for the monthly breakdowns, so when they click "Update Prices" in the Currency Settings and a product would cost 1233.37 the price gets automatically rounded up to 1234.00.

Unfortunately, WHMCS doesn't offer this feature, so I suggested to setup a script on a secure location that they can trigger after they update the currency conversion rates and product prices. Below is the sql query that goes through all secondary currencies (1 = default currency) and rounds up the values, so that the setup fee and all monthly prices are full numbers.

The script itself would run a simple MySQL query:

UPDATE tblpricing SET
msetupfee = ceil(msetupfee),
qsetupfee = ceil(qsetupfee),
ssetupfee = ceil(ssetupfee),
asetupfee = ceil(asetupfee),
bsetupfee = ceil(bsetupfee),
tsetupfee = ceil(tsetupfee),
monthly = ceil(monthly),
quarterly = ceil(quarterly/3)*3,
semiannually = ceil(semiannually/6)*6,
annually = ceil(annually/12)*12,
biennially = ceil(biennially/24)*24,
triennially = ceil(triennially/36)*36
WHERE
currency != 1 AND
id = id

you could replace

currency != 1 AND

with
currency = 2 AND

or
currency IN(2,3,6) AND

etc

Enjoy :enjoy:

2275

04th Feb2013

Ubuntu update/upgrade fails with dpkg error message

by Gyro

Today, my Ubuntu was unable to install update.

I got this error message after trying to update Ubuntu:

dpkg: error: parsing file ‘/var/lib/dpkg/available' near line 15054 package ‘unity-common':
duplicate value for `Architecture' field
E: Sub-process /usr/bin/dpkg returned an error code (2)

After some research and trial'n'error, I came up with this solution:

1.Clear the content of the "available" file
# sudo nano /var/lib/dpkg/available
or
# sudo rm /var/lib/dpkg/available
# sudo touch /var/lib/dpkg/available

2. "Reset"
# sudo dpkg --configure -a
# sudo apt-get clean

3. Update/Upgrade again
# sudo apt-get update
# sudo apt-get upgrade

That should be all!

Step 2 may be unnecessary, but I have no way of testing it again… maybe someone with the same or a similar problem can try it without step 2 and let me know? ;)

1364