Category Archives: Linux

The Linux Category actually encompasses *BSD, RH, Fedora, Ubuntu, and the like.

Install VMWare Server 2.* on Debian 5.0 Lenny

I started with an HP DL380 G4 – dual 3.4GHz Xeon single core 533MHz bus, 4GB RAM, 6x 36.4GB SCSI in RAID5 (182GB available), 2U server. I then went on to install Debian 5.0 Server x32. If I ever want to run Wine or another program it’s generally still easier to run 32bit software. That and I only have 4GB RAM anyway.

So then I wanted to install VMWare Server 2.0.1 for Linux. The exact file name and version: 2.0.1-156745.i386.tar.gz. Why not ESXi? While ESXi is also free and a hyperadvisor, there seems to be a lot more overhead in terms of administration and setup – that and I can’t figure out how to speed up the transfer of virtual machines over the network. AND we already have several other servers running VMWare Server so we can still use the linux side for internal sites.

I knew it would be a challenge so I was ready for whatever I needed to do. Running this same setup on CentOS took less than half the time. However, CentOS has a much larger footprint and takes noticeably longer to install. And now that I have the steps required, I think I shall use Debian more often. Apt-get > Yum. Nano > vi.

I’m assuming that you have a fully installed Debian server here and you have at least a little knowledge of linux. Most of the steps do not require me to let you know what’s going on. I always run the install as the root user (su), so you can add sudo to all the commands if you so desire.

I’m also assuming that you went to www.vmware.com, clicked on Products, then on Server (Free). You’ll have to sign up for an account before you can download, but that’s easy enough. Download the appropriate file, in my case it’s 2.0.1 32bit linux server NON-RPM.

First gunzip and de-tar our file:
tar xzvf VMware-server-2.0.1-156745.i386.tar.gz
cd vmware-server-distrib

Then we need to grab the prerequisites:
apt-get install libx11-6 libx11-dev libxtst6 xinetd wget
Notice that these are NOT quotes or apostrophes. Very important step BTW.
apt-get install linux-headers-`uname -r` build-essential
apt-get install binutils-doc make manpages-dev autoconf automake1.9 libtool flex bison gdb
apt-get install gcc
This will remove a “setup is unable to find the ‘killall’ program” error.
apt-get install psmisc

Might as well do some housecleaning and make sure everything is up to date.
apt-get update
apt-get upgrade

Now you can run the installer:
./vmware-install.pl

If the installer complains about the gcc kernel version:

Your kernel was built with “gcc” version “4.1.3”, while you are trying to use “/usr/bin/gcc” version “4.3.2”. This configuration is not recommended and VMware Server may crash if you’ll continue.

Blah blah blah.

First, show all the installed versions of GCC:
ls -l /usr/bin/gcc*

Which spits out the following:

lrwxrwxrwx 1 root root 7 2009-05-06 09:17 /usr/bin/gcc -> gcc-4.3
-rwxr-xr-x 1 root root 196996 2009-01-18 09:39 /usr/bin/gcc-4.1
-rwxr-xr-x 1 root root 207648 2008-12-31 06:52 /usr/bin/gcc-4.3
-rwxr-xr-x 1 root root 16288 2009-01-18 09:37 /usr/bin/gccbug-4.1

You can see that the gcc command is linked to version 4.3. Let’s link it back to 4.1 so vmware can stop complaining.
su -
export CC=/usr/bin/gcc-4.1
Then rerun vmware-config.pl

You will see that the compiler will now use GCC 4.1, which just so happens to be the same version that was used to compile the kernel. No more complaints! Yay!

Basically follow the wizard the remaining steps and you should be fine. The above should save you quite a bit of time, frustration, and … if you’re a consultant it’ll make you look good.

https://IP_OF_SERVER:8333/ui will then allow you to login using the information provided during setup of the server/setup of VMWare.

Backing Up A Linux Box

I finally came across a need to backup a linux box. Usually, in the past anyway, the linux box was such a strong contender that rarely if ever crashed that it seemed almost foolish to install AV and Backup software. Not that they crash more than they used to, but we rely on the systems so much more that we need viable backup solutions.

ClamAV, by the way, is a decent enough free solution to AntiVirus on a linux box.

Mondo is a great backup solution for a linux box.

I basically went to ftp://ftp.mondorescue.org/ and grabbed the three files I needed to get this running on a Debian 5.0 box.
(wget ftp://site/nameoffile)
File 1: mindi-busybox_1.7.3-1_i386.deb
File 2: mindi_2.0.6_i386.deb
File 3: mondo_2.2.8_i386.deb

Busybox is needed to install mindi, and mindi is needed to install mondo.

Install the applications:
Apt-get update
Apt-get upgrade
dpkg -i mindi-busybox_1.7.3-1_i386.deb
dpkg -i mindi_2.0.6_i386.deb
dpkg -i mondo_2.2.8_i386.deb

Create your bootable ISO rescue disk:
mindi
Select Yes for using your kernel for booting, and also Yes for creating an ISO of the CD.

Run your backup job:
mondoarchive

This will open up a window prompt wizard that allows you to choose where to backup your files.
Follow along with the wizard to finish your backup job.

Logging What Users Do In BASH

I like the BASH Shell – it’s fun and the default shell, so pretty much everyone can use it. And since I like the Ubuntu/Debian, the following steps apply to these systems – and you can probably figure out how to get them to work with BSD or another *nix flavor.

Finding out what people do with their access, on the other hand, is a little more difficult.

Sure, you can lookup their bash_history file, but that only goes back 15 to 25 commands (unless setup to a non-standard logging).
nano /home/username/.bash_history

Then I was turned onto Accounting Management:
apt-get install acct

That’s it! Easy, right?
Well, to see the information you have to know which commands to type.

LastComm shows the last command by a certain user, or when the command last matches your variable:
lastcomm username
lastcomm PID/Process

AC
ac
ac -d
ac -p

GD, Apache, Captcha, PHP, Error

I had to setup a captcha on someone’s website. The captcha refused to load. The easiest way to get the error (since, by default, PHP will not list out all the problems when called from another page) is to call the script directly.
Say your site is http://www.mysite.net. You’ll want to go to http://www.mysite.net/CaptchaSecurityImages.php. You can do the website math.

I had apache installed, GD installed, PHP installed.

This is the error I was receiving:
Warning: imagettfbbox() [function.imagettfbbox]: Could not find/open font in /var/www/sitehere/CaptchaSecurityImages.php on line 60

Error in imagettfbbox function, eh? That’s none too helpful. Good thing I can read: Could not find/open font. That’s all I need to know.

If you were to open up CaptchaSecurityImages.php and change the location of monofont.ttf to a debian/ubuntu file location, everything would probably end up working correctly.

SSH to your machine
nano CaptchaSecurityImages.php
Search for:
var $font = 'monofont.ttf'
and replace with:
var $font = './monofont.ttf'
Reload your script on your web browser

AWStats on Apache

If you’ve ever seen an Apache log file, you’ll notice that it’s rather long to read. It’s not that the log is hard to read, it’s just full of a lot of useless information. If you view a website with a browser, the log will show that you connect and retrieve every single file (images are included). Ouch.

I installed Debian 5.0 Server on an HP DL380 G4 server. I then did all the updates etc. I’m assuming you know how to install apache and how to “su” to root.

apt-get install awstats
nano /etc/apache2/awstats.conf
This creates a new file called awstats.conf

Alias /awstatsclasses “/usr/share/awstats/lib/”
Alias /awstats-icon/ “/usr/share/awstats/icon/”
Alias /awstatscss “/usr/share/doc/awstats/examples/css”
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch

Save this file and exit back to the shell.

nano /etc/apache2/apache2.conf

Add this to the end of the conf file:

Include /etc/apache2/awstats.conf

Save and exit apache.conf.

apache2ctl restart

cd /etc/awstats
cp awstats.conf awstats.www.mysite.org.conf
nano awstats.www.mysite.org.conf

Search for and edit the following:

LogFile=”/var/log/apache2/access.log”
SiteDomain=”mysite.org”

Save the file and exit to the shell.

Now we need to run the script to parse the log files into a stats page:
perl /usr/lib/cgi-bin/awstats.pl -update -config=www.mysite.org

If it fails due to permissions:
chmod -R 777 /var/log/apache2
Then re-run the script

Now check your stats at http://www.mysite.org/awstats/awstats.pl

As long as everything went to plan, the script should also automatically install a cron job to update the stats every 10 minutes.

You can find out by typing the following:
dpkg -L awstats | grep cron
Which shows the following:

/etc/cron.d
/etc/cron.d/awstats

If you nano the awstats cron, you can edit the times and locations of the scripts.

EDIT!!!

If you’re using virtual hosts (like I am) and you want each site to have its own stats:

Edit your sites-available default:
nano /etc/apache2/sites-available/default

Add the following in your VirtualHost:

NameVirtualHost 192.168.1.4

DocumentRoot “/var/www/web123”
ServerName web123.com
ServerAlias *.web123.com
CustomLog /var/log/apache2/web123.com.log combined

Then you’ll have to create the awstats.web123.com.conf file in /etc/awstats
cp /etc/awstats/awstats.conf /etc/awstats/awstats.web123.com.conf
nano /etc/awstats/awstats.web123.com.conf

Change the following:

LogFile=”/var/log/apache2/web123.com.log”
LogFormat=1
SiteDomain=”web123.com”
HostAliases=”web123.com www.web123.com localhost 127.0.0.1″

This will allow you to use the browser to update the stats if your CRON job is set for long periods of time:

AllowToUpdateStatsFromBrowser=1

And I set this up because I have apache do a DNS lookup on its own:

DNSLookup=0

Then restart apache:
apache2ctl restart

LAMP on Debian

LAMP is Linux Apache MySQL PHP. Debian is the primary for Ubuntu.

Tried to install Ubuntu server 8.10 on an HP DL380 G4 with mixed results. Grub was failing on me. Instead of trying to fix it I just took a Debian 5 CD and wrote it over. Only problem is no LAMP – Ubuntu is much better for setting up initially, but both OSes are basically the same.

nano /etc/apt/sources.list
remove the cdrom

apt-get update
apt-get upgrade
apt-get install ssh-server

apt-get install apache2
apt-get install apache2-mpm-prefork
apt-get install php5

apt-get install mysql-server php5-mysql
apt-get install phpmyadmin
apt-get install webmin
apt-get install libapache2-mod-php5 php5-cli php5-common php5-cgi

nano /etc/apache2/apache2.conf
AddType application/x-httpd-php .php
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.shtml index.htm

I installed SSH so I could remotely do the rest of the work.

At this point, you should be able to go to http://youripaddress and see a generic “IT WORKS!” apache page.
You can also go to http://youripaddress/phpmyadmin and load up the phpmyadmin page. I suggest prohibiting this from being viewed outside your internal subnet using access rules in apache.
Then you can go to http://youripaddress:10000 and view the webmin page

Potential Problems:
Your repository list is incorrect.
nano /etc/apt/sources.list
deb ftp://ftp2.fr.debian.org/debian/ stable main contrib non-free
deb-src ftp://ftp2.fr.debian.org/debian/ stable main

You can not apt-get webmin:
wget http://voxel.dl.sourceforge.net/sourceforge/webadmin/webmin_1.460_all.deb
dpkg -i webmin-1.460_all.deb
apt-get install -f

You want ASP support on this Linux Box:
apt-get install libapache-asp-perl

You want to edit the sudoers list:
apt-get install sudo
visudo
Uncomment the following line:
%sudo ALL=NOPASSWD: ALL

ESXi Enable SSH

This is one of those topics that is very easy to find on google, but I’m posting anyway.

Go to the console of your VM ESXi machine
Press Alt + F1
The password is “unsupported”
vi /etc/inetd.conf
Find the #SSH, and move the cursor over the #
x
X will delete the character under the cursor. i for insert before cursor. r for replace the current character with the character typed next.
:wq
: puts the vi editor into the command mode, w for write, q for quit.
Reboot your server