Half-Elf on Tech

Thoughts From a Professional Lesbian

Tag: servers

  • Subdomains Back Where They Belong

    In my last post, I talked about how I did something dumb with my subdomains.

    How did I install subdomains?

    Stupidly. Or rather, stupid for DreamHost. See, many other hosts, when you make a subdomain, come up with this structure for your files:

    /home/ipstenu/public_html/
                             /subdomain1
                             /subdomain2
                             /addon.com
    

    So when I made my subs, I made them similar to that. What DreamHost does is this:

    /home/elftest/elftest.net/
                 /db.elftest.net/
                 /addon.com
    

    I suggest you do the default! If you didn’t, however, there is a way to fix it. It’s a two step process.

    1) Move the files.

    I found it easier to do this in Unix $ mv elftest.net/trunk trunk.elftest.net (this moves and renames all in one). If you wanted to do it via FTP, just drag and drop, then rename.

    2) Change the location in Panel.

    Go into your panel, edit the domain, and change elftest.net/trunk:
    before: elftest.net/trunk

    To trunk.elftest.net:
    after: trunk.elftest.net

    Give it 5 to 10 minutes, and you’re done!

    tl;dr to the whole thing is this: Trust the tool! (Sharon, that was for you!)

  • Is It My Server or My Theme?

    This could go on any of my sites, but since the conversation started on the DreamHost forums, I thought I’d tackle it here.

    When your site is running slow, it’s easy to pick on the webhost or the server you’re on, saying that’s the problem, and demanding someone else fix it. The truth is that speed involves a lot more variables than just the webhost. Sure, if your host is slow (or down), you’re stuck waiting on us, but there are a couple really easy ways to determine where the slowness is, and you might be surprised.

    If you’re using a CMS like WordPress or Drupal, take a look at how long a page takes to load the first time, and then again on a refresh. When you look at these pages, they’re in PHP and take a little time to process. The more complex your code, the longer it can take to display. This won’t really impact a refresh, but it’s a good idea to see if your browser is caching anything. If the site is really slow, go look at a static HTML or TXT page. On WordPress, look at http://yourdomain.com/readme.html and see how fast that loads. If that’s slow, hey! It is your server! Open up a ticket with us and tell us that the site is slow to load static pages. It’s really important that you tell us what you’ve done, so we don’t have to waste time re-doing it all for you.

    But most of the time you’ll see the html loads really fast. Why is that? It’s that pesky PHP taking a while to render. Now I know this brings up the obvious question of why would we use PHP if it takes longer to load, and the answer is complicated. There are a lot of benefits to using PHP (like being able to use those cool CMS’s to make publishing your site easier), and I’m not going to go into them. Just know that if you choose to use a modern CMS, then you’re likely going to be using PHP to render your site.

    That means we have to consider how to make our PHP run faster. If you’re on shared hosting, the server side work should have been done for you, and if things are still slow then you have to consider the painful option that you did this to yourself. Don’t worry! That’s not a terrible thing, you probably just picked a theme, or a plugin, that is totally perfect for you, but a little slow. This is why people say ‘too many plugins/extensions slow your site.’ It’s not true, but the idea is that the wrong one will slow you down. And that is certainly true.

    Go to Google PageSpeed Insights and check your site out. It should give you a hint as to what’s lacking. Don’t take this as the holy grail, though. Sometimes Google has really dumb advice, like ‘You should compress the code you’re using from google.com!’ Really? So why don’t you compress it, or tell me ‘Use this code instead from us! It’s already compressed!’ In theory, all of Google’s jquery code has a compressed version, but that’s not what most people see, so telling us to use it but not how is pretty idiotic, in my opinion.

    I always tell people to look into minifying their output. That means you use a tool to make your HTML all mashed up together when someone looks at your source code. This simple step has amazing results for most sites. It took my Google Speed score from 71 to 81. Any score above 75 is a ‘good’ score from my experience (Microsoft gets a 77, after all, and while Google gets a 99, their main page is pretty minimalistic).

    The point to all this is that your pagespeed is dependent on more than just how fast DreamHost is running. If you tell me that your site is slow, the first thing I do is look at a static page (I may even make one for you if I can’t find one). From there, maybe I’ll poke at the server, but most of the time it’s been your site’s configuration. I say this from a place of over 15 years of self-hosting: I’m nearly always the cause of my own problems.

    Of course, if it’s your WordPress site being a slug, start with caching plugins and feel free to ask us for advice. If you have a wild and wooly, never been seen before, WP problem, don’t be surprised to see me showing up in your ticket.

  • Subdomains, WordPress and nginx

    This should be obvious, but I’m not familiar with nginx, so it wasn’t.

    I added trunk.elftest.net as a separate subdomain (rather than Multisite) because I wanted it to run trunk and not impact anyone else.

    The way that DreamHost works, is you have a separate folder for your nginx configurations, called nginx, and it lives off your home directory. This is commonly referenced as ~/nginx/ and yes, if you type in cd ~/nginx/ you’ll jump right there.

    To make WordPress work, I had to create ~/nginx/trunk.elftest.net and add a wordpress.conf file there, with the standard DreamHost nginx config for WP.

    ######################
     # Permalinks
    if (!-e $request_filename) {
     rewrite ^.*$ /index.php last;
     }

    Magic.

  • WordPress, DSO and Permissions

    WordPress, DSO and Permissions

    I run my server with PHP DSO.(For the differences between DSO and SuPHP, read DSO (mod_php) vs. CGI vs. suPHP vs. FastCGI) It lets me run APC, and I’ve always liked it. It does have some weird problems, mind you, like a tendency to upload files as nobody:nobody, and more importantly it means that you have to set your wp-content/uploads folder permissions to 777. Thankfully there’s a fix!

    If you’re not good with command line, scared by shell, and terrified of chmod, you’ll need to find your friendly neighborhood sysadmin to help you out. It’s okay to not feel up to doing this, and it should go without saying that you should make a backup first!

    To step back, someone’s going to ask “Why is 777 bad?” Unix permissions are complicated. Every file in UNIX has an owner user and an owner group, and most of the time they’re the same. Mine are ipstenu:ipstenu (which means owner ipstenu, group ipstenu). Now another account on this server, conrel, has conrel:conrel. The groups ipstenu and conrel are both in the same webmaster group, which gives them special permissions. It’s confusing to a lot of people that most webhosts use the same name for the user and the group, but it’s just what we do.

    Now for every file, there are three types of ‘ownership’:

    1. User ownership – i.e. the user ipstenu
    2. Group ownership – i.e. the group ipstenu
    3. No ownership – i.e. you who are reading my site

    There are also three types of permission levels”

    • read (r)
    • modify/edit/write (w)
    • execute/run (x)

    This all works out so when you go in via unix shell and look at your files you see soemthing like this:

    -rw-r--r-- 1 ipstenu ipstenu 203789 Oct 5 19:30 stevejobs.png

    This means the owner (ipstenu) has rw permissions (which are read-write). The group (ipstenu) has r (read-only), and the world (i.e. everyone else) also has r (read-only). This is an image, no one needs to execute it (which would be an x).(The “1” before ipstenu is for the number of files. “203789” is the size of the file. “Oct 5 19:30” is the day/time I uploaded the file, and “stevejobs.png” is the name of the file.) These rwx letters correspond to numbers. r = 4, w = 2 and x = 1. So when you see ‘rwx’ that equals 7.(There are also options o (other), u (user), g (group) and a (all)… and s … but I’ll spare you that right now. Suffice to say, you can use what you’re comfortable with. I use the numbers most of the time.)

    So why is 777 dangerous? 777 means ‘everyone has full access to this file.’ Yeah, that sounds dangerous! I don’t want that! The only person who should have full access is you! But DSO doesn’t like to upload files without 777 permissions. In part, this is WordPress’s fault, but really it’s an unholy combination of things. Alex King explains why it happens, and as of WordPress 2.8, you can fix this yourself.

    Just override the default file permissions. It’s genius! I tossed this into my wp-config.php file and I was good to go!

    define('FS_CHMOD_DIR', (0755 & ~ umask()));
    define('FS_CHMOD_FILE', (0644 & ~ umask()));
    

    No, the 0 in front is not a typo. 0755 is an octal value. Octal values must be prefixed with a 0 and are not delineated with single quotes (‘). It’s just how it works.

    There is a catch, though. My uploads folder had been set to 777, which meant /wp-content/uploads/2011/10 (this month’s folder) was also 777, which totally invalidated my test. That’s easy enough to go back and fix permissions on your folders. I did it this way because I have some caching plugins that I do not want to screw around with:

    find /home/foobar/public_html/wp-content/uploads -type d -perm 777 -print -exec chmod 755 {} \;
    
    find /home/foobar/public_html/wp-content/themes -type d -perm 777 -print -exec chmod 755 {} \;
    
    find /home/foobar/public_html/wp-content/plugins -type d -perm 777 -print -exec chmod 755 {} \;
    

    That code says “Find all folders (-type d) and if they have permissions of 777, change them to 755.” There are more variations on that.(I got the code from NixCraft – Linux / UNIX: Change File Permissions Recursively ( conditional )) If you want to change files, it’s -type f and you’d want something like this:

    find /home/foobar/public_html/wp-content/uploads -type f -perm 777 -print -exec chmod 644 {} \;
    

    That will turn all your images back into permissions 644, presuming they were 777 to begin with. Mine were 755.

    Permissions GrantedThe last step I had was chowning the folder for uploads and 2011 to nobody:nobody. That was so on month end, I would be able to create folders (like uploads/2011/11 today) without any issues. The other folders, as they already existed, didn’t need the permissions changed. Honestly, I’m not sure if I needed to set the uploads folder to that. I didn’t set blogs.dir for my MultiSite install, and just did the files folder within, since it had created other folders correctly. It’s a hassle, unraveling years of ‘Did it wrong!’ and when you add in that we’re using different tool sets to upload files versus upgrade and all that … well. It works now.

    I also kept the upgrade folder with permissions 777, since that just did not want to work any other way. It flat out refused to upgrade any plugins. I’ve yet to try upgrading WordPress itself with this setup, but I suppose I’ll find out soon.

    And that’s it! It’s not 100% painless, and it’s much easier if you start out ‘doin’ it right’, but even after you’ve been doing it wrong for over 5 years, you can fix it.

  • Smart Servers

    Smart Servers

    I upgraded the server that runs this site. Well, I should say I transferred from a traditional VPS on CentOS 4 32 bit server I’ve been on since 2009 to a CentOS 5, 64 bit, fully managed Smart Server.

    What’s a Smart Server?

    You know this whole cloud hosting thing? It’s like that, but not. I had serious concerns about the cloud. Certainly I was worried when I heard people running WordPress MultiSite had weird issues with caching and things not syncing up when new server slices were made. Reason enough to hold off for me. But then my host says “We have these in-between servers.”

    smartserver comparisonLiquidWeb Smart Servers are kind of like Cloud Servers. First, I’m the only person on my server (which is a step up from VPS), and I have a set amount of bandwidth. I’m charged per-day, too, so if I need more CPU/Memory for a couple days, I only get charged for those days. That’s really nice. There’s a lot of normal ‘cloud’ features too, like I can spin up new images on the fly and use them (maybe 30 minutes total to do all that).

    Yeah, 30 minutes. Thinking about how long it took to just migrate from host2 to gamera(Gamera (ガメラ?) is a giant, flying turtle from a popular series of kaiju (Japanese giant monster) films produced by Daiei Motion Picture Company in Japan. Created in 1965 to rival the success of Toho Studios’ Godzilla during the daikaiju boom of the mid-to-late 1960s, Gamera has gained fame and notoriety as a Japanese icon in his own right.), being able to move things around on the fly with only an hour of outage is nothing. When I moved my three WordPress sites, they took about an hour or so each (give or take). When I moved my forum with a 4gig database, it took about eight hours. We made jokes about how it was the size of Liechtenstein.(The problem with a 4gig database is when 400megs is in one table. Takes a long time, no matter what you do. The file copied over fast, but the exploding of it took long enough for me to nap.)

    None of that was why I upgraded/moved though. The real reason for the upgrade was that my server’s been having weird issues, and most of my research said it was because I was on CentOS 4. I couldn’t upgrade SVN, I couldn’t upgrade PHP for much longer, and I was sure that come February 2012 (when CentOS 4 is EOLd) I was going to be increasingly in the cold. So I made a list of everything I’d ‘done’ to my server, all the upgrades and tweaks, and I went for broke.

    For the most part, I can’t tell the difference between my old VPS and my new smart server other than the speed (much faster). What I did notice, and didn’t like, was that the memory tends to run ‘hot.’ With nothing going on at all, it was hitting 90% usage. With nothing going on for my old site, it’s at 50% (and normally hovered around 60-70%). Gamera definitely runs heavier, though I’m still using the old caching. I did have to up PHP memory to 64megs, from 32, after I ran into weird issues on one site, but for the most part, I’m in a ‘It Just Works’ state of mine. Oh and I will very much need to sort out external SSL, since everything’s on one IP now, and you can’t use multiple SSL like that.

    Yet I’ve still not answered the question. What is a Smart Server anyway?  Thankfully LiquidWeb isn’t the only site using this designation.

    We know what Cloud Server is, and we know why it’s good.  It’s flexible, it can add on memory and diskspace as I need it, and take it away if (when) I don’t.  I’m charged for what I’m using, not a blanket ‘This is what I need on my worst day’ sort of deal.  But the problem there is a lot of people actually need that flexibility but don’t have the brainpower to handle running their own server.  Two years ago, I didn’t, that’s for sure.  In fact, two years ago, Cloud scared me.  But, just like VPS.net came up with Cloud Shared Hosting (which I jokingly called Cloud for Dummies), LiquidWeb and some other said that some of us really need a VPS, but we’d like some of those cloud features too.

    To the cloud!This is the middle ground.  Too many places were looking at Cloud Dedicated hosting, which is expensive, and not something we all need, and then was also that race to the cheap hosting.  I pay $60 a month for my hosting, and it’s worth it.  I know, it’s a lot of money to some people, but think on this: If I pick up the phone right now and call Tom, my sales guy, or Benny, the tech I know pretty well, they’ll take the time to help me.  And if I call the 1-800 number at 1am?  Someone is there who speaks English and knows what I’m talking about.(Not that I don’t love OffShore support, I know I love the ones at my office!  Many of them are fantastic in their fields and well worth the price of admission. But too many companies force these intelligent people to stick to a script, and don’t teach them the hows and whys of the code, the company, and how to work with American customers.  If you’re going to support Americans, you must learn how to deal with them, for better or for worse, you learn to deal with your customers.  And yes, that means being fluent in their native language, and their technologies.  This holds true for India, Mexico and that moron from Nebraska who wanted me to go into the registry on my Macintosh.  AT&T.)  So while I’m willing to pay more for someone who will bail me out, I’m not willing to pay more for something I don’t use.  Like extra minutes on my cell phone, I don’t like to pay for hypothetical ‘in case I get the Digg effect or Matt links to me again’ CPU and memory.

    While a Cloud Server would handle all that, it also requires consistent and constant management.  You have to know what to expect, and be ready to go.  Those of us who do all this as hobbies or as a side-gig don’t have the time.  Also, sharing resources in the cloud makes some of us sketchy.  The whole reason we self-host anyway is that we want to be in control.  Cloud sharing started to sound a lot like Shared Hosting, which has issues of it’s own.  Resource contention is s concern, as are bad neighbors.  The cloud is great for hosts because it shares everything, and complicated for users because we don’t want to share.

    It sounds a little repetitive to call this Cloud Light.  In fact, it feels really repetitive to say “This is like a VPS, but with Cloud Add-ons.”  Part of this is because understanding what the Cloud is, after decades of the old way, is hard for our brains to wrap around.  For most of us, the cloud doesn’t matter.  In fact, it barely matters for me.  The cloud is really what the internet has always been to most of us: ephemeral and mystical.  Don’t let the smoke out of the cloud, or your website will crash!  See?  You don’t know anything more than you did before, now do you?

    The Cloud is synonymous with the Internet for many people, and I think the future of it is aimed that way.  For me, having the ability not to be tied to hardware and to add on more space, memory and CPU as I need it is invaluable. Being priced reasonably for those things also makes me pleased. The Cloud gave me freedom, but a Smart Server gives me even more: the freedom to control my destiny on my server. And that’s just cool.

    So what’s the downside?  There are some.

    Understanding memory usage has been the big issue. I mentioned before that Gamera uses 90% of the memory, normally, and after my database crash I came to understand why.  See not being tied to hardware means I’m not tied to hardware memory either.  So linux, being linux, uses up all the memory it can.  I watched, and when I start doing more intensive stuff, like importing a 4G database, the memory dropped to about 75%, and then bounced back up to 80-90.  This is what it’s supposed to do!  When it starts running out of memory, it goes to swap.  Now on the traditional VPS, this was bad.  Swap meant you were ‘out’ of memory and about to crash.  On a Smart VPS, this is okay.  My swap sits around 10% right now until I clean it out.

    Trade one ...Cleaning it out is where things get weird.  Smart VPS memory doesn’t clean out.  If I hot-swapped my memory, some genius at MIT sorted out I could actually read data off the memory.  Of course, if you have the physical access to my server I have other problems.  But swapping memory, well that means the computer swaps data to the hard disk and back to your RAM as needed.  I’m not entirely sure how this all works, and I’m doing some research now (and asking the tech from last night for info he said he had about all this).  As for the crash… My database crashed on Saturday because the table was 600mb, and the space I’d allocated for swapping like that was 400mb.  Liquidweb’s support moved the SQL temp drive to a place with more space to allow for that and everything started working again.

    ... for the other!SSL was pretty straightforward. I bought an extra IP, since it’s cheaper and easier than sorting out multiple domains on 1-IP for SSL for only two domains. The other domains don’t need SSL yet, so they can wait until WHM catches up with SNI and other weird acronyms you don’t care about.

    Basically, I’m very happy. I’ve even started to forget it’s something novel.

  • Request: Multiple Domains, One IP SSL Certificates

    This is actually a request. The server that runs Ipstenu.org hosts three other domains. I set up my self signed certificate just fine for *.ipstenu.org, but I want to add on the other domains. For some reason I seem to be failing.

    I somehow managed to get it half-baked. If you go to https://otherdomain.com it kicks you to https://ipstenu.org/wp-signup.php?new=otherdomain.com which isn’t what I want at all.

    I’m using WHM on CentOS 5.6 and I’m a total newbie when it comes to all this! Links to tutorials with pretty pictures, advice, or directions are all welcome!