Monthly Archives: December 2011

Installing MySQL, Apache, PHP & mod_perl on Debian from source

Introduction

I am writing this article because I believe it may be useful to people other than just myself. I am new to Linux. However, the command-line environment is not unfamiliar to me. I have been avidly using FreeBSD since 1996 (2.1.5) and I am usually found with my head in a Cisco or Juniper terminal most of the day. Even with this experience, I found installing installing MySQL, Apache, PHP and mod_perl on Debian to be laborious and tedious. You see, on a FreeBSD server, you can nearly install Apache right out of the box. Install the perl and libxml2 packages and you’re ready to go. For whatever reason, the people driving Debian’s development have decided that you either need to install everything using apt-get (a package manager similar to FreeBSD’s pkg_add or Redhat’s rpm) which is a horrifically terrible idea in a production environment, or jump though a plethora of hoops to install from source. I mean, Debian doesn’t even include gcc in the base install. Huh?

One thing FreeBSD does not do well, yet, is virtualization. Today, I needed a virtual box and my choices were between six different flavors of Linux and a few flavors of Windows. Windows is completely out of the question, so I was left to decide which Linux distribution I wanted to meander through. I recently worked for a company that used Debian (5.0 Lenny) as well as FreeBSD. I made a calculated decision that they, FreeBSD lovers, chose Debian because it closely resembled FreeBSD. I have still not decided whether or not my calculations were correct or not. Either way, I am armed with my good friend Google, who seldom lets me down when I encounter Linux issues. It would seem that someone has already been there, done that, fixed it and shared it. This is my attempt to give back.

Audience

Anyone looking to install MySQL 5.1, Apache 2.2, PHP 5.3 and mod_perl 2.0 on a Debian install.

Prerequisites

You will obviously need a box running Debian. I happen to be running Debian 6.0 Squeeze with the Linux 2.6 kernel.

Linux server 2.6.32-5-xen-amd64 #1 SMP Tue Mar 8 00:01:30 UTC 2011 x86_64 GNU/Linux

You will also need to download the source tarballs for MySQL, Apache, PHP and mod_perl

http://www.mysql.com/downloads/mysql/5.1.html
http://httpd.apache.org/download.cgi
http://www.php.net/downloads.php
http://perl.apache.org/download/index.html

Assumptions

  • You have a fresh Debian install
  • You have root privileges
  • You’ve downloaded all your sources to ‘/usr/local/src’
  • You’re installing MySQL in ‘/usr/local/mysql’
  • You’re installing Apache in ‘/usr/local/httpd’
  • You’ve created a user named ‘mysql’

Dependencies

During my installation, I tripped over several missing updates and libraries. In order for you to avoid encountering the same issues, please install the following updates and required libraries:

# apt-get update && apt-get upgrade
# apt-get install build-essential
# apt-get install libncurses5-dev
# apt-get install libxml2-dev
# apt-get install zlib1g-dev
# apt-get install libssl-dev
# apt-get install libgdbm3
# ln -s /usr/lib/libgdbm.so.3 /usr/local/lib/libgdbm.so
# ln -s /usr/lib/libperl.so.5.10 /usr/local/lib/libperl.so

The nitty gritty

Unpack the tarballs

# cd /usr/local/src
# tar xvfz mysql-5.1.60.tar.gz
# tar xvfz httpd-2.2.21.tar.gz
# tar xvfz php-5.3.8.tar.gz
# tar xvfz mod_perl-2.0-current.tar.gz

Configure, make and install MySQL

# cd /usr/local/src/mysql-5.1.60
# ./configure ––prefix=/usr/local/mysql ––with-plugins=innobase
# make
# make install
# ./scripts/mysql_install_db
# chown -R mysql:mysql /usr/local/mysql/var
# /usr/local/mysql/bin/mysqld_safe ––bind-address=127.0.0.1 &
# /usr/local/mysql/bin/mysqladmin -u root password 'your-new-password-here'

Configure, make and install Apache

# cd /usr/local/src/httpd-2.2.21
# ./configure ––prefix=/usr/local/httpd ––enable-modules=all ––enable-mods-shared=all ––enable-so ––enable-ssl
# make
# make install

Configure, make and install PHP

# cd /usr/local/src/php-5.3.8
# ./configure ––with-mysql=/usr/local/mysql ––with-apxs2=/usr/local/httpd/bin/apxs
# make
# make install
# cp php.ini-production /usr/local/lib/php.ini

Add the following lines to your httpd.conf file

AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

Insert them right after the following line:

AddType application/x-gzip .gz .tgz

Configure, make and install mod_perl

# cd /usr/local/src/mod_perl-2.0.5
# perl Makefile.PL MP_APXS=/usr/local/httpd/bin/apxs
# make
# make install

Add LoadModule config to your httpd.conf

LoadModule perl_module modules/mod_perl.so

Add that line where all the other LoadModule declarations are located.

And to finish it off…

Don’t forget your start-up scripts!

Conclusion

Once all the speed bumps are removed, installing from source is a piece of cake and doesn’t take long at all. Obviously, this is a very straight forward install and most of the time you’ll want to add several configuration options, especially to PHP.

I hope that you found this useful.

OnCall for Nagios app

UPDATE AS OF OCTOBER 10, 2017: This app is no longer supported in IOS 11 and it appears that the author has abandoned the project.

I recently purchased this iPhone app for my iPad and iPhone in hopes that it would glean information out of Nagios and provide a clean, easy-to-use, summary.  It did exactly that.

However, there are a few good things and a few not-so-good things you should know.

The app was designed with the iPhone in mind.  If you’ve ever tried to acknowledge an alert using Safari on your iPhone, you know how tricky it can be.  It involves several steps and an incredibly small user interface which frequently gets fat fingered .  OnCall for Nagios solves that.  It provides a concise summary of all network issues and allows you to filter issue types to see only what matters to you at that moment.  It also provides detailed information about individual problems and allows for quick and easy acknowledgement, rescheduling of the next check and even the scheduling of downtime.

Some things that I feel could have been done better are the documentation, FAQ and the support pages, which are pretty much non-existent.  There is a support page, but it contains nothing more than email address to email the app author for support.  Luckily, the app is very intuitive and easy to configure, so this is not too much of an issue.  There is however one configuration gotcha.

When I configured the application initially, I was asked for the URL, but I wasn’t sure which URL it wanted; the URL in which I access Nagios from the web or the true path to the cgi-bin.  It turns out that it is the cgi-bin path that it wants.  Because this was ambiguous and because there is a lack of documentation, as mentioned previously, I had to email the author.  I first reached out to him at 8:30pm on a Saturday night.  I figured I would receive a reply sometime on Monday.  Wrong.  He replied in less than 30 minutes and quickly pointed me in the right direction with regards to the URL.  He was also very pleasant.

Something I would love to see is a version for the iPad.  Because it is an iPhone app, it’s actually better to use Safari on your iPad.

Pros: easy to navigate, easy to use, easy to configure, inexpensive, good support

Cons: lack of documentation, no iPad support

In conclusion, if you are using Nagios and an iPhone, this app is a must.  The not-so-great issues are small.  The upside is big.  Definitely worth the money.

http://itunes.apple.com/us/app/oncall-for-nagios/id431794127