31.5.08

Fast and Easy Custom WordPress User Registration

Alternative Registration form for WordPress Registers and Logs in a user immediately, no emailed password- user chooses.This is an insecure method due to no email validation, but still pretty sweet!

read more | digg story

Upgrading to DreamHost Private Servers

From:

Problems migrating to DreamHostPS

Here are some issues I experienced during migration and the solutions I’ve used.

During this process it is important to note how helpful the DreamHost Support Staff were in putting up with my sometimes overly technical and detailed support requests. Thanks John, Brian, and Robert R!

PHP and HTTPD processes hogging all memory

Unlike on shared hosting accounts, where DH technical people have set up a very robust system, it appears they are missing the expertise of a past employee or something because this new setup is not as robust.. YET!

For instance I started out my account CPU and memory at the MAX (2300 MB / 2300 Mhz) but my sites were all still taking forever to serve content, simply because instead of on the shared servers where user processes and HTTPD instances are more controlled, this account seems to not have very well-thought out limits on it. So if 100 people asked for a page on my site, this server loads up 100 HTTPD processes under dhapache user and loads up 100 processes for the custom-compiled php.cgi I am running. This sounds like a cool thing but in reality it takes up so much of my memory that my bash shell login under SSH runs out of memory and won’t even let me do a simple ps, and it just keeps serving 503’s to anyone else who requests something on my site. DH will have to fix this soon or someone will launch a DDOS attack that will cripple them, unless a googlebot does it first!

Solution
I contacted support and received a very friendly and prompt reply suggesting a bad script and offering to setup a process watcher and killer, which I accepted. Eventually I located the problem to be an ErrorDocument 500 directive in my .htaccess that was pointing to a php file instead of a static .html

No crontabs or cronjobs

None of my crontab files were moved to my new server and in fact I was receiving permission denied just to access my crontab.

Solution
I contacted support and they installed new crontabs for me and offered to copy my old ones.

Static IP Changed for site with non-DreamHost DNS

One site uses DNS from Network Solutions, so when my site was migrated and got a new static IP address, my site went down. It would have been nice and should be expected that in this situation DreamHost would alert you that the change is going to happen so you can update your DNS without your site going offline.

Solution
Logged into my Network Solutions account and updated the DNS for my site to point to the new Static IP.

SSH Hosts, Authorized Keys Broken

Some of my sites and user accounts use passwordless SSH to make some things work, and all of these were made useless when I moved to my new private server.

Solution

  1. Logged into my user accounts with SSH
  2. Deleted the old files in folder .ssh
  3. Created new keys and added them to other accounts
  4. Logged in to new accounts to add to host files

Old Server and Static IP References in Site Files

I have some pretty technical and complex cgi’s, .htaccess files, shell scripts run by cronjobs, php scripts, etc., on some sites and shell accounts, and many of my files contain code to the Static IP and/or dreamhost server, either for access control or for faster connects by connecting straight to an IP instead of having to perform a DNS lookup. So when both the Static IP’s and dreamhost server changed it broke all my files.

Solution
Basically I knew I had to search all of my files and replace the old IP with the new IP. I also had to search files relacing the old server with my new server. To make life simpler, I wrote a simple shell script that I run from my account while logged in using SSH that does this automatically with the added feature of asking me if I would like to make the replacement for each file it finds, which is nice because I don’t want to replace this for old log files and misc stuff.

dreamhostps migration shell script

#!/bin/bash
# Version 1.0 by AskApache 5/29/2008

shopt -s extglob
renice 19 $$

OLDSERVER=208.113.183.103
NEWSERVER=208.113.134.190

FIXFILES=$(grep -R -l -i $OLDSERVER $HOME/!(Maildir|logs|backups|source|tmp|doit|php5|php526|ip_abuse) 2>/dev/null)

for thefile in ${FIXFILES[@]}; do
if [ -f "$thefile" ]; then
echo -e "\n\n\n\n"
echo "___________________________________________________________________"
echo "Name: ${thefile}"
echo "Type: $(command file -b ${thefile})"
echo "Size: $(command du -hs ${thefile}|awk '{ print $1}')"
echo "Matching Lines:"
grep -i --color=auto $OLDSERVER $thefile
echo -e "___________________________________________________________________\n"
echo -en "Replace occurances of $OLDSERVER with $NEWSERVER? [y/N] " ; read -n 1 ans
case "$ans" in
n|N) echo -e "\nSKIPPING..."; ;;
y|Y) echo -e "\nREPLACING..."
cp $thefile $thefile.b1 &>/dev/null
cat $thefile.b1 | sed "s/${OLDSERVER}/${NEWSERVER}/g" 1>$thefile
rm $thefile.b1 &>/dev/null
echo "DONE"; ;;
esac
fi
done
exit 0

15.5.08

Firefox popup- page redirected new location, resend form dat

If you see this message in Firefox."This web page is being redirected to a new location. Would you like to resend the form data you have typed to the new location?"

read more | digg story

9.5.08

Favorite .htaccess mod_rewrite examples

mod_rewrite rewrite examples for .htaccess

read more | digg story

SEO detailed Robots.txt

Very detailed tutorial dealing with the robots.txt file. Shows examples for google and other search engines. Wordpress robots.txt and phpBB robots.txt sample files.

read more | digg story