Tag Archives: debian

HOWTO install php5-fpm on Debian Squeeze

PHP5-FPM

PHP5-FPM

Once PHP hit version 5.3, it started shipping with PHP-FPM, which is the new way to handle PHP requests when serving web content. Their site describes it as, “PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites“, but this is being pretty modest when you consider the host of improvements it brings over the old way of doing things when running PHP with an ‘alternate’ webserver such as lighttpd or nginx. So, it sounds like a slam dunk, time to remove all the handwritten fastcgi-php scripts from /etc/init.d, update PHP and go to town, right? Not so fast hot shot, in Debian Squeeze (stable) they don’t include PHP-FPM with PHP 5.3 (reasons for this tend to fall in the ‘not enough testing‘ variety), so we have to look elsewhere for a PHP with this (and other upgrades) enabled. This is exactly what the site and repo Dotdeb is there for, and they have the updated PHP 5.3 that includes the FPM module. So, to get it installed on Debian Squeeze we first have to add the repo line to sources.list

HOWTO automate Debian installs with preseed

Automatic (you know, for the people)

Automatic (you know, for the people)

I’ve installed Linux, probably 100s of times, and while going through all the questions and answers used to be fun, once you have everything decided it’s mainly a case of tab, space, enter, tab, tab, enter, space, space, tab, enter. I remember reading about kickstart, which was Red Hat‘s way of automating the install process, but Debian GNU/Linux (and by extension Ubuntu Linux) support  preseed. From Debian’s wiki, “Preseeding provides a way to set answers to questions asked during the installation process, without having to manually enter the answers while the installation is running. This makes it possible to fully automate most types of installation and even offers some features not available during normal installations.” So preseeding automates the install of the OS, the questions that you’d normally need to answer interactively are predetermined, and defined by a supplied configuration file, and sometimes boot parameters. So while Ubuntu is known for it’s user-friendly OS installer, Ubiquity, preseeding the Debian-Installer  (also known as “d-i”) is the recommended method for automating Ubuntu installations and for building custom install CDs. With this in mind I set out to build a preseed config file that would automate installs of virtual KVM machines we were provisioning at a gig, but looking at how I do such bare-bones base installs, this would work for most of my normal Debian installs at home too.

HOWTO monitor Tomcat with monit and munin in Debian

I have an existing Tomcat installation in production that has been running hot and causing monit to send me notices that such and such service is down, only to come back clear on the next run. Of course since I use monit I can see that the service was never restarted, plus I’ve never had this happen on other servers with monit, so I’m convinced that Tomcat, with its hunger for Java, is the culrprit here. I’ve been running munin for years on this server too, however I never got the Tomcat plugins to work with it, so I can’t gauge how hot Tomcat is running, and how changing the heap size is effecting things. Because of this, yesterday I got serious about it and finally got it working, but I had to take an end run to get it rolling and it wasn’t fun; which is why I’m posting it here. If anyone knows a better way to do this, please share in the comments and I’ll update this, but here’s how I was successful.

HOWTO use monit to monitor sites and alert users

Ok, I’ve used the process management software, monit, since at least 2004, and it is simply an indespensible tool in my sysadmin cache. Basically it watches a process, say like Apache, and restarts it if it dies. But wait, that’s not all, it does tons of other things. Want it to watch it and restart it at a certain time? Sure. How about if it uses 50% of system memory in 5 cycles (cycles are checks, 120 seconds by default)? Yep, it’ll take care of that. How about watching a file and stopping a service and/or issuing an alert by email or web if the file’s UID, permission, or whatever has changed?   No problem. Disk space is greater than 90% on one partition you want an email to go out to the admin? Easy. Seriously, once you start using monit you’ll be amazed at what you can cover, it’s truly one of the best tools I’ve ever used, and of course it’s GPL’d open source.

So, this week we had an issue where a some of our sites were down, and the monitor that watches them were internal to our network, and relied on some of the same resources; which is lees than ideal. I have a remote server running at one of our partner’s sites, so it’s the perfect canidate to watch our sites from a ‘real world’ view.

HOWTO: log the user's IP, not the proxy's, in nginx access log

nginx

nginx

So back in January I had a post about HOWTO: log the user’s IP, not the proxy’s, in Lighttpd access log, but today I switched that system to run nginx (actually nginx has been running since early this year, I just got lazy on running Varnish) fronted again by Varnish. I had the same issue, but not much trouble solving it. Since I often refer to my own notes on fak3r, I’m recording it here for myself, and anyone streaming in from Google. So, as I talked about before, when you run a webserver behind Varnish doing http acceleration, the webserver access logs will display the IP of the proxy (generally 127.0.0.1) instead of the end user’s IP. This not only breaks any kind of tracking or reporting you want to run against your webserver logs. Since this server runs Varnish in front of nginx, and it reveals the end user’s IP in the header as X-Forwarded-For, so it’s just a matter of making nginx use that variable in its access logs instead of the default variable defining the referring IP. Once we know that, the configuration is simple.  Edit your nginx.conf file:

Page 1 of 3123