Phat Site Blog

Archive for July, 2010

Slicehost Articles: Enabling and using apache's mod_status on Debian

by on Jul.31, 2010, under LAMP

Apache’s mod_status module allows it to display a web page containing statistics about the web server’s current state, including worker processes and active connections.

What is mod_status?

While you can get information on the connections being made to apache by checking its access log, if you want more immediate information about what apache is up to you can enable mod_status. This module allows you to view a detailed status page for your web server. This information can be useful for watching your web server’s performance during load testing or for allowing a monitoring program like munin or mrtg to gather activity data for later aggregation.

The Apache Project keeps their server status page available to the general public. to get a look at a fairly busy web site’s status page, visit:

http://www.apache.org/server-statusEnable mod_status

The default installation of apache usually has mod_status enabled, but let’s check to make sure. Check the contents of apache’s enabled modules directory:

ls /etc/apache2/mods-enabled

Search for “status.conf” and “status.load”. if those files aren’t listed in that directory, you will need to enable mod_status by running:

sudo /usr/sbin/a2enmod statusConfigure access

To enable access to the server status page we’ll need to add a Location directive entry for it to the default virtual hosts for any domains configured for apache. if you haven’t added any new virtual hosts to the default apache configuration, you will only need to edit the virtual host file at:

/etc/apache2/sites-available/default

Add to each virtual host file that needs to be edited the following section, within the “VirtualHost” configuration block:

<Location /server-status> SetHandler server-status Order deny,allow Deny from all allow from localhost</Location>

Note that “Allow from localhost” can be changed if you want to allow remote access to the apache status page, but we don’t recommend it. We’ll talk about how you’ll be able to view the status page from the slice itself in a later section.

ExtendedStatus

One more change we may want to make is to enable the ExtendedStatus setting in apache. This setting adds more information to the status page apache returns, like CPU use and requests per second. Enabling ExtendedStatus makes apache do a little extra work when it gets a status request, so you might weigh the extra information gained against the potential performance hit to a busy server.

Many monitoring applications that record performance over time, like munin, require that ExtendedStatus be enabled before they can monitor apache.

The ExtendedStatus setting must be set at the server level and applies to all virtual hosts running under apache. We’ll add this configuration option as a configuration snippet in apache’s conf.d directory, to make it easy to find and change later if necessary. create and edit the file:

/etc/apache2/conf.d/extendedstatus

Add the following lines to the extendedstatus file to enable ExtendedStatus:

# ExtendedStatus controls whether Apache will generate “full” status# information (ExtendedStatus On) or just basic information (ExtendedStatus# Off) when the “server-status” handler is called. The default is off.#ExtendedStatus On

To disable ExtendedStatus later, either delete the extendedstatus file or change the setting in the file from “On” to “Off”.

Restart apache

Now that we’ve made sure the apache server status page is enabled and configured the way we want it, we’ll need to restart apache:

sudo /usr/sbin/apache2ctl restartInstall lynx

With apache’s server status page restricted to localhost-only access we won’t be able to see the page from our desktop’s web browser. Luckily the server status page is just a bunch of text with no graphics, letting us use a simple approach: run a text-based web browser while logged into the slice itself.

To try this option out we’ll need to install a browser on the slice first. The browser we’ll use is called “lynx”, and you can install it with the following command:

sudo aptitude install lynx

No configuration is necessary, but lynx is keyboard-controlled so it’s handy to know a few basic keystrokes when using it. there is a list of the most frequently-used commands at the bottom of the screen while lynx is running. if you visit a site with lynx you can navigate with the up and down keys and follow a highlighted link by hitting enter. Hit “q” to quit (and hit “y” to confirm the quit). Hit “h” to access lynx’s documentation.

View the status page

The URL of the apache status page will be your domain name with “/server-status” tacked onto the end. in this section we’re assuming you’ve configured your default server instance or virtual host to accept connections from the localhost only. tell lynx to view your apache status page with the following command:

lynx http://localhost/server-status

You will see something like the following page if you have ExtendedStatus enabled (the example server was running Ubuntu Hardy, but it should look similar for all recent versions of Linux and Apache). With ExtendedStatus disabled the page will look similar, but with a few lines missing.

Apache Status (p1 of 2) Apache Server Status for localhost Server Version: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch Server Built: Nov 13 2009 21:58:02 ______________________________________________________________________________ Current Time: Friday, 26-Mar-2010 19:04:17 UTC Restart Time: Friday, 19-Mar-2010 20:21:03 UTC Parent Server Generation: 1 Server uptime: 6 days 22 hours 43 minutes 14 seconds Total accesses: 386 – Total Traffic: 317 kB CPU Usage: u0 s0 cu0 cs0 .000643 requests/sec – 0 B/second – 840 B/request 1 requests currently being processed, 9 idle workers W_________……………………………………………… ………………………………………………………. ………………………………………………………. ………………………………………………………. Scoreboard Key: “_” Waiting for Connection, “S” Starting up, “R” Reading Request, “W” Sending reply, “K” Keepalive (read), “D” DNS Lookup, “C” Closing connection, “L” Logging, “G” Gracefully finishing, “I” Idle cleanup of worker, “.” Open slot with no current process Srv PID Acc M CPU SS Req Conn Child Slot Client VHost Request 0-1 3425 0/36/45 W 0.00 0 0 0.0 0.04 0.04 127.0.0.1 www.example.com GET /server-status HTTP/1.0 1-1 3426 0/44/58 _ 0.00 4277 0 0.0 0.04 0.05 173.65.120.190 www.example.com GET /favicon.ico HTTP/1.1 — press space for next page — Arrow keys: Up and Down to move. right to follow a link; Left to go back. H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list

If you get an error, troubleshoot accordingly. a “not found” error would indicate that mod_status isn’t properly enabled. a “forbidden” error would mean that the Location configuration for /server-status is restricting you from accessing the page. a “connection refused” error means apache isn’t listening on port 80 and may not be running.

Following the “Scoreboard Key” will be a list of current connections, including the source addresses and the file being accessed.

Most of the server status page should be pretty self-explanatory. The apache version is listed at the top, along with some of the modules loaded in apache. some important stats following that include how long the apache server has been running since its last restart, the traffic it’s handled since then, how much CPU is being used by apache at that moment, and how frequently apache is serving requests.

The section between the number of current requests and the “Scoreboard Key” is a representation of apache’s “workers” and their status. The “worker” is essentially apache’s request handler. Apache keeps several active at a time.

The Scoreboard Key shows what each symbol in the worker list means. in the example you can see the apache server isn’t very busy — several “_” characters show a handful of workers waiting for requests, while a lone “W” shows a worker replying to a request (the request for the server status page, in fact). all the periods show slots that could be filled with workers if the server gets busy enough to need them.

If you visit the Apache Project’s server status page you can see a more active server and a greater variety of worker states, like “K” (keep-alive, a reused connection waiting for a new request from a browser), “R” (reading a request from a browser), and “C” (closing a terminated connection).

Yes, but what does it all mean?

Most often the mod_status output is used by other tools to chart the server’s activity over time. Viewed directly, the status page is handy for a quick overview of what your server is doing at a given moment. some of the displayed data can indicate problems that merit investigation.

Examples of items to watch for on the status page include:

• a high CPU usage for apache could indicate a problem with an application being run through a module like mod_php.

• While it’s normal to see several keep-alives being handled by apache’s workers, if they constitute a vast majority of the worker statuses you see then your web server might be keeping old connections alive too long. you may want to look into reducing the amount of time connections are kept alive by apache via the KeepAliveTimeout directive.

• if you see very few inactive workers (represented by “.” characters) you may want to increase the MaxClients value for your apache server. making sure you have idle workers ready to handle new requests can improve the web server’s responsiveness (assuming you have enough memory on the slice available to handle the extra connections).

Summary

Apache’s status module is a handy complement to a monitor program, and the snapshot it provides of a web server’s activity can highlight problems that would be otherwise difficult to isolate using standard system tools like top and lsof. even if you’re only enabling mod_status for a monitoring tool, knowing how to access and read the status page can help you be a more effective web server administrator.

For more information about mod_status and the details it reports check the Apache mod_status documentation.

  • – Jered

Slicehost Articles: Enabling and using apache's mod_status on Debian

Leave a Comment :, , , more...

Self Hosting Questions?

by on Jul.31, 2010, under Server Maintenance

Hello,
I plan to host a small development website from a desktop computer, and have a few questions about doing so. first off, which HTTP server should I use (e.g. Apache, lighttpd, etc.)? Second, which OS should I run for this server? I have heard Ubuntu Server Edition and Debian are good, but I could do with some opinions. Third, what are good mail and FTP servers?
Thanks a lot in advance!

Self Hosting Questions?

Leave a Comment :, , more...

Large Ruby on Rails resouce for all levels w/ Articles, Tutorials & more

by on Jul.30, 2010, under Ruby and Rails

Ruby on Rails: An extensive roundup of resources, projects, books, links, hosts and more. April 16, 2006 on 2:26 am | in Rails, RoR, Ruby, Ruby on Rails, programming | 63 Comments

Update: This article was added to digg. Please digg it!

Update #2: Thanks for all the comments. Adding all the resources to the list.

After seeing new Rails write-ups, tutorials, projects, etc.. pop up almost everyday, I decided to try and go through a lot of them and post the best and most useful ones. Below, you will find what I believe are to be the some of the best Ruby on Rails resources. if you know of some that I have missed, let me know via comments/email, and I’ll probably add them to the list.
Official Sites:

Tutorials:

Articles:

Ruby on Rails Open Source Apps:

Some of the Real World Rails Sites (Thanks fanarama!):

  • BaseCamp : a unique project collaboration tool.
  • 43Things : Find your 43 things.
  • CrispyNews : a site that allows anyone to create a community news site–for free.
  • Kiko : a great, dead simple calendar you can use right in your web browser.
  • Penny Arcade
  • Here is a more complete list of Real World Rails Usage.

Rails Books:

Rails Hosting:

  • TextDrive : TextDrive is a hosting company run by and for people who love publishing on the web. With plans starting as low as $12 per month.
  • 3SHost : Rails hosting starting at $10 per month.
  • DreamHost : Rails hosting for as low as $9.95 per month. (Coupon Code #1: 50RAILS and get $50 off when signing up. [Thanks Will Merydith!]. Coupon Code #2: SAVE96DOLLARS saves $96. [Thanks jopotts!]).
  • HostingRails : Curious about rails? This free plan will get you started, but be aware of the small amount of disk space(50MB) and low montly transfer limit(1GB). No Ads, just free hosting for rails!
  • You can find hundreds of more hosts listed on the Rails Wiki site.

Firefox extension:

Other:

  • RadRails : An integrated development environment for the Ruby on Rails framework. (Thanks gookie from digg!)

Large Ruby on Rails resouce for all levels w/ Articles, Tutorials & more

Leave a Comment :, , , , more...

Take the Ruby on Rails Train to XML

by on Jul.29, 2010, under Ruby and Rails

Daniel Wintschel (daniel@humandoing.net), Software developer, Helium Syndicate

You’ve very likely heard of Ruby on Rails. Maybe you’ve actually used it; perhaps it is your new programming mistress. Whatever the case, it looks like Rails is here to stay, and to everyone’s benefit. Ruby plays very nicely with XML — read further for the details.

In this tutorial

In the past couple of years, Ajax has practically become a requirement for new Web sites, but that doesn’t make it any easier to create. to create Ajax-enabled sites manually means that you createJavaScript to make asynchronous HTTP requests using objects that do not comply with browser standards, which can make for a very long programming day. the Google Web Toolkit (GWT) abstracts the JavaScript tasks necessary for an Ajax-enabled application into a few Java classes, to make creating these interfaces much more intuitive for Java programmers. but most of these Ajax applications use XML to transfer information to and from the server, so your application must be able to both parse and create XML data.

In this tutorial, you will build a Rails application, discuss some basics about the way that Rails works, how it’s structured and how to use it, and then you’ll move on to working with XML. There are a number of ways to both generate and parse XML in Ruby, and you’ll look at a few of them, including REXML (Ruby Electric XML), Builder and Hpricot (Technically Hpricot is an HTML parser — but it’s fast, and works on XML, too).

  • Build the skeletal Ruby on Rails app (preparation for XML processing)
  • Create a new XML document
  • Download the XML document
  • Upload a file in Rails (in this case, XML)
  • Parse and manipulate XML

This tutorial is for a general programming crowd interested in learning the basics of setting up a skeleton Rails application and using Ruby and Rails to process XML. Beginner and intermediate programmers or people who have a little bit of exposure to Rails will likely benefit the most. it will spend a brief amount of time discussing Rails in general, and Ruby syntax as necessary, but these topics are covered in much better detail elsewhere. Please see Resources in the tutorial for additional information.

You will need JavaScript enabled in your browser.

The following tools are needed to follow along with this tutorial:

  • Ruby — if you run Windows, your best bet is to download the One-Click Ruby Installer. if you use some variation of Linux or Mac OS X, you might already have Ruby installed. if not, you can download it from http://www.ruby-lang.org. the installation instructions are straightforward. Version 1.8.4 or 1.8.5 is recommended.
  • RubyGems — Get the gems you need, and install Rails, Builder and Hpricot if you haven’t already.
  • Rails — You can install Rails through RubyGems. While not really part of this discussion, you figure all that out at http://www.rubyonrails.com/down. You’ll use version 1.2.2 for this tutorial.
  • Builder — Install through RubyGems.
  • Hpricot — Install through RubyGems.

html, pdf

Take the Ruby on Rails Train to XML

Leave a Comment :, , , , , more...

Burn almost any video file to a playable DVD

by on Jul.29, 2010, under LAMP

  • Sign up for the Lifehacker Daily and get one great story in your inbox each day.

  • Join Lifehacker on Facebook. Click “Like” to get the most important stories in your News Feed.

by Adam Pash

Putting any old video file – like the DivX/Xvid-encoded videos you’ve downloaded with BitTorrent – onto a DVD to play on your TV can be a daunting task. There’s plenty of software that tackles this sort of thing for a price, but as a lover of open source software, free’s always my first choice.

Luckily for all of us, authoring playable DVDs from just about any video file has gotten a lot easier in the open source community. this week I’m going to show you how to burn those downloaded TV shows to a DVD you can play in your living room using the free (as in speech), open source application, DVD Flick.

NOTE: DVD Flick’s almost embarrassingly simple to use, but since it’s a subject that can be confusing for people who haven’t authored many DVD’s, and it’s a question we’ve been asked about several times before here at Lifehacker, we thought DVD Flick deserved a quick guide.

In a few simple steps, here’s how to burn almost any video file on your computer to a playable DVD.

Step 1: Download and install DVD Flick

DVD Flick is a free, open source DVD authoring tool that will take care of pretty much all of the legwork involved in authoring your DVDs. So thank the gods of open source and go download it here.

In order to make a DVD that you can play on your DVD player, your video files need to be encoded in MPEG-2 format. What makes DVD Flick special (aside from the fact that it’s free) is that it handles all of the necessary transcoding of your AVI, MPG, MOV, and WMV files (among others) to MPEG-2, and then authors and burns your DVD all in one fell swoop – meaning it’s very simple for anyone to use.

Step 2: Configure your project settings

The DVD Flick interface is very no-nonsense – everything you need to access is available to you through the 7 buttons in the toolbar. Before we add videos to your DVD project, let’s take a look at the settings and make sure everything’s as you want it.

Click the button labeled Project settings. By default you probably won’t have to change anything, but I do want to point out a couple of things.

The General tab lets you set the size of your target media (i.e., the capacity of your DVD). If you’re burning to a standard DVD-R, you’ll want to keep the default 4.3GB setting. However, you can also set your target size to Dual Layer DVD, Mini-DVD, CD-R, or your own custom target size.

The Video tab lets you set the format of your DVD player – namely whether your DVD should be NTSC or PAL-formatted. If you live in the US, NTSC is your pal. most of Europe and Asia, on the other hand, use PAL. you can also set the encoding quality in the Encoding profile drop-down. If you feel that the quality of your authored DVDs isn’t high enough, you might want to try upping the quality and ensuring the “Second encoding pass” checkbox is ticked. If you’re more than happy with quality but you want to speed up the encoding process, you can lower the quality and get rid of the second encoding pass (you probably won’t want to do this, but just in case, there it is).

Also of note, the Burning tab lets you set the options for the final product. If you don’t have a DVD on-hand for burning, for example, you can tell DVD Flick to create an ISO image that you can easily burn to a DVD later on using a tool like ISO Recorder or ISOBurn.

Step 3: Add titles to your DVD

As I said above, DVD Flick lets you add nearly any type of video file to your DVD project. The easiest way to do this is to open up the folder holding your video files and drag-and-drop the files into DVD Flick. The yellow bar on the left of the app shows you how much space you’ve used. The amount of video you can fit on one playable DVD will vary by length and quality, so keep an eye on your space.

DVD Flick is pretty no nonsense at this point; you can’t build any fancy menu screens. [1] Instead, the DVD you author and burn will simply play each file as a chapter in the order you add them to the project by default. If you want to add chapters to individual video files, select the video/title and click on Edit title… and change the method of chapter creation. you can create chapter points every so many minutes, create a set number of chapters per title, or leave your video chapter-free.

Advanced users can add extra audio tracks (like commentary) and subtitles through the Edit title menus as well.

Step 4: create your DVD

Before you start, pick the directory that the transcoded files will be saved to while DVD Flick works. You’ll need to have a drive with a fair amount of space, so keep that in mind. You’ll also want to keep that in mind so you can remove those files after the process is complete so you don’t end up with a hard drive full of pre-burned DVDs.

Now that you’ve got everything set up how you want, click the button labeled Create DVD. DVD Flick will now start transcoding the video files and authoring the DVD while you sit back and browse the internet. If you’ve never done this before, you’ll learn quickly enough that video transcoding takes some time and CPU horsepower.

If you don’t want DVD Flick to eat up precious CPU cycles while you’re working on your computer, it’s sometimes useful to save this sort of operation for when you’re away from the computer. Tick the checkbox labeled Shutdown when completed and you can leave DVD Flick to do its business overnight and shutdown your computer when it’s finished. When you get up the next morning, you’ll be the parent of a newly authored DVD!

Adam Pash is an associate editor for Lifehacker who likes his DVD creation to be dead simple. his special feature Hack Attack appears every Tuesday on Lifehacker. Subscribe to the Hack Attack RSS feed to get new installments in your newsreader.

Footnotes:

[1] If you’re looking for a free solution for authoring DVDs with nice menu screens, check out DVD Styler. The downside to DVD Styler is that it doesn’t handle all the transcoding that DVD Flick does, meaning that you’ll need to transcode your video files to MPEG yourself. [back up]

Send an email to Adam Pash, the author of this post, at tips+adam@lifehacker.com.


Burn almost any video file to a playable DVD

Leave a Comment :, more...

linux vs windows web hosting?

by on Jul.29, 2010, under LAMP

What is the difference between linux web hosting & Windows web hosting? Can’t we built a website in windows if we take linux hosting and vice-versa?

linux vs windows web hosting?

Leave a Comment : more...

Rails 3 nears with release candidate availability

by on Jul.28, 2010, under Ruby and Rails

David Heinemeier Hansson, the creator of the Ruby on Rails web framework, has announced the availability of the first release candidate of Ruby on Rails 3, noting over 842 commits by 125 authors made to the code since the most recent beta. The release candidate, originally promised in June, was delayed for a fourth beta release and more testing.

Many of the fixes have focussed on bringing the performance up to Rail 2.3 levels with improvements to start up speeds and faster development cycles. Rails 3 is a major revision of Rails, bringing together the Rails and Merb frameworks to create a slimmer and faster platform for web applications written in Ruby. an early version of the release notes is available which covers the changes in architecture in the framework.

Heinemeier Hannson says that in use Basecamp, 37Signals flagship application, “went from insufferable to about 2.3 levels of enjoyment”. he did note though that Active Record performance still needed work and that the developers aimed to get it back to “at least 2.3 levels before release”. other changes in the Rails 3 release candidate include support for the MySQL2 gem, support for shallow routes (for shorter URLs), fixes to auto-loading and web encoding issues and a change which allows the rails command to work “even when you’re in a subdirectory”.

The details of the changes are available in the change logs for the ActionPack, ActiveModel, ActiveRecord and ActiveSupport components or in intricate detail in the commit history. Rails is available under an MIT licence and can be installed by running gem install rails –pre on a system with Ruby and RubyGems installed. The current stable release of Rails is version 2.3.8 and instructions for installing it are available on the Ruby on Rails web site.

(djwm)

<a href="http://www.h-online.com/open/news/item/Rails-3-nears-with-release-candidate-availability-1045806.htmltag:news.google.com,2005:cluster=http://www.h-online.com/open/news/item/Rails-3-nears-with-release-candidate-availability-1045806.htmlTue, 27 Jul 2010 10:22:38 GMT 00:00″>Rails 3 nears with release candidate availability

Leave a Comment :, , , , , more...

How to set windows as default after dual-boot installing CentOS?

by on Jul.28, 2010, under Server Maintenance

I had windows xp, and I installed CentOS on a separate partition, but now when I boot up my computer I have to press a key really quickly to select windows as the operating system to boot up (otherwise it just quickly boots to CentOS).

How do I make windows the default OS?

How to set windows as default after dual-boot installing CentOS?

Leave a Comment :, , , , more...

How did you learn Ruby on Rails?

by on Jul.27, 2010, under Ruby and Rails

I want to learn ROR, but I do not know which book do I need to get it first. I noticed that everyone is saying that ” Agile Web Development with Rails, 2nd Edition” is the best, but I prefer to buy ” Practical Rails Projects by Eldon Alameda” So, please let me your suggestions? Please keep in mind that I already know Java and PHP.

How did you learn Ruby on Rails?

Leave a Comment :, , more...

My first Ruby on Rails patchRainer Blessing's Site | Rainer …

by on Jul.27, 2010, under Ruby and Rails

As I was googling my name I found my name on a Rails Contributors List which could only mean that my little Rails patch got accepted, which made me very happy for today.
Now I am in the list with all the Rails celebrities with just one patch .
I got the inspiration by reading Rohit Arondekar’s report about his Bugmash Contribution.
I used the Gimme Ticket service to find a bug to patch and the Bugmash Guide to get Rails from Github and create the patch.

My first Ruby on Rails patchRainer Blessing's Site | Rainer …

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!