sandip's blog

Installing Bugzilla on an ISPConfig site

These are some notes I had taken down during the installation of Bugzilla on a server with ISPConfig hosting control panel:

Requirements:

# yum install mysql-devel gd-devel libpng-devel libjpeg-devel freetype-devel libdbm-devel
# rpm -e mod_perl #else mod_perl2 does not install.

Create Site:

Site was created via the ISPConfig control panel with "web6_bugs" as the admin user and "web6" as the group.

Install:

$ cd /var/www/web6
$ wget http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-3.0.tar.gz
$ tar -xvzf buzilla-3.0.tar.gz
$ mv buzilla-3.0/* web
$ ./checksetup.pl --check-modules
# perl -MCPAN -e 'install AppConfig' #had to force install.
# perl -MCPAN -e 'install Bundle::Bugzilla'
# perl -MCPAN -e 'install GD'  #requires libpng-devel, libjpeg-devel, freetype-devel
$ ./checksetup.pl #Edit the localcofig with the correct database settings.
$ ./checksetup.pl #Re-run anytime if needed, specifically if the file permissions are not correct.
$ chgrp -R apache . #Had to make all files belong to the apache group after re-running checksetup.pl .

Apache with mod_perl need the below directives in httpd.conf:

    PerlSwitches -I/var/www/web6/web -w -T
    PerlConfigRequire /var/www/web6/web/mod_perl.pl

Runs a lot faster, but is a memory hog. Suggested to turn off KeepAlive in apache when running mod_perl.

Crontab Entry:

# Bugzilla
5 0 * * * web6_bugs cd /var/www/web6/web; ./collectstats.pl
55 0 * * * web6_bugs cd /var/www/web6/web; ./whineatnews.pl
*/45 * * * * web6_bugs cd /var/www/web6/web; ./whine.pl

Hosting multiple domains pointed to the same web-space

Place the snippet of code in an index.php file to pull up a different web page for each domain pointed to the same web-space.

<?
$serverName = $HTTP_HOST;
$serverName = str_replace("www.",&quot;",$serverName);
$serverName = str_replace(".com",&quot;",$serverName);
$serverName = str_replace(".net",&quot;",$serverName);
$serverName = str_replace(".org",&quot;",$serverName);
if (!(empty($serverName))) {
   include("./".$serverName.".html");
}
?>

Installing APC Cache (alternative to Turck Mmcache/Eaccelerator)

Notes on installing Alternative PHP Cache (APC):

  1. Download and istall:
    $ wget http://pecl.php.net/get/APC-3.0.14.tgz
    $ tar -xvzf APC-3.0.14.tgz
    $ cd APC-3.0.14
    $ phpize
    $ ./configure --enable-apc
    $ make
    # make install
  2. Add the below lines to the php.ini:
      extension=/path/to/apc.so
      apc.enabled=1
      apc.shm_segments=1
      apc.optimization=0
      apc.shm_size=128
      apc.ttl=7200
      apc.user_ttl=7200
      apc.num_files_hint=1024
      apc.mmap_file_mask=/tmp/apc.XXXXXX
      apc.enable_cli=1
  3. Restart apache:
    # service httpd restart
  4. Check phpinfo() to see if APC is enabled.
  5. Copy the "apc.php" admin file in the source directory to a password protected web site directory. Edit "apc.php" top line to change password to something different from default.

Static compile and install of apache + mod_ssl + php on FC4

Latest Compile with pdo drivers for mysql along with mod_security.

NOTE:
Remove the MySQL-shared rpm else openssl will not work.

# rpm -e MySQL-shared-5.0.20a-0.glibc23

Inserting adsense code to multiple files...

Here's a quick bash script that I wrote to add adsense code just before the closing body tag in several accounts with the same file name. Could be modified to take the file names as the last argument if different.

Note: replace the UA-####### with your particular ID number assigned by adsense.

#!/bin/bash
# insert_adsense.sh
# usage: ./insert_adsense.sh {account} {count}

ACCOUNT=$1
COUNT=$2
FILE=/home/${ACCOUNT}/public_html/index.inc.php

ADSENSE="

<script src=\"http://www.google-analytics.com/urchin.js\" type=\"text/javascript\&quot;>
</script>
<script type=\"text/javascript\&quot;>
_uacct = \"UA-#######-${COUNT}\&quot;;
urchinTracker();
</script>

"

cp $FILE $FILE.bak

replace "</body>" "${ADSENSE}</body>&quot; -- $FILE

exit 0

masquerade with iptables

Allows for easy sharing of internet connection to an internal network with dynamic IP range.

# iptables -A POSTROUTING -t nat -o eth0 -j MASQUERADE

Sending mail to a SMTP server using telnet

$ telnet remotehost 25
HELO localhost
MAIL FROM: johndoe@localhost
RCPT TO: jilldoe@remotehost
DATA
Subject:Test Message
This is a test message.
.
QUIT

RAID notes...

  1. Create RAID-1 level array with 2 active devices and 1 spare:
    # mdadm -C /dev/md0 -l 1 -n 2 /dev/hda{8,9} -x 1 /dev/hda10

    Note: RAID-1 provides for redundancy and needs a minimum of 2 partitions and any number of spares.

  2. Show details:
    # mdadm --detail /dev/md0
  3. Mark Faulty:
    # mdadm --manage /dev/md0 -f /dev/hda8

    Note: When partition is marked faulty, the spare quickly replaces it in RAID 1 array.

  4. Remove:
    # mdadm --manage /dev/md0 -r /dev/hda8

    Note: Only faulty partitions can be removed.

  5. Add:
    # mdadm --manage /dev/md0 -a /dev/hda8

    Note: Only removed partitions can be added.

  6. Stop RAID:
    # mdadm --stop /dev/md0
  7. Run RAID:
    # mdadm --assemble /dev/md0 /dev/hda{8,9,10}

    Note: Before assembling, check on the UUID of the devices. They should all be the same and show only one array:

    mdadm --examine --scan /dev/hda{8,9,10}

  8. Remove the md signature from disk
    # mdadm --zero-superblock /dev/hda{8,9,10}
  9. Scan md superblock
    # mdadm --examine --scan
  10. Scan currently active arrays
    mdadm --detail --scan
  11. Monitor RAID:
    # nohup mdadm --monitor --mail=root --delay=300 /dev/md0 &

Check if cpu supports 64 bit

If the below produces lm (long mode) flags, then the cpu has support for x86_64 architecture.

# grep lm /proc/cpuinfo

I have seen quite a few dedicated servers with support for x86_64 architecture, but i386 installed instead.

When doing a `uname -a`, the output misleads you to think that x86_64 is not supported. Such machines do not fully utilize the hardware resources and decreases performance of you box.

Converting bin/cue to iso format

You might come across a disc image in the BIN/CUE format. BIN/CUE files can be directly burned to CD via K3B, however if you want to convert to an iso, a command line application called bchunk can be used.

# yum --enablerepo=extras install bchunk
# bchunk image.bin image.cue image.iso

Comment