kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Smarty Security – Stop .tpl access

Posted on August 17, 2010

WHMCS uses the Smarty template engine. Which means your .tpl files are accessible to anyone that knows the path. Quite easy in WHMCS. Whilst not really a major security risk, its bad practise to all these files to be accessed directly.

Add this code into your .htaccess file.

  1. <Files ~ "\.tpl$">
  2. Order allow,deny
  3. Deny from all
  4. </Files>
Tagged as: No Comments

[Snippet] Stupid Simple cPanel Install

Posted on August 3, 2010

Open a clean server,

  1. cd /home && wget -N http://httpupdate.cpanel.net/latest && sh latest && /usr/local/cpanel/cpkeyclt

Go have your lunch. Maybe lunch +VAT depending on the speed of your server.

Tagged as: No Comments

cPanel MySQL Tuning

Posted on August 3, 2010

The default configuration for MySQL provided by cPanel is pretty barren. /etc/my.cnf

  1. [mysqld] skip-innodb

Thats it. One line. Its rubbish.

Here's mine to help you along the way. Its got some decent logging set, some decent cache and memory options for a shared server set and some helpful security settings enabled.

  1. [mysqld]
  2. max_connections = 200
  3. bind-address = 127.0.0.1
  4.  
  5. safe-show-database
  6. skip-locking
  7. skip-innodb
  8.  
  9. # MySQL 4.x has query caching available.
  10. # Enable it for vast improvement and it may be all you need to tweak.
  11. query_cache_type=1
  12. query_cache_limit=1M
  13. query_cache_size=32M
  14.  
  15. interactive_timeout=100
  16.  
  17. # Reduced wait_timeout to prevent idle clients holding connections.
  18. wait_timeout=15
  19. connect_timeout=10
  20.  
  21. # Checked opened tables and adjusted accordingly after running for a while.
  22. table_cache=512
  23.  
  24. # Reduced it to 32 to prevent memory hogging.
  25. thread_cache=32
  26.  
  27. # Reduced it by checking current size of *.MYI files.
  28. key_buffer=128M
  29.  
  30. thread_concurrency=1
  31.  
  32. log_error = /var/log/mysql/error.log
  33.  
  34. # log slow queries is a must.
  35. log_slow_queries=/var/log/mysqld.slow.log
  36. long_query_time=2
  37.  
  38. [mysqldump]
  39. quick
  40. max_allowed_packet=16M
  41.  
  42. [mysql]
  43. no-auto-rehash
  44.  
  45. [isamchk]
  46. key_buffer=64M
  47. sort_buffer=64M
  48. read_buffer=16M
  49. write_buffer=16M
  50.  
  51. [myisamchk]
  52. key_buffer=64M
  53. sort_buffer=64M
  54. read_buffer=16M
  55. write_buffer=16M
  56.  
  57. [mysqlhotcopy]
  58. interactive-timeout
Tagged as: , No Comments

Extending Advanced Policy Firewall with Brute Force Detection

Posted on August 2, 2010

In my previous article I discussed setting up the Advanced Policy Firewall on your servers. So now your servers are protected - but what happens when you get an attack at a legitimate service? SSH? MySQL? Apache? In a series of articles I'll discuss implementing some best practises to help avoid server nightmares.

Advanced Policy Firewall (for cPanel)

Posted on August 2, 2010

More retro software that has been with us for years - APF - Advanced Policy Firewall. A brilliantly robust and fool proof Linux script that acts as a wrapper for iptables.

Here's how I configure it for all the WHM/cPanel boxes I commission, although you can configure it for non-cPanel servers, just adjust your ports accordingly.

Tagged as: , , , Continue reading

Installing mytop on cpanel

Posted on February 19, 2010

abstract computer network in 3d over a white b...

MyTop is one of the best MySQL monitoring tools available, written by a MySQL guru, Jeremy Zawodny.

Its vital for monitoring your MySQL health, especially in a shared hosting environment.

mod_geoip Revisted including stopping spam in phpBB 2

Posted on February 15, 2010

I've recently moved a client's forum onto a new cPanel server, previously it was on a home-brew Ubuntu server.
So I had to install mod_geoip onto cPanel in CentOS. It wasn't as bad as I was expecting.

First off, we need to download the GeoIP libraries.

Installing mod_evasive on cPanel and/or Apache

Posted on January 29, 2010

This guide details how to install mod_evasive on cPanel to help protect against DDOS attacks, brute force attacks  and other irritants.

It uses an internal hash table of IPs and URLs and can temporarily block web requests to anyone requesting a large number of page views, or making many concurrent requests. Properly configured it can help evade DDOS attacks and keep your customers happy.

You can integrate it with iptables and hardware firewalls too if you like.

Enabling mod_deflate/gzip globally on cPanel

Posted on January 26, 2010

There's far too many reasons to mention why you should enable mod_deflate to gzip your content served by Apache. Simply put, it makes it go fast.

You can enable mod_deflate in cPanel really easily with /scripts/easyapache. Easy.

Installing memcached on CentOS (cPanel)

Posted on January 23, 2010

Welcome to hell. No really, compared to installing memcached on Ubuntu, CentOSs really sucks. CentOS really sucks for package management.  Really sucks. Anyway, on to the point.

Here's how I installed memcached on CentOS, which I mainly use for cPanel.

Tagged as: Continue reading
Page 2 of 3123