Archive for March, 2009

Using a VPS

Sunday, March 29th, 2009

I’m experimenting with an inexpensive ($9.99/mo) VPS from Echo Servers. I have some ideas that I want to put somewhere, and this seemed like a good time to try out some of the new virtual hosting options. I share a dedicated server from ServerMatrix as well. This will be a comparison with a dedicated server, as well as some notes about running (or trying to run) an app server on a VPS with limited resources. Note that I am by no means a sys admin, as you will see. :)

I picked configuration VPS Hosting 2. This comes with 5Mbps bandwidth, 300G a month, 10G of storage, and 128M of RAM (with the capability to use 192M for short periods of time, I think).

Right off the bat, I will tell you one advantage of using a VPS: the admin control panel is running on the host, not on your dedicated server. We use cPanel on our shared server, and while it is very good for creating and managing multiple accounts for multiple people, keeping it up to date has been a challenge at times. With my VPS, I don’t have to worry about my control panel being a security hole.

Obviously, cPanel also does things like e-mail management that require running on the guest. Echo Servers provides cPanel access if you want it.

I had the option of choosing between Cent OS, Debian, Ubuntu and Fedora. I’ve used Ubuntu a little recently and liked the wide availability of packages and documentation. It also seems like more people are adopting Ubuntu.

Ubuntu Server only used 138M of disk space or so when I first logged into the VPS. This is really nice. I don’t know if this is the default server install or not, but I really like it compared to default server installs that include X, Gnome, KDE, etc. I had to “apt-get install man” to get some documentation on the server.

I installed MySQL and Apache 2.2 and immediately started running into resource issues. It turns out that, from what I’ve read, that swap on a VPS is not recommended. I’m going to ask Echo Servers if this is true and what my options are.

But for now, I wanted to run a HTTP server and database on my VPS. I also want to use Ubuntu packages to do this. I tried reconfiguring Apache to only start one process but no matter what configuration I tried, it wouldn’t start with my limited RAM. If somebody knows a way to do this, let me know!

So I installed Lighttpd. It looks like I can run PHP and Python with it, so we’ll review that more in an upcoming post. But I was able to run it no problem on the VPS.

Next, I revisited MySQL. With Lighthttp and MySQL running, I didn’t have much free memory at all. So I installed PostgreSQL. I’ve used PostgreSQL before and liked it. MySQL is pretty ubiquitous these days, and I probably could configure it to run in a smaller space, but I wanted to see if the default PostgreSQL install would be any different.

Now I’ve got Lighthttpd and PostgreSQL running and according to top, I’m using 59M. Much better! Obviously, we’ll see what happens once I actually start doing something. :) My guess is Apache and MySQL allocate caches more aggressively than Lighthttpd and PostgreSQL. We’ll see. To be continued…

PHP Session Problems and session.cookie_secure

Monday, March 2nd, 2009

Here’s what happened:

  • Had my app redirecting HTTP to HTTPS using a rewrite rule.
  • Requiring HTTPS for session cookies by setting session.cookie_secure = 1
  • Disabled SSL for some reason, forget why.

Unfortunately, this coincided with me pointing Apache at a new version of the app, which then broke. I just found the reason on Google: if you require a secure session cookie, you better have SSL enabled and working.

Or just comment out the line in php.ini. Either one.