Thursday, January 29, 2009

Fixing Error "cannot open shared object file: No such file or directory"

There are instances during our installation that a shared object, commonly on .so files, cannot be openned or located. To fix this issue here are the steps to take.

1. locate the .so or object file that cannot be opened

locate (objectname).so

Ex. locate libmp4.so

-you will get the path

/usr/local/lib/libmp4.so.0

2. Take note of its path

3. Open ld.so.conf, usually it is on /etc/ld.so.conf

vi /etc/ld.so.conf

4. Add at the end the path of the shared object

include ld.so.conf.d/*.conf
/usr/local/lib/

5. Save it then issue this command

/sbin/ldconfig

-- You're done

Hope you find this helpful. Thanks and God Bless!!!

Setting up a LAMP Server

It is a common task for Linux System Administrators to set up and to establish a web server. On Linux Systems it is common to have Linux, Apache, MySQL and PHP for production. In this tutorial I'll show you on how to set up LAMP with the latest Httpd (Apache), MySQL, and PHP. Here I'll be using CentOS 4.7.

Actually you can have a LAMP running Apache 2.0, PHP 5.1 and MySQL 5.0 on CentOS 4/RH4 easily with yum. How?
Here it is:

To install apache 2.0
yum --enablerepo=centosplus install httpd
To install mysql 5.1
yum --enablerepo=centosplus install mysql mysql-server
To install PHP 5.1
yum --enablerepo=centosplus install php

Then you are done you have a CentOS 4.x running Apache 2.0 MySQL 5.1 and PHP 5.1. Hmmm quite nice isn't it.

But how about if you really insist to have the latest. Well then here is how.

Of course you have to remove all the old Apache, PHP and MySQL instances. Here's how to do it.

1. First check if they are currently installed
rpm -qa|grep httpd ;to check if Apache is installed
rpm -qa|grep mysql ; to check if mysql is installed
rpm -qa|grep php ; to check if php is installed

2. If they are installed then remove them
yum remove httpd
yum remove mysql
yum remove php

3. Remove the remaining traces or dependencies of it
rpm -qa|grep php

you will see here like

php-common
php-pdo

remove them via

rpm -e php-common php-pdo

do the same thing on httpd and mysql

rpm -qa|grep (packagename)

then remove remaining traces

rpm -e (packagename)

4. Once all is clean we can start downloading all the latest packages for our new LAMP

Installing Apache

1. Goto /usr/src

cd /usr/src

1. Get the latest apache server say 2.2.x

wget http://apache.mirrors.biblionix.com/httpd/httpd-2.2.11.tar.gz

2. Extract it

tar xvzf httpd-2.2.11.tar.gz

3. cd httpd-2.2.11

4. then under the httpd folder do the following

./configure
make
make install

By default the apache is installed at /usr/local/apache2 folder

5. Set the necessary configuration you want for your web server

vi /usr/local/apache2/conf/httpd.conf

in my case I set my document root on /var/www/html
to avoid directoy listing do this
On directory directive you will see this

Options Indexes FollowSymLinks

make it like this

Options -Indexes FollowSymLinks

well enough on httpd configurations we'll have more on our next discussions to follow

6. To make the httd start at boot, we'll put it on Linux services. How?

- copy first the apachectl script from the httpd folder

cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

- we put it on under init.d since all start up scripts are under this folder and being executed upon boot

- we're not done yet. Open httpd startup script.

vi /etc/init.d/httpd

- Add the following entries after the second line

# chkconfig: - 85 15
# description: Apache Web server

- let us add it on the Linux services

/sbin/chkconfig --add httpd

- then set it to start on running levels 345

/sbin/chkconfig --level 345 httpd on

- check if it is set well

/sbin/chkconfig --list|grep httpd

- you should see this

httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

7. Now start the httpd service by

/sbin/service httpd start

8. to check if it is running

/sbin/service httpd status (only works for apache installed via rpm or yum)

or do

ps aux|grep httpd (works for all so just do this in our case)

- you should see either of the following

root 27093 0.0 0.1 4108 1808 ? Ss 14:31 0:00 /usr/local/apache2/bin/httpd -k start
apache 27114 0.0 0.1 4108 1640 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27115 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27116 0.0 0.1 4120 1648 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27117 0.0 0.1 4108 1648 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27118 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start
apache 27119 0.0 0.1 4108 1300 ? S 14:32 0:00 /usr/local/apache2/bin/httpd -k start

-- now you have a running Apache server version 2.2

Installing MySQL

We'll do the RPM way of installing this one.

1. First you have to know what version of CentOS you have and what platform are you working in with.
- to know what platform are you working with issue the command

uname -i ; this will display or echo the platfrom in my case its i386

- to know what OS version are you running with open this file or just do cat

cat /etc/redhat-release ; this will display the OS version in my case it's CentOS release 4.7 (Final)

2. Since we're running i386 platform and version 4.x CentOS we'll download the necessary MySQL rpm packages suitable to this platfrom. In this case it is x86 or Red Hat Enterprise Linux 4 RPM (x86) downloads. Here are the things we need.

- MySQL-server-community-5.1.30-0.rhel4.i386.rpm
- MySQL-client-community-5.1.30-0.rhel4.i386.rpm
- MySQL-devel-community-5.1.30-0.rhel4.i386.rpm
- MySQL-shared-community-5.1.30-0.rhel4.i386.rpm

- so let's download them

wget http://(Mirror-linkname)/(rpmpackagename)

3. Once all neede packages are downloaded we can now install them. Issue the following command

- to install each of the packages issue this

rpm -ivh (packagename)

Ex. rpm -ivh MySQL-server-community-5.1.30-0.rhel4.i386.rpm

4. Then ensure that mysql service can start at boot.

/sbin/chkconfig --list|grep mysql

- you should see this

mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

- if it is not then make sure it runs / start on run level 345

/sbin/chkconfig --level 345 mysql on

5. Start MySQL service

/sbin/service mysql start

6. By default MySQL root has no password so just set its password say by installing first phpMyAdmin then reset password there or just go using the mysqladmin or mysql console command to reset password.

-- Now you have a running MySQL server version 5.1.x

Installation of PHP

Before we proceed on installing PHP we need the following to be installed first. These packages are known and commonly used on web development such as XML, web service and others

- curl (compile from source or you can do yum)
- curl-devel (if you did yum on curl)
- zlib (compile from source or do yum)
- libxml2 (compile from source or do yum)
- libxml2-devel (if you did yum on libxml2)
- openssl (you can do yum on this one)
- libpng (do yum here)
- libpng-devel (do yum here)
- gd (do yum)
- gd-devel (do yum)

Once all of these package are installed we can proceed on php installation.

1. Get the latest PHP packages from php.net

2. Goto /usr/src

3. Extract it there

4. cd php-5.x/

5. then issue this

./configure --with-mysql --enable-soap --with-apxs2=/usr/local/apache2/bin/apxs --enable-ftp --with-curl --with-curlwrappers --with-zlib --with-gettext --with-gd

make

make install

6. You now have installed PHP 5.x

7. There are things to verify to make PHP5 really running. How? Create you phpinfo.

8. If phpinfo is not displaying any content at all then there must have any problem on the httpd configuration. Here are the things that you should ensure to have on you httpd.conf

LoadModule php5_module modules/libphp5.so ; by default this is placed by PHP installer

DirectoryIndex index.php index.html


AddType application/x-httpd-php .php

AddHandler php5-script .php

AddType text/html .shtml .php

9. Save your changes on the httpd.conf and restart apache.

10. Check again your phpinfo it should display the current PHP and apache settings.

11. By the way sometimes php.ini is not set up so just copy the php.ini to the configuration path check phpinfo for the right path

- on phpinfo you will see

Configuration File (php.ini) Path /usr/local/lib

- copy the recommended php.ini settings

cp /usr/src/php-5.X/php.ini-recommended /usr/local/lib/php.ini

-by the way you should always restart your Apache service after saving any changes you applied on php.ini.

=== Now you have the latest LAMP running.

Hope you find these useful. Thanks, Cheers and God Bless!!!

Local Channel in Asterisk

Local channel in asterisk is usually use to connect two or more call legs. It is usually done via Manager API, AGI or thru a call file dumped on /var/spool/asterisk/outgoing/

If you're going to call Local channel and want to monitor its call durations use the '/n' flag.

Here it is

Local/extension@context[/n]

Here is an example, a snippet of a script

fputs($socket, "Channel: Local/1$number@wakeout/n\r\n");
fputs($socket, "Context: wakeout\r\n");
fputs($socket, "Exten: waketest\r\n");
fputs($socket, "Priority: 1\r\n");

This is important most especially for billing purposes.

Hope you find this helpful. Thanks, CHeers and God Bless!!!

Tuesday, January 27, 2009

Resolve False Hangup Detection on TDM400 on Asterisk

One of the issue I have encountered on digium card specifically TDM is the hangup detection. Some indications that you have this problem are: 1.) Random hangups 2.) Incoming calls still get through even if the outside caller has already hangup. Here are the possible solutions that can be done with it.

Set the following entries on your chan_dahdi.conf (that is if it is dahdi if not it is zapata.conf)

; first is the polarity switching
; most of the countries supports polarity reversal whenever answer or hangup happens

hanguponpolarityswitch = yes
answeronpolarityswitch = yes

;detect busy
busydetect = yes
;count the busy tones
busycount = 6
;set call progess works in mine
callprogress = yes
; set progress zone
progzone=ph ; in my case it's Philippines

After that you have to restart Asterisk for the changes to take effect. Then test the result.

I do hope you find these helpful. Thanks, Cheers and God Bless!!!!

Saturday, January 24, 2009

Basics Sometimes are forgotten (Fixing few Windows issue)

I was really upset when I found my workstation not booting up. I just learned that my workstation got a virus. It was infected when I plug my USB drive. The worst is I don't have any anti-virus on my workstation. By the way the workstation that I have at the office is Windows based. Then I don't have any idea what to do next since my workstation does not resume or load the login window. A co-worker of mine told me of this basics. He told me that I can load back or boot my windows workstation on the last working configuration. Hmmmm I didn't know that. So here was what he suggested me to do.

1. Reboot / reset the windows machine
2. Upon boot press repeatedly the F8 to go to the advance windows menu configuration
3. Select "Last Working Configuration"
4. Then you're done...

But if ever you have to repair the windows OS then you have to use an installation CD to fix your problem.

1. Reset your machine
2. Upon booting press repeatedly the delete button to goto the BIOS settings
3. Select to boot first on the CD-ROM
4. Then there you go ...

Hope you find this helpful. Cheers and God Bless!!!!

Protecting Your Linux Systems

ALthough Linux is said to be a very secured OS. It is still highly recommended to install applications that will enhance its security and integrity. There are many kinds of threats out there that could really trip up a system. To name few are virus, rootkits, brute force attack and etc.

Here are some softwares that you can install on your Linux system and few of them are must to have.

- Netfilter's IPTables (firewall) ; of course you should enable it and set your rules
- fail2ban ; need this if ever there are ports / services that will be openned to the public say ssh
- chkrootkit ; this one is like a check up of the Linux files integrity
- clamav (optional) - this one is an anti virus but actually Linux sometimes does not require it

Ok those are just few that I know you can have on your system.

Hope you find this brief discussion helpful. Cheers and God Bless!!!

Friday, January 23, 2009

Asterisk DTMF Issue Fixed

One of the issues that is known with Asterisk is the reliability on how it handles DTMF. By the way what is DTMF. DTMF in layman's term is touch tone. This are the digits being dialed. We usually encounter this when we call a customer service where we're asked to dial a certain option. Say "Press 1 for sales .....".

One problem that I encountered on this was how poorly the Asterisk server accepts DTMF or send DTMF. Actually this is not an Asterisk issue but the way how the Asterisk is configured.

Is there a resolution to it? Well, there is.

Here's are some notes and how.

There are 4 modes where asterisk can handle DTMF. We have rfc2833, info, inband and auto. Among these modes, based on majority suggestions out there, it is recommended to use RFC2833.RFC2833 is said to work perfectly with asterisk. By the way RFC2833 is an out-of-band DTMF mode.

To set Asterisk to use RFC2833 then set on the configuration files (sip.conf, iax.conf and chan_dahdi (I am not sure here...)) and look for this option.

dtmfmode=(mode)

Set it to:

dtmfmode = rfc2833
rfc2833compensate = yes
relaxdmtf = no ; should be no because setting it to yes cause talkoff

then reload the module say 'sip reload'

Another suggestion is to use:

dtmfmode=auto

Here Asterisk will use RFC2833 first as its default way of relaying DMTF. If the remote side does not suppor it, then it will switch to Inband mode. But a note on this. If you plan to use this mode, make sure that you are only using ulaw codec as the Inband mode is very problematic on non ulaw codec.

Personally I recommend just using the RFC2833 as your mode for DTMF handling because it is proven to work perfectly and reliably on Asterisk. It is your choice to use auto also.

Hope this discussion will be helpful. Cheers and God Bless!!!!

Tuesday, January 20, 2009

PHP Native Session Handling

#native php session handling


// initializes session handling in php
session_start();

// assign and set session variables
$_SESSION['varname'] = 'value';

// unset a certain variable
unset($_SESSION['varname']);

// free all session variables
session_unset();

// terminate or kill session handling
session_destroy();

Tuesday, January 13, 2009

Asterisk Installation

Asterisk is known to be the leading open source IP PBX. It has been the best choice alternative to expensive and proprietary

type of PBX server. What's nice about Asterisk is that it is open source and it is free!!! When we say open source this

software has been made by collaborating ideas of different developers around the globe. So expect the cool stuff that can be

done with it. The other nice thing about it, is that it is customizable, flexible and cross platform.

Asterisk can be obtained from various sources. You can have it in a installable CD (ISO) or you could have it from other

communities out there who have developed friendly UI where you could tweak the server easily. If I were to ask I would prefer

to have it from source. Why? Cause templated Asterisk though user friendly can't be extended the way you wish it.

So let us have the Asterisk (raw) and install it on Linux (preferably CentOS).

Before you can compile Asterisk you need the following stuffs on Linux.

Linux Requirements

GCC 3.x
ncurses-devel
libtermcap-devel
Kernel Development Headers
Kernel Development Headers (SMP)
GCC C++ 3.x
bison
OpenSSL (optional)
newt-devel (optional)
zlib-devel (optional)
libtool (optional; recommended)
GNU make (version 3.80 or higher)
libnewt

Here is how we can have them

Install command

yum install -y gcc
yum install -y ncurses-devel
yum install -y libtermcap-devel
yum install -y kernel-devel
yum install -y kernel-smp-devel
yum install -y gcc-c++
yum install -y bison
yum install -y openssl-devel
yum install -y newt-devel
yum install -y zlib-devel
yum install -y libtool
yum install -y make
yum install -y libnewt

Once done we can get the sources from asterisk.org using wget.

# wget http://downloads.digium.com/pub/libpri/releases/libpri(version)tar.gz
# wget http://downloads.digium.com/pub/libpri/releases/dahdi-linux(version)tar.gz
# wget http://downloads.digium.com/pub/libpri/releases/dahdi-tools(version)tar.gz
# wget http://downloads.digium.com/pub/libpri/releases/asterisk(version)tar.gz
# wget http://downloads.digium.com/pub/libpri/releases/asterisk-addons(version)tar.gz

then extract each of the packages

# tar xvzf (packagename)

then compile each packages

for libri and dahdi-linux

# make
# make install

for dahdi-tools

# ./configure
# make
# make install
# make config

for asterisk

# ./configure
# make menuselect ;this is optional but when run just save the default settings, in my case I used to issue it to check out the different options available
# make
# make install
# make samples
# make config

for asterisk-addons (this is important if you want to have some applications like DB, WakeUp Call, streaming audio/video)
# ./configure
# make
# make install
# make samples

To start asterisk the first time (for debugging purposes)

/usr/sbin/asterisk -vvvvgc

If you did not receive any errors stop asterisk and then start asterisk the normal way

/sbin/service asterisk start

to enter the asterisk console issue this command

for root

asterisk -r

for non-root

/usr/sbin/asterisk -r

Now you have a running Asterisk IP PBX

Note: If you want to recompile asterisk say you want to upgrade then recompile asterisk-addons after that as well because sometimes a recompiled asterisk will not load the asterisk-addons module.

BTW there are also other addons / extensions available out there that works with Asterisk like the app_conference (an alternative for MeetMe, capable for doing video conferencing), app_mp4 from sip.fontventa (for recording mp4 video)


Hope you find these helpful. Thanks, Cheers and God Bless!!!!