Easy WordPress Client Management via Command Line

I’ve had a WiredTree VPS for about 3 months now. In addition to hosting about 5 of my personal sites on it, I also host a few family members blogs and some pro-bono stuff I’ve done for past clients.

Anytime I get ready to create a new account on the VPS (which, in turn, creates its own cPanel account just as if one had purchased a shared hosting account) I always dread the next step of downloading the latest version of WordPress, grabbing the latest copies of what I consider ‘base-install plugins’ (that is, plugins that I always include in a WordPress installation. These include Absolute Privacy, Google Analyticator, All-in-One SEO Pack, Next-Gen Photo Gallery, WP-Optimize, WP Super Cache, Google XML Sitemap Generator, Contact Form 7, and Akismet.) [Note: I don’t always activate all of these in each build, but I do like to have them handy if I need them. In today’s ‘Unlimited Storage Space’ environment, these small plugins don’t get in the way.]

After going through this download, unzip, upload, and activate process about a hundred times, I figured there had to be an easier way. Yes, I know you can auto-install plugins (and even WordPress, via Fantastico or Softaculous) but I don’t pay for either of those two auto-installers on my VPS because, well, I don’t need them. Plus, I run my PHP as DSO on my VPS rather than suPHP, so there can easily be permissions issues since I run all processes as the ‘nobody’ user.

So, I began thinking…couldn’t I download the latest WordPress build, download the lastest plugin versions I want, put the plugins, extracted, in the wp-content/plugins folder and even toss in a few ‘Coming Soon’ or ‘Maintenance Mode’ themes in the wp-content/themes/ folder. Then, when I create a new account, I could just explode the zip file into the newly created public_html directory and the only manual process I would have to go through would be setting up the MySQL database and editing the wp-config. file–a process which I can now due in under 5min.

Well, that’s exactly what I did. I created the folder I wanted and zipped it up. Then I dropped it on my VPS in a high level folder and tried exploding it into a directory. What I noticed was that, since I had zipped things on my Mac and then uploaded to a Linux box, I had the nasty _MACOSX folders in each directory…making the zip file larger than it needed to be AND making things convoluted.

I did a bit of Google research and found that I just needed an archive utility that would zip ‘Windows Friendly’ files which simply excludes those Mac folders. There were several programs out there, but I settled on one called YemuZip for it’s simplicity and cost (free!). It has a simple drag-and-drop interface that worked perfectly.

I deleted the ugly directory I created the first time using the fantastic “$ rm -rf /ugly-directory” command, uploaded the newest zip and exploded it. This time, it worked like a charm. I quickly tied it to a database I had standing by and was able to log in, with themes & plugins intact, in a matter of seconds.

This process certainly beats the heck out of downloading WordPress each time and and then subsequently downloading plugins. Below, I’ll share the Linux commands for accomplishing this.

How to do it

Once you’ve created your zip (using a program like YemuZip if you’re on a Mac!), upload your wordpress.zip file to a neutral folder on your server. (By neutral, I simply mean a higher level folder that isn’t likely to be deleted…something like /home/.)

Then, you’ll want to ‘explode’ (uncompress) the zip file to a directory on your server.

You’ll need to have navigated to the directory where your recently uploaded wordpress.zip lives.For me, that means logging into my VPS via Terminal (SSH) and the using the bash command:

cd /home/

…which simply tells the server to ‘change directory’ (cd) to the /home/ folder. Then, you have two options for inflating: (1) you can pre-create the destination folder or (2) you can tell the command line to create it for you. I typically follow the latter, so my code looks like this:

unzip wordpress.zip -d /home/USER/public_html/destination

That “-d” tells Linux to create the referenced directory, “destination”, even though it doesn’t exist. If you’re inflating to a folder that already exists, you’ll simple leave off the -d.

The server-side explode takes about 2 seconds and then everything is ready for you to start configuring. In my opinion, this is the fastest way of quickly installing WordPress, fully configured, on a new server. (There are also config files you can include in your install to further personalize things, but I avoid those in most cases unless I’m setting up 5+ sites for the same client. You can Google that topic for more info.)

If you’re interested, I’ve included my latest ‘wordpress.zip’ here for you to download. All the plugins & core files are up-to-date as of the date of this post and it includes WP v. 3.0. I hope you find it useful. FYI: The unzipped folder is 18.6 MB. The zipped file is 6.0MB…another pro of uploading the zip to the server and inflating it there rather than the other way around.

Download pre-built WordPress.zip.

Do you have any tips or tricks for making things easier that I haven’t thought of? Please share you tips with us! Oh, and for what it’s worth, I also delete the “Hello Dolly” plugin…you would think Matt and the team would have gotten rid of this by now…

Shrimp and Bowling

On the way home from work tonight I drove passed an elderly black man, carrying two heavy bags, and walking with a slight hinderance. I thought about pulling over and offering him a ride to his destination–I wasn’t in a hurry to get anywhere–but I continued on to the on-ramp for HWY 31 S, drove back over the mountain, and started to turn toward home when I felt like I could have done something for the man.

I exited the highway a few blocks shy of my street and turned back toward downtown. I didn’t know if I would be able to find the man again, I had only seen him while stopped at a red light for a few moments…now, 10 minutes later, he could be anywhere. But, I drove back to where I saw him and made rounds up and down streets, about 4 blocks in all, until I came across him again.

I moved some personal items out of the passenger seat, pulled up beside him and rolled down my window: “Hey friend…need a ride?” He looked at me puzzled at first…I could tell he was trying to get a read on me…was I dangerous? Was I a cop? After he decided he would be better off in my car than hobbling down the street much longer, he accepted my offer.

He opened the door and placed his large bags in the floorboard. His white t-shirt and oversized blue jeans were drenched in sweat and he smelled rather…ripe. He had trouble climbing into my SUV (I soon found out he was 62 years old) and his wet jeans made the climb in cumbersome. After 3 failed attempts to climb in, he turned to me and said, “Hey man, pull me up.” So I took off my $250 sunglasses, unbuckled my seatbelt, and leaned over to grasp his sweat soaked arm & shirt to pull him up into the vehicle.

“Where ya going?” I asked. “To see my son…but I can’t get him on the phone. He was s’posed to meet me and put me up for the night…said I could sleep on the floor. Just take me a few blocks up and I’ll wait fo’ the bus to come.” “Alright,” I said. We drove a few blocks up, a very short 2 blocks to be exact, and he said I could drop him off here…I felt like I hadn’t helped him much…If I had picked him up when I first saw him, I could have saved him a mile or so…the two blocks seemed rather insignificant. I reached into my pocket and the only bill I had was a single dollar. I felt like that would be more of an insult than a benefit…”You in a hurry?” I asked…”Huh?” …”If you’re not in a hurry, let’s get you a few dollars for the night. I’ll go up a few blocks to an ATM.” “Yea yea…let’s go!” He was very excited about the idea of having some money in his pocket.

As we drove a few blocks to Wachovia, he told me his name was Jerry. He had grown up in Avondale, just outside the city. He was 62 and had two grown children. He was a war veteran, Vietnam, and had been staying a shelter for the past few nights that cost $25–a special for veterans. I told him my name was Ian. He began telling me a little bit more about his situation and then seemed very interested in my truck. “This a’ good truck…a real truck. My son had $40,000…told him to buy a good truck, a truck like this, and then he wouldn’t have to worry ’bout nothin…but he didn’t listen to me.” Most of his stories didn’t have a point to make…he was just making small talk. Glad to be riding and not walking. When we reached the ATM, I took out $100. I was careful not to let him see how much I withdrew, but I immediately handed him $20 and said “…here. You hang on to this.” He was very gracious.

I was on my way home to eat dinner when I first saw him, so food was on my mind. “Have you eaten anything…are you hungry?” I asked…”No..I mean, Yeah…I ain’t eaten nothing.” “What do you want? Anything…” I offered. “Chicken…let’s get some chicken. You know where Church’s is?” I didn’t. “No, tell me where to go.” He directed me about a mile further away from the “civilized” downtown that I typically stay in during my 9 hour days in the city for work..I normally don’t stray more than a few blocks from the heart of downtown. But, it was still daylight out, and the man was elderly. Between me and the 6″ serrated knife in my door panel, I wasn’t threatened by him.

We pulled into the drive through and I asked him what he wanted. “A two piece…with sum mashed potatoes…extra gravy….wait, no, that’s $5..uhm…” I could tell he didn’t want to spend the $21 dollars I had already given him on his dinner. “Don’t worry about the price…get whatever you want.” The most expensive thing on Church’s menu is about $8 so there wasn’t much harm in offering him the farm. “Uhm..then lemme get the shrimp. #8…with a Coke…no, wait….a Sprite…and mashed potatoes….with extra gravy.” I placed his order and we drove around to pick it up at the window. The total came to just over $8.

While we were waiting on his food I asked him where he was staying that night. “Well, I was supposed to stay wit my son but he won’t call me back.” I could tell he loved his son…he told me that his son took care of his mother, Jerry’s ex-wife, every day…checking on her and locking up her house for her at night. Jerry was thankful for this but I could tell his son wasn’t interested in helping his father too much and I saw the disappointment in Jerry’s face as he continued to tell me about his family.

I paid for his shrimp with a $20 and handed him the change back from the girl at the window…about $11. Jerry then counted the cash I had given him…he had about $32 at this point. “Well, I can stay at the shelter tonight. I can’t shower there but they’ll let me sleep for $25.” “Where do you stay when you’re not at the mission?” I asked. “Usually on the street…this one time I stayed in a motel though…it was $50.” Jerry told me. I asked him where that motel was…I didn’t think I’d have much of a chance trying to check him into the Marriott in his condition. “It’s just up the street there. The Tourway Inn…but it’s $50,” Jerry said. I told him not to worry about the room, just tell me how to get there. He directed me about half a mile back toward downtown and we pulled into the motel.

We went in and Jerry explained to the lady behind the bulletproof glass that “..my boy here is gunna put me up for the night. Big pimpin'”…that’s what he kept calling me, ‘Big Pimpin'” My truck and job, and the ability to take money out of an ATM made me a big shot in his world. The lady said the room would be $55. Jerry was immediately upset. “Las’ time it wuz only $50..why you trying to do Big Pimpin’ like that?” “Don’t worry about it, Jerry..it’s fine,” I said. I gave the lady three twenty dollar bills. When she gave me the $5 in change, I handed it to Jerry, “…here, hang on to this.” Jerry now had about $37.

He struggled to get back up into my truck and we drove across the lot to his room…room #132. He asked me if I liked to shoot pool, “Not really.” He then asked me if I liked to bowl. I found this a strange question because I had a hard time picturing this older, overweight man having the coordination to bowl. “Yes…I like bowling.” “Well, maybe we can go sometime. When my ship comes in, I’ma look you up, Big Pimpin! Have you got a number?” I didn’t want to give Jerry my main telephone number, nor one of my business cards, for fear that he would show up at my office. He only knew that I was an account manager for a technology firm. I gave him one of my secondary telephone numbers, my Google Voice number to be exact. I wrote it on a small piece of paper along with my first name, “Ian.”

Jerry plopped down out of my truck…shook my hand, twice, and continued thanking me for everything. He got his two bags, his shrimp box, and his Sprite out of the truck and then he asked me to give him “dap”…a term I was familiar with from high school…it’s black slang for the bumping together of fists, one on top of the other. So, I did.

After giving Jerry the initial $1, and then a $20 at the ATM, buying his Shrimp & Potatoes for about $8.50, giving him the change of about $11, paying for his $55 motel room and giving him the $5 change, I was wiped out. I remembered that I normally keep some cash under my cup holder for fast food. When I checked, I had a single $20. I gave it to Jerry and told him to be well. Jerry was happy to have a full meal, a safe place to sleep, and now, $57 in cash. He said he couldn’t wait to go inside, eat, and be able to take a shower…something he hadn’t done in a long time.

Before walking inside, Jerry told me that just earlier that afternoon, he stopped outside a restaurant in downtown Birmingham and asked for some water. The manager, who Jerry made a point to tell me was white, gave him a bottle of water but then told him “…not to be running off his customers.” Jerry was insulted by this…he was simply down on his luck with no means to really better himself. He was thankful that “…there are other, kind people out here who help folks like me.”

Jerry mentioned God, or “The Lord,” several times during our car ride. He referenced “the Lord” in the way that a grandmotherly black woman would…in that sort of “all things which are good in this world” and less in a “personal relationship” kind of way. He called me his ‘guardian angel’, thanked me one last time, and I waited to watch him get into his room safely. I then turned out of the motel parking lot, went three blocks over to I-65S and headed toward home.

One question Jerry asked me, but didn’t stop talking long enough to let me answer was, “Why did you stop? So many people drove by in cars but nobody stop to help me. Why you stop?” Again, he didn’t allow me to answer…he went right on about his good luck and with gratitude. I didn’t tell Jerry that I passed him by the first time or that I drove around Birmingham’s one-way streets looking for him. I didn’t answer Jerry at all. In fact, looking back, I said very few words during the whole ordeal…Jerry was glad to have someone who would listen…and someone, at least for the moment, who seemed to care about him and his plight in life.

Jerry wasn’t depressed. He had a hard life, but he was in good spirits. He may have even put on a slightly embellished story at times, thinking to himself, “This rich white boy might give me some more money.” I’m not naive…I was able to discern when Jerry was putting on a bit…but he never begged, never asked for anything more than what I offered, and always said thank you. I took $100 out of the ATM and I didn’t intend to have any left once we parted ways. I had been doing well recently and $100 wasn’t going to break me. I was glad to help.

No doubt my mother will cringe when reading this. Though I am one month shy of turning 27, I’m still her youngest…her baby. And, it wasn’t but 6 months earlier than I picked up a man hitchhiking from Birmingham, south-bound. It was clouding up and I could tell the bottom was about to fall out. I was headed home to Dothan and I thought if he was going South, I could help him. His name was Paul and I took him as far south at Montgomery and dropped him at a truck stop…he was headed to Mobile, across the state from my destination in Dothan. Not 5 minutes after picking him up, a storm of massive proportions did, in fact, blow in. I would have felt awful knowing he was out there, on the side of the interstate in that storm. My mother was very upset at my having stopped to pick him up, she immediately thought the worst. And, of course, I realize that helping people these days isn’t the same as it used to be. There are bad people out there who will take advantage of you. With Jerry and Paul, I was quick to survey the situation before inviting them into my truck. Each time, my large knife was by my side, and had I had a bad feeling about either of them after pulling over, I wouldn’t have hesitated to move on. But, in both cases, I’m glad I didn’t.

…I don’t know why I stopped to pick up Jerry, though. Or rather, and maybe even more surprisingly, why I drove all the way home, almost, just to turn around and search for him. God has blessed me, and my family, immensly in this life. I have more than I need and never go without. I’ve never known what it is to be hungry, or not to have a clean bed to lay in. I’ve never once worried about where I was going to sleep or where my next meal would come from. Like the song says, “…even my worst days aren’t that bad.”

Just before I turned my car around to pick up Jerry, before I made the decision to turn around, I thought “I hope he’ll be alright…I wonder what his story is.” God brought to my mind a passage in James, chapter 2, vv. 15,16. “Suppose a brother or sister is without clothes and daily food. If one of you says to him, “Go, I wish you well; keep warm and well fed,” but does nothing about his physical needs, what good is it?” This passage kept running through my head, and ultimately, is what caused me to turn around.

To be cliche, I think it was I who received the blessing by helping Jerry out tonight. The $100 I invested into him will hardly be missed but I’ll always remember the opportunity I had to help him, if only for a day. I hope Jerry sleeps well tonight, in a clean bed and on a full stomach. I hope he thanks God for the stranger who stopped to help him and is encouraged as he goes about his day tomorrow. I hope he doesn’t soon forget “Big Pimpin” as I know I won’t soon forget him…and who knows, maybe we’ll go bowling one day.

Rules for Eating Out with Friends

Several weeks ago, I stumbled upon the website Archive.org, a site that allows you to enter a URL and see that website on many different dates from the past. When I was first starting to blog, back in High School, I simply edited an html page, added my own timestamp, and uploaded my own pictures…this was just before I began using versions 1.2.* of WordPress. Anywho, I went back through some of the archives and found this gem, which I thought I would repost.

Ok, how many of you have been hungry before? Let me see a show of hands; and out of those, how many of you have jumped in a car with friends, family or strangers (if that’s your thing) only to have someone ask the inevitable question: “Where do you all want to eat?” Yea, just about all of you! Well, this is a common occurrence in my daily life and living in a large city with tons of places to choose from, the conversation can go on for quite awhile unless someone REALLY knows what they want to eat and no one else minds. With that in mind, I’ve come up with the Official Rules of Choosing a Restaurant when Eating out with Friends. They are as follows (and yes, I’m willing to make amendments if they are valid ones.)
RULES FOR 2 PEOPLE IN A CAR:
1.) If someone asks you go to a specific restaurant with them and you agree, the discussion is over.
2). If someone asks you what you want to eat and you reply with “It doesn’t matter” or “I don’t care”, then whatever he/she suggest goes…end of discussion.
3.) If you are allergic to any type of food, or if a specific type of food upsets you, you must make this known up front so there is not confusion later.
4.) If someone suggests a restaurant and you do no want to eat there and you make your desire known, it is now up to you to suggest the next choice.
5.) If someone pulls the “I choose last time, its your turn to choose” card, you must play it…it is a valid rule and trumps most others.

RULES FOR 3 OR MORE PEOPLE IN A CAR:
1.) If someone suggests a restaurant and no one in the car has a strong disagreement with the choice, accept it and eat. End of discussion.
2.) If someone suggests a restaurant and another passenger refutes it as a choice due to any number of reasons (price, quality, service, reputation, etc) it is now the refuter’s turn to suggest a restaurant. This rule may repeat itself as many times as necessary.
3.) If a food allergy or preference is held by any member of the party, the others in the car must respect that preference without asking possibly embarrassing questions such as “Does it give you gas?” or “Does that make you sick?”
4.) Once a restaurant is decided on by all members of the group, the discussion is over and all should make an attempt to find something on the restaurant’s menu that appeases them. They can always refute it on the next go’round.
5.) Once a restaurant has been refuted (for any reason) it may not be brought up for discussion again unless it is by the person who refuted it.
6.) At any time the driver of the car in which the party is traveling in may veto any suggestion for a restaurant. So as not to have a loophole, the driver may only veto as many restaurant’s as there are passenger’s in the car, and referring to rule #5, a refuted restaurant can not be brought back up by another passenger.

I hereby declare these the official rules for choosing a restaurant to eat at amongst friends. These rules may be amended at any time I see fit. These rules are to be held to the strictest standards. Feel free to print and distribute the rules to your friends whom you are likely to eat with so that there is no question about proper refusal procedure. If you adhere to these rules as they are written, the process for choosing a destination should be swift and without bodily harm.

Add Max Width to WordPress Image Uploads

The core WordPress media manager does a pretty good job of helping folks to automatically manage their images. Depending on your setup, WordPress will look for the GD Image Library on the server (you can also set it to ImageMagick if you prefer…like I do) and resize your images, auto-create thumbnails, and perform other neat on-the-fly chores that would take awhile to do if you blog a lot.

The later versions of WordPress will take a large image and create 4 different images once you upload it: a thumbnail, small, medium, and large, along with the original. You can then select which image you would like to insert into your post.

Over the past two weeks, I’ve been helping my Mother move from a Blogger blog to a new WordPress blog. She had been wanting the ability to have a wider “content” area and wanted a fresh new look. So, we found her a template that would work well for her and I modified it to fit her needs.

One of the issues we had, once we launched her new blog was image sizing. Sometimes she’ll upload images from her digital camera (which are really large) and other times she’ll grab smaller images from a Google search to include in her posts. It was confusing to her to not have all the size options each time she uploaded an image. See, if a photo is relatively small when you upload it, you won’t get the options for a small or medium image, only the original. Conversely, if a very large image is uploaded and she chooses ‘large’ or ‘orginal’ it may be too wide for the content area and essentially ‘break’ the layout.

Fortunately, there is a simple solution. Locate your theme’s main functions.php file (typically found in the theme’s root directory), and add the following after the opening < ?php:

$GLOBALS['content_width'] = 800;

This will set the maximum width for uploaded images to 800 pixels. You may, of course, adjust as necessary. Now, when my Mom uploads an image, she always knows to choose the ‘original’ option, because it will never be ‘too large’ for the content wrapper…of course, she doesn’t know that this piece of code is in place…she just knows that it works. And, as they say, ignorance is bliss.

Redirecting Visitors on Unix Servers

There are many times when one may wish to redirect a visitor on his or her site. Say for example you used to have your blog a yourdomain.com/blog but now you want it in the root; you could redirect all traffic from the /blog directory back to the root / directory. Or, perhaps you’re moving to an entirely new domain; you could redirect all traffic from one domain to another. Like the first example, if you used to have webpages in a subfolder (like, /articles/article1.html) and you change your structure directory, you could redirect traffic from /articles to /entries.

One could come up with hundreds of reasons to redirect traffic and since there are so many reasons to redirect, there are a handful of ways to accomplish the redirection. The easiest and cleanest method is by editing your .htaccess file. The .ht (or, hypertext) access file is a directory-level configuration file that allows for “decentralized management of a web server1.” Incidentally, the file begins with a dot (.) because this is the default ‘hidden’ mode for *Nix servers. Anywho, the .htaccess file can do a lot of stuff and is very powerful, so always make a backup when editing the file and don’t erase things you find when you get there…always append, or prepend, and add a comment about what the code is meant for. (See #4 on Donnie’s list…in fact, read them all while you’re there.)

A few mote notes about .htaccess:

  • Always transfer your .htaccess file to the server is ASCII mode; binary will mess it up and could cause your server to operate incorrectly.
  • If you can’t see your .htaccess file, make sure your FTP server is set show hidden files. Also, as mentioned before, you won’t find this file on a Windows server…*Nix only. You can always try uploading abc.htacccess.txt and then renaming it once it’s on the server to simply “.htaccess” if you’re having trouble.

301 Redirect

To move a single page:

Redirect 301 /oldpage.html http://www.example.com/newpage.html

To move your whole site:

Redirect 301 / http://www.example.com/

What if you’ve changed your site from .html extensions to .php or vice versa? The following will help you redirect one extension to another on the server-side; it looks for any .html extension and changes it to .php:

RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php

Other Methods

Remember at the beginning of the article when I said that editing the .htaccess file was the “clean & easy” way of redirecting? Well, not everyone has access to their .htaccess file so there is an alternate method. You can *gasp* use a meta redirect.

Search engines don’t like meta redirects and most people don’t either. They’re clumsy and they’re not bullet-proof like the .htaccess method. Either way, it can be used in a pinch. For this method, we’ll open the index.html or index.php file (or header file, if you’re using SSI) and add a few lines of code:

 

<meta http-equiv="refresh" content="10; url=http://example.com/">

The content=”10;  tells the browser how many seconds to wait before redirecting…you could easily change this to meet your needs.

Final Notes

All of my notes above have the intent of creating 301 redirects, as opposed to 302s. A 301 redirect is meant to be a permanant change. If Google and other spiders see a 301 redirect in place, they will begin updating their records accordingly.

Conversely, if you create a 302 redirect, you don’t lose your search engine friendliness. Here’s a helpful image to help you see the difference:

So, there ya go; a quick run down on redirecting visitors on a *nix box. Any questions?