Recent Entries
- Recovering from a Broken Partition Table
- RewriteRule in htaccess vs httpd.conf
- Running PHP through mod_fcgid
- How They Got Your Password
- Installing mod_reqtimeout on cPanel
- Following the Hacker — passwords
- Using Nginx as a reverse-proxy
- Dead-simple templates in PHP
- Tell-a-friend SPAM
- PHP mail via SMTP
Code
This section centers around code that you can either download or cut-and-paste for your own purposes. The following articles contain sections of working code accompanied by explanations to help you better understand what the code does.
Running PHP through mod_fcgid
There are two ways to set up PHP to run via mod_fcgid. The majority of the steps are the same for both, the only difference is in your Apache VirtualHost configuration. This document will explain both. Step 1: Installation and Preparation Chances are you’ve already done these steps Install the PHP CGI binary Install and […]
Section: Code
Installing mod_reqtimeout on cPanel
The Apache module mod_reqtimeout is a simple and effective way to protect yourself from the Slowloris attack. But the cPanel team still does not include support for mod_reqtimeout in the EasyApache build utility, even though the module is a core part of the Apache web server distribution. But that doesn’t leave us completely powerless: we can add this support ourselves.
Using Nginx as a reverse-proxy
Sometimes the simplest way to deal with Apache problems and exploits is to install Nginx (“Engine X”) as a reverse-proxy in front of Apache. Often this setup is temporary for the purpose of handling a DDoS attack or the like.
Section: Code
Dead-simple templates in PHP
Often what you’re really looking for is just a simple master template inclusion system. Allow me to introduce an alternative. It’s simple, it’s intuitive, and it’s easier to work with than whatever mess you narrowly avoided making.
PHP mail via SMTP
Depending on your server setup, you may find yourself needing to take closer control of how mail is sent from your site. Below is a drop-in replacement for PHP’s mail() function which uses the Mail::send function from PEAR internally.
Installing mod_cloudflare on cPanel
Here you’ll find an installer script that adds mod_cloudflare to your EasyApache build system included with cPanel servers. The CloudFlare module automatically translates visitor IP addresses to reflect the visitor’s original IP address rather than the IP address of the CloudFlare proxy servers.
Transferring a MySQL database via SSH
Normally the preferred way to transfer a MySQL database is to use `mysqldump` to create a database backup, possibly compress it with gzip, transfer that backup file to the new server, and then load it using the `mysql` command-line tool.
But what if you wanted to do it all in one step?
Pasting Files Into a Text Console
Traditionally it’s been remarkably easy to copy and paste text between programs and between terminal sessions, but it’s been somewhat more tedious to copy files around.
Command-Line MySQL Backups
Using web tools for MySQL backups can be convenient, but sometimes it doesn’t work so well, such as when you have a database that is too large. So it’s good to know how to do it from the command-line. Here’s how you do it.
Force SSL with .htaccess
Here’s a generic .htaccess excerpt that you can use to redirect users to the SSL-enabled version of the page they requested. Just drop it into any directory you want to enforce security on, and you’re done (no modification necessary).