Tuesday, April 16, 2013

Apache 2.4 Installation


In this I will explain how to install apache 2.4 on linux based systems.
First, Check httpd is installed or not
rpm -qa | grep httpd
If httpd on the system
rpm -e httpd

 Create a user apache with group apache
# groupadd -g 48 apache
# useradd -u 48 -g 48 -G users -s /bin/nologin -d /dev/null -m apache

 Download http source ball
# cd /opt/src
Compile http from tar ball
# tar -zxvf httpd-2.4.3.tar.gz
# tar -zxvf apr-1.4.6.tar.gz
# mv apr-1.4.6 httpd-2.4.3/srclib/apr
# tar -zxvf apr-util-1.4.1.tar.gz
# mv apr-util-1.4.1 httpd-2.4.3/srclib/apr-util 

Asterisk on linux


vim /etc/apt/source.list
deb http://ftp.debian.org/debian/ lenny main contrib non-free
deb-src http://ftp.debian.org/debian/ lenny main contrib non-free
apt-get install linux-headers-`uname -r` libc6-dev zlib1g-dev bison openssl libssl-dev libasound2 libasound2-dev libslang2-dev libnewt-dev libncurses5-dev binutils cpp-4.1 gcc-4.1 libstdc++6-4.1-dev g++ make libpq5 libapr1 libexpat1 libaprutil1 libxml2 fxload libusb-dev libiksemel-dev zlib-bin libc6-dev libbluetooth2-dev libxml2-dev
Downloading necessary packages: LIBPRI, DAHDI, AND ASTERISK
Libpri Installation

Recover a MySQL root password


If we forgot the mysql root password, don't worry. We can update the mysql root passord by following the below mentioned steps ..

Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server.
# /etc/init.d/mysql stop
# mysqld_safe –skip-grant-tables &
# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD(“newrootpassword”) where User=’root’;
mysql> flush privileges;
mysql> quit
# /etc/init.d/mysql stop
# /etc/init.d/mysql start

Now we can give the  newrootpassword as root passwd for mysql. That is ,

#mysql -u  root -p
#newrootpasswor
 mysql>

How to mount tomcat using mod_jk on linux


Mod jk is a module used in apache for mountinfg the applications running on apache tomcat to apache and also unmounting for its own servings. Mod jk can be configured in ubuntu based systems by following the below steps.

Configure mod_jk with Apache in Ubuntu
1. Install mod_jk: To install mod_jk in ubuntu execute the following command on the command line.
sudo apt-get install libapache2-mod-jk
2. Enable mod_jk loading: Create a link in /etc/apache2/mods-enabled/jk.load which points to /etc/apache2/mods-available/jk.load. This will enable loading mod_jk module in apache when apache is restarted.
3. Create mod_jk conf file: Create a mod_jk conf file and place it in /etc/apache2/mods-available/jk.conf
# Where to find workers.properties
# Update this path to match your conf directory location
JkWorkersFile /etc/apache2/jk_workers.properties
# Where to put jk logs
# Update this path to match your logs directory location
JkLogFile /var/log/apache2/mod_jk.log

Takeout a table from a full mysql database dump


vim MyDumpSplitter.sh
#!/bin/sh
#SPLIT DUMP FILE INTO INDIVIDUAL TABLE DUMPS
# Text color variables
txtund=$(tput sgr 0 1)    # Underline
txtbld=$(tput bold)       # Bold
txtred=$(tput setaf 1)    # Red
txtgrn=$(tput setaf 2)    # Green
txtylw=$(tput setaf 3)    # Yellow
txtblu=$(tput setaf 4)    # Blue
txtpur=$(tput setaf 5)    # Purple
txtcyn=$(tput setaf 6)    # Cyan
txtwht=$(tput setaf 7)    # White
txtrst=$(tput sgr0)       # Text reset

uninstall a perl module in linux

For removing a perl module from your linux system just create a pl file as mentioned below.
vim removeperlmodules.pl
#!/usr/bin/perl
use ExtUtils::Packlist;
use ExtUtils::Installed;
$ARGV[0] or die “Usage: $0 Module::Name\n”;
my $mod = $ARGV[0];
my $inst = ExtUtils::Installed->new();
foreach my $item (sort($inst->files($mod))) {
print “removing $item\n”;
unlink $item;
}
my $packfile = $inst->packlist($mod)->packlist_file();
print “removing $packfile\n”;
unlink $packfile;
usage –>
perl removeperlmodules.pl mod::ule

This will uninstall the  mod::ule from the system.

Perl module version check


vim mod_version.pl
#!/usr/bin/perl
use ExtUtils::Installed;
my ($inst) = ExtUtils::Installed->new();
my (@modules) = $inst->modules();
foreach $mod(@modules)
{
$version = $inst->version($mod);
printf(“%-35s %-15s \n”, $mod , $version);
}
usage –>
perl mod_version.pl mod::ule

Mail sending via perl


vim mail.pl
#!/usr/bin/perl -w
use strict;
use Mail::Sender;
my $filename = $ARGV[0];
my $smtp = “192.168.1.1″;
my $subj = “Hello”;
my $toaddr = ‘totest@test.com;
my $fromaddr = ‘fromtest@test.com’;
my $body = “Hello Administrator, Attached is the report. Thank you.”;

count no of rows in all mysql tables


vim count.sh
#!/bin/bash
db=$1
connect=”mysql -u root $db –skip-column-names”
for tbl in `$connect -e “show tables;”`
do
result=`$connect -e “select count(*) from $tbl;”`
echo -e “$tbl —— $result”
done
usage –>
./count.sh <database>

awstat for web tracking

AWstat is a free real-time logfile analyzer to get advanced statistics ..

Here I will explain how to install it by downloading your version of awstat.

Untar the package by issuing the below command,
tar -zxvf /var/Packages/awstats-7.0.tar.gz
mv awstats-7.0  /usr/local/awstats

Enter a new virtual hosts in the apache configuration,
vim /etc/httpd/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot “/usr/local/awstats/wwwroot”
ServerName awstats.test.com
ErrorLog “logs/awstats-error_log”
CustomLog “logs/awstats-access_log” common

Install PDNS in debian

Here I will explain how to install pdns in linux debian.
apt-get update
apt-get install gcc g++ make libncurses5-dev
Mysql Installation:
groupadd mysql
useradd -g mysql -d  /var/mysql  -m mysql
tar –xvzf  mysql-5.1.62.tar.gz
cd  mysql-5.1.62
./configure –prefix=/usr/local –localstatedir=/var/mysql/data –with-charset=latin1 /
–with-extra-charsets=none –with-tcp-port=3306 –enable-assembler –without-debug /
–with-unix-socket-path=/tmp/mysql/unix.sock–enable-static –with-mysqld-user=mysql \
–enable-thread-safe-client –enable-shared –with -plugins=partition,innobase
make && make install

Mysql 5.1* installation

Check mysql is installed or not
rpm -qa | grep mysql
If mysql on the system
rpm -e mysql
Create a user mysql with group mysql
# groupadd -g 501 mysql
# useradd -u 501 -g 501 -G users -s /bin/bash -d /var/mysql -m mysql
Download Mysql source ball
# mkdir /var/mysql/src
# cd /var/mysql/src/
# wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.65.tar.gz
# chown -R mysql.mysql /var/mysql/src/

mysql 5.5 in Debian


groupadd mysql
useradd mysql -s /bin/bash -m /var/mysql -g mysql
chown -R mysql.mysql /var/mysql/data
apt-get install cmake gcc g++ automake
tar -zxvf mysql-5.5.24.tar.gz
cd mysql-5.5.24/
cmake . -DMYSQL_DATADIR=/var/mysql/data -DCMAKE_INSTALL_PREFIX=/usr/local/ -DINSTALL_LAYOUT=STANDALONE -DENABLED_PROFILING=ON -DMYSQL_MAINTAINER_MODE=OFF -DWITH_DEBUG=OFF

Install LDAP + SAMBA on linux


First Install Samba
# apt-get install samba samba-doc smbclient
vim smb.conf
[global]
# Domain name ..
workgroup = TECH.COM
# Server name – as seen by Windows PCs ..
netbios name = TECH.COM
# Be a PDC ..
domain logons = Yes
domain master = Yes
# Be a WINS server ..
wins support = true
obey pam restrictions = Yes
dns proxy = No
os level = 35
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
pam password change = Yes