Filed under CLI | by Samuel Huckins | Date Posted: February 22, 2009 - 2:02 AM
While experimenting with mod_python, I ended up completely hosing my local Apache installed. I had the configuration files in a bad state, so I thought I would just drop all of /etc/apache2, remove Apache, and re-install it. But once that happened, /etc/apache2 wasn’t remade! When I tried to start or stop Apache, it spat back:
1
| .: 44: Can't open /etc/apache2/envvars |
Oh right, thanks… So here’s what I did to erase Apache’s memory of my mistakes:
- Find and drop all Apache packages:
1 2
| sudo dpkg --get-selections | grep apache
sudo apt-get remove --purge apache2 apache2-mpm-worker apache2-threaded-dev apache2-utils apache2.2-common libapache2-mod-python libapache2-mod-python-doc libapache2-mod-wsgi |
- Re-install Apache:
1
| sudo apt-get install apache2 libapache2-mod-python libapache2-mod-wsgi libapache2-mod-python-doc |
After this, all the configuration files were back, and I had a default Apache install.
Tags:
Apache,
CLI,
Linux
February 22, 2009 - 2:02 AM
Filed under CLI | by Samuel Huckins | Date Posted: December 6, 2008 - 12:58 AM
While top can show you that yes, it is Apache that is taking up all your server’s resources, what can you do to narrow down the activity to a particular site being served on the box? You could tail the access_log, but on anything but a slow server, that leads more to blindess than enlightenment. And perhaps you want something a little more current than utilities that can chew through Apache log files and give you stats.
In looking for this, I came across Apachetop. This handy little utility parses your log files and gives you all sorts of configurable stats in real time, in a clean CLI human readable interface. This article over at HowToGeek does a great job describing how to install it (in most package handlers), use it, and configure it, so I won’t re-hash it all here. Here’s some example output (updating as soon as activity occurs of course):

Tags:
Apache,
CLI,
monitoring,
top
December 6, 2008 - 12:58 AM
Filed under CLI | by Samuel Huckins | Date Posted: July 3, 2008 - 12:51 AM
Often when troubleshooting or setting up servers, I need to know the installed versions of applications commonly grouped into the “LAMP” stack. I dislike having to remember the slight differences between them when trying to coerce each to divulge their version. So I created a script that does that, and even prints it all in easy-to-read colors!
The code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| #!/bin/bash
###################################
#
# Written by Samuel Huckins
#
# July 2007
#
# Prints out version info for
# things in the LAMP stack.
#
###################################
#
echo -e "\e[1;34mThis machine's LAMP stack:\e[0m"
echo ""
# Linux:
LINUX=`cat /etc/issue`
echo -e -n " * \e[31mL\e[1;33minux: \e[0m"
echo "$LINUX"
# Apache:
echo -e -n " * \e[31mA\e[1;33mpache: \e[0m"
if [ -e /usr/sbin/httpd ]
then
echo "`/usr/sbin/httpd -v| head -n 1 | awk '{print $3}'`"
elif [ -e /usr/sbin/apache2 ]
then
echo "`/usr/sbin/apache2 -v| head -n 1 | awk '{print $3}'`"
else
echo -e "\e[37mNot present\e[0m"
fi
# MySQL:
echo -e -n " * \e[31mM\e[1;33mySQL: \e[0m"
if [ -e /usr/bin/mysql ]
then
echo "`/usr/bin/mysql --version | awk '/Ver/ {print $2, $3, $4, $5}' | sed 's/,//'`"
else
echo -e "\e[37mNot present\e[0m"
fi
# PHP:
echo -e -n " * \e[31mP\e[1;33mHP: \e[0m"
if [ -e /usr/bin/php ]
then
echo "`php -v`"
else
echo -e "\e[37mNot present\e[0m"
fi
# Perl:
echo -e -n " * \e[31mP\e[1;33merl: \e[0m"
if [ -e /usr/bin/perl ]
then
echo "`perl -v | awk '/This is perl/ {print $4}' | sed 's/v//'`"
else
echo -e "\e[37mNot present\e[0m"
fi
# Python:
echo -e -n " * \e[31mP\e[1;33mython: \e[0m"
if [ -e /usr/bin/python ]
then
echo "`/usr/bin/env python -V 2>&1 | awk '/Python/ {print $2}'`"
else
echo -e "\e[37mNot present\e[0m"
fi
# done
echo "" |
The result:
Call it “lamp-version-printer.sh”, and add something like “alias lamp=”~/my/code/lamp-version-printer.sh”. Couldn’t be easier.
Minor caveat: While the script does check each program for existence, I only check the most common place. It could be better expanded to cover less used locations for applications, conventions on more OSes, etc.
Tags:
Apache,
Bash,
CLI,
LAMP,
MySQL,
Python
July 3, 2008 - 12:51 AM