02
Feb 08

zip zip

It’s the simplest things. Really. I do the same dumb thing 50 times without ever stopping to think if there might be a better way. And then, when I stumble into it, I smack myself in the forehead.

Zips. I work with WordPress, and on my development install I’m constantly downloading new themes or plugins to try them out. I’d rather use the terminal than an FTP client, so I’m usually using wget to pull the zip file into the plugins folder, unzipping it, then deleting the original zip file.

It took me 6 months of doing this before I realized that I could add one single line to my bash_profile to ease all of the pain.

alias zz="unzip *.zip && rm *.zip"

It seems small, and it is, but my zen-like happiness quotient has been skyrocketing ever since.

Share and enjoy!

Popularity: 4% [?]


23
Oct 07

apt-get remove dovecot spamassassin postfix

Sweet! Google Apps / Gmail just got IMAP. There goes my final reason for trying to figure out email server configuration on my own. Now I can focus on the things that really matter – porting NES classic games to the ncurses interfaces. You haven’t played zelda until you’ve played ASCII graphics zelda!

Popularity: 9% [?]


20
Oct 07

Denial of (advertised) Service Attack!

Last spring, I posted this tutorial on how to use rsync to upload data to a Dreamhost server. It’s still the most popular article ever posted on that blog, even more popular than my liturgical poetry, if you can imagine.

The result was 25 new dreamhost customers who signed up through the link in that article.

Dreamhost then altered their terms of service to prevent this sort of thing, and made a big stink about it on their support site. I was willing to suffer through some of the downtime, the server chokes, the high load times and stick it out with them because of the huge bandwidth pipe and large dump truck they were offering.

Now, they’re limiting how we can use that bandwidth and data. Apparently, they didn’t really sell me a chunk of storage and a chunk of bandwidth, what they sold me was the ability to do one specific thing (host a website) up to a certain size and distribution load. What a load.

The new Terms of Service (TOS) now specify that you may not use Dreamhost for anything that’s not primarily related to one of your hosted websites. Here are some of the things I use my Dreamhost account for that, apparently, are no longer considered acceptable usage.

  1. Off-site backup of my studio computer. Ok, I get it. This is a pretty big strain on your system. Even though it was one of my reasons for maintaining such a large account, I’ll quit doing this and find another solution.
  2. WebDAV transfers between my students and I. I teach at a University, and I have a WebDAV folder setup for them to use to pass projects back and forth to me. It’s unclear to me why Dreamhost even offers WebDAV under the new TOS, since there’s no way to access that folder from an HTTP or PHP request. It is, by definition, unrelated to web hosting.
  3. WebDAV synchronization of my iCal calendars between my wife and I. Our lives would be a mess if we couldn’t sync calendars. Again, not related to web-hosting, now an illegal use of Dreamhost.
  4. FTP transfer of media files between my clients and I. I record and produce music, frequently music to video, which means I rely on the ability to transfer large media files to and from clients. One of the reasons I bought a Dreamhost account was to setup an FTP transfer account for this. Again, not related to web-hosting, not legal under their TOS.
  5. Mirrored backups of sites hosted elsewhere. I host many, many websites with other hosting providers, in addition to my sites with Dreamhost. I do regular rsync backups of these sites to Dreamhost, complete with intact folder structures and database archives. If one of those other hosts goes down, I can switch to Dreamhost and take that backup live. Is this a violation? I’m honestly not sure. Until I actually make the DNS switch and serve the data from Dreamhost, the files sitting on the server are, strictly speaking, just backup data, the kind of thing explicitly prohibited by their TOS.
  6. File Server for podcast files. I host a podcast with about 2,500 daily subscribers, and about 10,000 downloads per episode – I need it to be up 24/7, and Dreamhost seems to be able to provide about 22 hours at a stretch, before their central networking router goes down. So, I host the actual website at slicehost.com. There I have my own dedicated virtual server, no downtime, snappy response, it’s basically perfect. But the podcast uses about a terabyte of bandwidth a month, and that would be prohibitively expensive through slicehost. Instead, I host the actual podcast files on Dreamhost, and I reference them from the site on slicehost. Is this illegal? It sure seems to be, since I’m not hosting the site itself on Dreamhost, but I don’t know.

I think what the new Terms of Service boil down to is this: Dreamhost is no longer interested in working with power users. If you need to host a simple LOLcats homage site, by all means, come sign up with us. If you’re looking to actually USE the services we advertise though, like rsync between servers, WebDAV file sharing, FTP services, any backend sharing of data that doesn’t relate to your LOLcats site, then don’t bother. We’re not interested.

For those who feel unduly constrained by those limitations, let me be the first to invite you to Slicehost. Get your own dedicated bandwidth, your own chunk of harddrive, and then do whatever you want with it. Check out their Terms of Service: as long as it’s not illegal, hackerish, or spam-a-licious, they don’t care what you do with your server.

Come live the dream.

Popularity: 17% [?]


19
Oct 07

ubuntu upgrade rush

Note to self: don’t even attempt to use apt-get or aptitude during the week of a major distro release from Ubuntu. It’s not worth the pain of 8KB/s download times over a massive 1MB/s pipe.

Popularity: 12% [?]


03
Sep 07

Migrating your MySQL database from Dreamhost

Those of you who are still using the Dreamhostess with the Mostest (downtime) are probably looking for another solution for your webby goodness after the networking train wreck of the past few months (1, 2, 3, 4, 5, 6, you get the picture. By the way, if this sounds like awesome hosting to you, by all means, use my referral link when you signup with them! ).

You know I’m in love with Slicehost, for all the wrong reasons (they tease me with wait lists to even sign up, then they hit me with the pure root goodness, and I’m jonesing for another hit). I’ve got my Debian VPS all setup to roll, just need to get my data from Dreamhost over to the new server.

Website files? No problem. I used handy old rsync, and even put together a little bash script that I reference from a cron job, to do regular syncing of the Dreamhost data until I’m ready to go live with the new site.

But what about the database? My websites are all database driven, which mean no MySQL migration = no website! I tried using the phpmyadmin interface first, and simply exporting / importing the database from one install to another. Well, the database file is about 30 MB (this is a pretty big blog we’re moving), so that’s right out!

What’s a noob server admin to do?

mysqldump

Command Line to the rescue! Shut down that phpmyadmin, and crank up ye olde terminal. SSH into your new server, the one you are migrating to, and run the following command. The username and password in the first part should be for the MySQL database you are migrating FROM, the second part of the command should use the username and password you are migrating TO. Everything in CAPS should be replaced with your own details. No line breaks, put the whole thing on a single line:

Now that is Easy Breezy Covergirl!

IP Access on Dreamhost

If you’re moving your database away from Dreamhost, you’ll need to do a little unlocking of the database first. Dreamhost restricts access to your databases by IP address (or the resolved domain name equivalent). This a good thing, a security feature, but it will thwart our attempts to use mysqldump from our new server. No worries, you can add access for whatever IP your new server is on. Here’s how it works.

From your Dreamhost control panel, hit Goodies >> Manage MySQL. Locate the database you’re migrating, then click on the USERNAME next to the database. It will take you to a page that lets you manage the privileges for that user. Toward the bottom, find the option for “Allowable hosts.” It will look something like this:

allowable hosts

The %.dreamhost.com line should be there by default, allowing any dreamhost server to get at your data.

You will need to add a new line, containing the IP address (or IP range using wildcards) for the server you intend to migrate to. Note that the IP address they list beneath this is the IP address for your current browser connection to the control panel, not the IP address you need to use in order to allow server access from your new machine. Don’t be fooled!

If you are on Slicehost, you have a dedicated IP number that you can use here.

Save, exit, run the command line for mysqldump from your new machine, and you should get a clean import of your database into the new server.

Taste the Freedom!

PS. Don’t cancel that dreamhost account just yet, though. Sometime in the future, I’ll show you how I used .htaccess on my new server to treat my dreamhost account like a big ole’ hard drive for storing and serving large media files.

Make Dreamhost your bandwidth bitch!

Popularity: 26% [?]


07
Aug 07

Plate Up! Bash Script for Apache VHost Setup

In the sisyphian marathon of blowing up and rebuilding my server, I’ve had to go through the process of reconfiguring my virtual hosts for Apache2 several times. Well, that gets a bit tedious. How can my hands do the very important jobs of holding a beer up to my lips whilst scratching my man candy if they have to keep typing “sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/newdomain.com” over and over again?

bash it!

Fear not, my young linux adventurers. There IS a better way! Pop that cold beer, pull up some sweats, and feast your eyes on my hand dandy little bash script for automatically setting up yon website. Here’s what it does, in a nutshell:

  1. Asks for the new domain name
  2. Creates a new folder in the user folder with the domain name (/home/user/DOMAIN.COM)
  3. Creates a basic index.html file in the new domain folder that displays the name of the domain when accessed.
  4. Rolls 2d6 for Hacker Shield, to prevent magic-based attacks against your website. (planned for version 0.2)
  5. Generates a vanilla Apache vhost config file spelling out how Apache should handle requests for that domain.
  6. Generates an access log and an error log
  7. Generates a cgi-bin folder within the DOMAIN.COM folder

The script assumes you have Apache 2.2+ installed.

The non-compliance disclosure

Keep in mind that this script was written by me, for me, to help save me some effort. Because of that, it uses some non-standard locations for things. Why? Because I likes my shit where I likes my shit, that’s why!

I like having my apache vhost config files in my user folder, so that I don’t have to hassle with permissions. You can do the same thing with these two commands. First, make yourself a few new directories:

mkdir -p ~/www-config/sites-available
Then, link the apache site config folder to your new folder. Make sure this all goes on one line:

sudo ln -s /home/USERNAME/www-config/sites-available /etc/apache2/sites-available/

So where are things placed with this script?

config:
/home/USERNAME/www-config/sites-available/DOMAIN.COM

website documents:
/home/USERNAME/DOMAINNAME.COM

index page:
/home/USERNAME/DOMAIN.COM/index.html

access log:
/home/USERNAME/logs/DOMAINNAME.COM/access.log

error log:
/home/USERNAME/logs/DOMAINNAME.COM/error.log

cgi-bin:
/home/USERNAME/DOMAIN.COM/cgi-bin

The Script

Here ’tis. Click here to view or download a .txt file with the script.

http://commandlineidiot.com/scripts/siteup.txt

To use it, do the following:

mkdir ~/bin
cd ~/bin
wget http://commandlineidiot.com/scripts/siteup.txt
mv siteup.txt siteup
chmod 755 siteup

Now, to invoke the script, type the following:
. ~/bin/siteup

If you want to find out more about bash scripts, including how to handle permissions and setting paths so that your scripts can be called by name, I highly recommend the following tutorial by William Shotts Jr. at LinuxCommands.org: Writing Shell Scripts

Questions? Comments? Feck Off! I’m too busy drinking this cold beer and fiddling my diddly.

Popularity: 24% [?]