Archive for 'Operating Systems'

Change the SSH port on RedHat/Cent Os

Changing the SSH port of RedHat or Cent Os is not a tough job. Any administrator can change it by just editing sshd_config file and then reloading the service.

Step 1. Edit the sshd_config

vi /etc/ssh/sshd_config

Step 2. Change the Port No
You will find something like

#Port 22

Simply change this like

Port 2222

Step 3. Save and Exit
Step 4. Reload the New Configuration
service sshd reload
You are done and now you can test your new configuration using this command

ssh username@myhostnaname.com -p 2222

Precaution: Before logging out make sure your 2222 or the port you have set is open. Otherwise you will no be able to log in using that port. Check your firewall settings for this.

How to install Red5 on Cent Os 5.4

Red5 is open source flash server written in java supports streaming audio/video, recording client streams, shared objects, live stream publishing etc. Here I will describe in details how you can install Red5 on your CentOS. For this you will also need to install Java and Apache Ant.

Step 1. Install Java

RED5 server depends on Java. CentOS 5.3 comes with OpenJDK 1.6 and install it using yum.

yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

Step 2. Install Ant

Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory.

cd /usr/src
wget http://opensource.become.com/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz
tar zxvf apache-ant-1.7.1-bin.tar.gz
mv apache-ant-1.7.1/ /usr/local/ant

Step 3. Export Variables for Ant and Java

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip

Also export these variables in /etc/bashrc to become available for every user login or for any terminal opens.

echo ‘export ANT_HOME=/usr/local/ant’ >> /etc/bashrc
echo ‘export JAVA_HOME=/usr/lib/jvm/java’ >> /etc/bashrc
echo ‘export PATH=$PATH:/usr/local/ant/bin’ >> /etc/bashrc
echo ‘export CLASSPATH=.:$JAVA_HOME/lib/classes.zip’ >> /etc/bashrc

Step 4. Download and Install RED5 Server

Here the latest version available for RED5 is 0.7 on site but download from google code using svn as the tarball of 0.7 on site is missing some of the files.

cd /usr/src
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
mv red5 /usr/local/
cd /usr/local/red5
ant prepare
ant dist

you will see a ton of lines, but you should get at last

BUILD SUCCESSFUL

that’s mean its install and now copy the conf directory from dist/ and test the red5 installation.

cp -r dist/conf .
./red5.sh

If it shows Installer service created in the last then everything is fine here, press ctrl+c and move to next step to create init script.

Step 5. Init Script

Now we will create init script for red5 to start, stop and restart easily.

vi /etc/init.d/red5

The init script code is below.

#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5

PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid

# Source function library
. /etc/rc.d/init.d/functions

[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5

RETVAL=0

case “$1″ in
start)
echo -n $”Starting $PROG: ”
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG

fi
[ $RETVAL -eq 0 ] && success $”$PROG startup” || failure $”$PROG startup”
echo
;;
stop)
echo -n $”Shutting down $PROG: ”
killproc -p $PIDFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
;;
restart)
$0 stop
$0 start
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|status}”
RETVAL=1
esac

exit $RETVAL

Now start the service

/etc/init.d/red5 start

check status

/etc/init.d/red5 status
red5 (pid XXXXX) is running…

again you can do stop, restart.

Step 6. Test

Now test the RED5 installation by opening following URL in browser

http://yourip:5080/

You will see Red5 test page.

Restoring Default Ubuntu Panel

This is for the newbies in the Ubuntu Community. Sometimes we want to configure our panels on Ubuntu to give a nicer look. And the newbies often fail to do that as they want and may want to restore the default panel settings. Restoring the default panel setting on Ubuntu is pretty simple. Just run the following command in the terminal and you will get your default Ubuntu panels back.

sudo debconf gnome-panel

But this is not a permanent solution. To permanently enable your default panel configuration enter the following commands in the terminal sequentially.

gconftool –recursive-unset /apps/panel
rm -rf ~/.gconf/apps/panel
pkill gnome-panel

Enjoy!!

N.B. Don’t worry if any of the command removes all your panel. The next command will restore it to default configuration.

Installing Apache Tomcat 6 on Ubuntu (8.04 / 8.10)

Before we install Tomcat you’ll need to make sure that whether we already have installed Java. Let’s assume that we are trying to install Tomcat we’ve already installed java, but if we aren’t sure we can check with the dpkg command like so:

dpkg –get-selections | grep sun-java

This should give we this output if we already installed java:

sun-java6-bin                                   install
sun-java6-jdk                                   install
sun-java6-jre                                   install

If that command has no results, we’ll want to install the latest version with this command:

sudo apt-get install sun-java6-jdk

Installation

Now we’ll download and extract Tomcat from the apache site. We should check to make sure there’s not another version and adjust accordingly.

wget http://apache.host.com/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.tar.gz

tar xvzf apache-tomcat-6.0.14.tar.gz

The best thing to do is move the tomcat folder to a permanent location. I chose /usr/local/tomcat.

sudo mv apache-tomcat-6.0.14 /usr/local/tomcat

Tomcat requires setting the JAVA_HOME variable. The best way to do this is to set it in the .bashrc file.

The better method is editing the .bashrc file and adding the bolded line there. We’ll have to logout of the shell for the change to take effect.

vi ~/.bashrc

Add the following line:

export JAVA_HOME=/usr/lib/jvm/java-6-sun

At this point we can start tomcat by just executing the startup.sh script in the tomcat/bin folder.

Automatic Starting

To make tomcat automatically start when we boot up the computer, we can add a script to make it auto-start and shutdown.

sudo vi /etc/init.d/tomcat

Now paste in the following:

# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid

export JAVA_HOME=/usr/lib/jvm/java-6-sun

case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac
exit 0

We’ll need to make the script executable by running the chmod command:

sudo chmod 755 /etc/init.d/tomcat

The last step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should be on our way.

sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat

Tomcat should now be fully installed and operational. Cheers!

Thanks

How to Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu (8.04 / 8.10)

This is for the newbies in the world of Ubuntu. Use the following steps to install LAMP (Linux, Apache, MySQL and PHP) in Ubuntu.

  • Open up the Terminal (Applications > Accessories > Terminal).
  • Run the following command to install Apache

    $sudo apt-get install apache2

  • To test Apache open up any web browser and then enter the following into the web address:

    http://localhost/

  • Now run the following command in the terminal to install PHP

    $sudo apt-get install php5 libapache2-mod-php5

  • In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:

    $sudo /etc/init.d/apache2 restart

  • In order to test PHP, in the terminal copy/paste the following line:

    $sudo gedit /var/www/testphp.php

  • Copy/Paste this line into the phptest file: <?php phpinfo(); ?>
  • Save and close the file.
  • http://localhost/testphp.php
  • Once again open up the amazing Terminal and then copy/paste this line:

    $sudo apt-get install mysql-server

  • This is where things may start to get tricky. Begin by typing the following into Terminal:

    $mysql -u root -p

  • Following that copy/paste this line:

    $mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’);

  • We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:

    $sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

  • After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:

    $sudo gedit /etc/php5/apache2/php.ini

  • Now we are going to have to uncomment the following line by taking out the semicolon (;). ;extension=mysql.so To look like this: extension=mysql.so

Now just restart Apache and you are all set!

$sudo /etc/init.d/apache2 restart

We are ready to start code in PHP using MySQL for database and Apache as HTTP server in Ubuntu!!!

Is Keyboard not working properly in Ubuntu 8.10?

Recently I have updated my Ubuntu machine at office from 8.04 (Hardy) to 8.10 (Intrepid Ibex). Surprisingly my keyboard was not working properly specially the arrow keys, HOME and END keys. Then I searched through google and found a quick solution. That I am sharing here to help others who may face this problem.
Just run the following command in the terminal all keys of your keyboard will work.

$ setxkbmap -model evdev

Thanking everyone and welcomed to share.

NB. This is not a permanant solution. But works for a single login. After restarting it will need to run the command again.

How to install or add PHP GD support in Ubuntu

PHP is mainly a server side language which renders the code at server and throws the output to the client end through Apache or any other HTTP server. So, being a newbie we often suffer from GD support in Ubuntu. This are the following steps to install or add PHP GD support in Ubuntu.

$ apt-get install php5-gd
OR
$ sudo apt-get install php5-gd
$ /etc/init.d/apache2 restart

Now PHP GD support is ready to work.

How to install JDK in Ubuntu

Those who are involved in Java based application development must need to use Java Development Kit (JDK). And those are newbie in the world of Ubuntu may don’t know how to install JDK in Ubuntu. This is quite simple to install JDK in ubuntu. Just run the following command in the terminal and follow the steps.

$sudo apt-get install sun-java5-jdk

After this the rest of the process will display a dialog that will require you to accept the license agreement. When you do, the rest of the setup will happen on its own.

When you’re on the command prompt type

javac -version

or

java -version

Now you should be ready to work with Java.

Installing true type fonts in Ubuntu

Even we are using Ubuntu we may sometimes want to or need to use some Microsoft true type fonts. For that we can follow the following steps to install true type fonts in our Ubuntu.

We can install the MS core fonts by installing the msttcorefonts package.
To do this, enable the “Universe” component of the repositories.
Then run the following command in the terminal:

$sudo apt-get install msttcorefonts

This will give us the core fonts, but if there are other TrueType fonts that we want installed, it is as easy as copying the font files to the ~/.fonts/ directory.

After installing new fonts, we will have to log out and log in again to be able to see and use the new fonts. If we want to avoid this, we can regenerate the fonts cache by issuing the following command:

$sudo fc-cache -fv

How to set a cron job using PHP in webmin

I have a CentOS server to test my all projects. According to clients requirement webmin is installed as admin panel. Today I had tried to use a cron PHP script in that server and succeeded. This is how I have setup the cron job.

In the webmin panel ther is a menu group named ‘Cluster’;
So from that menu group -> Cluster Cron Job.
Then I have added a new cron job.
1. Selected user ‘apache’.
2. in the command box:
/usr/bin/php -q /full/path/to/the/cronjob.php
3. Then selected the time which I want the cron job should be done.

Wow… It’s working. Please feel free to ask if you need any further help regarding this.