Wednesday, February 24, 2010

Url rewrite Enabling in Ubuntu

sudo gedit /etc/apache2/sites-enabled/000-default

Open this file and give allow override All in

Then now to enable the rewrite

sudo a2enmod rewrite

Now restart apache

sudo /etc/init.d/apache2 restart

To disable the rewrite

sudo a2dismod rewrite

Tuesday, February 23, 2010

Load Balancer and Apache Cluster

This post shows how to set up a two-node Apache web server cluster that provides high-availability. In front of the Apache cluster we create a load balancer that splits up incoming requests between the two Apache nodes. Because we do not want the load balancer to become another "Single Point Of Failure", we must provide high-availability for the load balancer, too. Therefore our load balancer will in fact consist out of two load balancer nodes that monitor each other using heartbeat, and if one load balancer fails, the other takes over silently.

The advantage of using a load balancer compared to using round robin DNS is that it takes care of the load on the web server nodes and tries to direct requests to the node with less load, and it also takes care of connections/sessions. Many web applications (e.g. forum software, shopping carts, etc.) make use of sessions, and if you are in a session on Apache node 1, you would lose that session if suddenly node 2 served your requests. In addition to that, if one of the Apache nodes goes down, the load balancer realizes that and directs all incoming requests to the remaining node which would not be possible with round robin DNS.

For this setup, we need four nodes (two Apache nodes and two load balancer nodes) and five IP addresses: one for each node and one virtual IP address that will be shared by the load balancer nodes and used for incoming HTTP requests.

Example setup

* Apache node 1: webserver1.example.com (webserver1) - IP address: 192.168.0.101; Apache document root: /var/www
* Apache node 2: webserver2.example.com (webserver2) - IP address: 192.168.0.102; Apache document root: /var/www
* Load Balancer node 1: loadb1.example.com (loadb1) - IP address: 192.168.0.103
* Load Balancer node 2: loadb2.example.com (loadb2) - IP address: 192.168.0.104
* Virtual IP Address: 192.168.0.105 (used for incoming requests)

Install netbeans in ubuntu

Follow the steps provided here.

http://netbeans.org/community/releases/68/install.html#downloadoptions

download netbeans from the following link. Select the technology which you want to use and then download. if u want all then click the link provided at the end.

http://netbeans.org/downloads/index.html

A sh file is downloaded now. Give full permission for the downloaded file as

sudo chmod 777 netbeans.sh

Then double click the file and run in terminal. This will install netbeans and you can just follow the steps it takes to.

Configuring Airtel Broadband in Ubuntu

We had an opportunity recently to provide support over the phone for one of our customers for installing Ubuntu and configuring Airtel broadband on a desktop PC. The Airtel broadband was connected through a Beetel 220BX ADSL modem but the instructions should work for most broadband connections where the device is a modem router.

The first part in setting up the connection is to set up static IP on the computer. Open System > Administration > Network. In the Network Manager dialog, click on the Wired device, right click and open the Properties dialog of the Wired Network Device. In the device properties dialog, unselect the "Enable Roaming Mode" checkbox, select static IP as the configuration and enter the following values

IP Address: 192.168.1.2
Network Mask: 255.255.255.0
Gateway: 192.168.1.1
Once these settings are entered done press OK and close the dialog.

or you can type sudo gedit /etc/network/interfaces and change the values in the opened file

Go back to the Network Settings dialog and click on the DNS tab. Click on the Add button and add the following IP Addresses as the DNS Servers in the same order as below.
202.56.215.6
202.56.230.6
208.67.222.222
208.67.220.220

or change the calues in resolv.conf file by sudo gedit /etc/resolv.conf

The second part is to configure the modem to connect automatically to the Internet by configuring PPPOE on the modem directly. Open a browser and type 192.168.1.1 in the Address bar. Enter 'admin' and 'password' as the username and password respectively in the password dialog.

The modem administration control panel will open up in the browser. Click the WAN link given on the left menu. Click the edit button. In the page that comes up enter VPI - 1 and VCI 32. Click Next. Select PPPOE as the connection type and LLC/SNAP-BRIDGING as the encapsulation mode. Click Next and continue to the next page. In the next page enter your login details for the Airtel Broadband connection. Your PPP username must be of the form _dsl@airtelbroadband.in and is the one you would have got from Airtel.

Enter the PPPOE service name as 'airtel' and the authentication mode to auto. Continue to the next page and disable IGMP multicast and enable WAN service. Change the service name to 'airtel'. Click next and then click on SAVE to save your settings and then in the WAN Setup page click on save/reboot to reboot the router.

Once the router is rebooted run

sudo /etc/init.d/networking restart

in a terminal. Open a browser and start browsing :).

Monday, February 15, 2010

Htaccess File

There is a huge range of things .htaccess can do including: password protecting folders, redirecting users automatically, custom error pages, changing your file extensions, banning users with certian IP addresses, only allowing users with certain IP addresses, stopping directory listings and using a different file as the index file.


Custom Error Pages


The first use of the .htaccess file which I will cover is custom error pages. These will allow you to have your own, personal error pages (for example when a file is not found) instead of using your host's error pages or having no page. This will make your site seem much more professional in the unlikely event of an error. It will also allow you to create scripts to notify you if there is an error (for example I use a PHP script on Free Webmaster Help to automatically e-mail me when a page is not found).

You can use custom error pages for any error as long as you know its number (like 404 for page not found) by adding the following to your .htaccess file:

ErrorDocument errornumber /file.html

For example if I had the file notfound.html in the root direct
ory of my site and I wanted to use it for a 404 error I would use:

ErrorDocument 404 /notfound.html

If the file is not in the root directory of your site, you just need to put the path to it:

ErrorDocument 500 /errorpages/500.html

These are some of the most common errors:

401 - Authorization Required
400 - Bad request
403 - Forbidden
500 - Internal Server Error
404 - Wrong page

Then, all you need to do is to create a file to display when the error happens and upload it and the .htaccess file.

Stop A Directory Index From Being Shown

Sometimes, for one reason or another, you will have no index file in your directory. This will, of course, mean that if someone types the directory name into their browser, a full listing of all the files in that directory will be shown. This could be a security risk for your site.

To prevent against this (without creating lots of new 'index' files, you can enter a command into your .htaccess file to stop the directory list from being shown:

Options -Indexes

Deny/Allow Certian IP Addresses

In some situations, you may want to only allow people with specific IP addresses to access your site (for example, only allowing people using a particular ISP to get into a certian directory) or you may want to ban certian IP addresses (for example, keeping disruptive memembers out of your message boards). Of course, this will only work if you know the IP addresses you want to ban and, as most people on the internet now have a dynamic IP address, so this is not always the best way to limit usage.

You can block an IP address by using:

deny from 000.000.000.000

where 000.000.000.000 is the IP address. If you only specify 1 or 2 of the groups of numbers, you will block a whole range.

You can allow an IP address by using:

allow from 000.000.000.000

where 000.000.000.000 is the IP address. If you only specify 1 or 2 of the groups of numbers, you will allow a whole range.

If you want to deny everyone from accessing a directory, you can use:

deny from all

but this will still allow scripts to use the files in the directory.

Alternative Index Files

You may not always want to use index.htm or index.html as your index file for a directory, for example if you are using PHP files in your site, you may want index.php to be the index file for a directory. You are not limited to 'index' files though. Using .htaccess you can set foofoo.blah to be your index file if you want to!

Alternate index files are entered in a list. The server will work from left to right, checking to see if each file exists, if none of them exisit it will display a directory listing (unless, of course, you have turned this off).

DirectoryIndex index.php index.php3 messagebrd.pl index.html index.htm

Redirection

One of the most useful functions of the .htaccess file is to redirect requests to different files, either on the same server, or on a completely different web site. It can be extremely useful if you change the name of one of your files but allow users to still find it. Another use (which I find very useful) is to redirect to a longer URL, for example in my newsletters I can use a very short URL for my affiliate links. The following can be done to redirect a specific file:

Redirect /location/from/root/file.ext http://www.othersite.com/new/file/location.xyz

In this above example, a file in the root directory called oldfile.html would be entered as:

/oldfile.html

and a file in the old subdirectory would be entered as:

/old/oldfile.html

You can also redirect whole directoires of your site using the .htaccess file, for example if you had a directory called olddirectory on your site and you had set up the same files on a new site at: http://www.newsite.com/newdirectory/ you could redirect all the files in that directory without having to specify each one:

Redirect /olddirectory http://www.newsite.com/newdirectory

Then, any request to your site below /olddirectory will bee redirected to the new site, with the
extra information in the URL added on, for example if someone typed in:

http://www.youroldsite.com/olddirecotry/oldfiles/images/image.gif

They would be redirected to:

http://www.newsite.com/newdirectory/oldfiles/images/image.gif

This can prove to be extremely powerful if used correctly.

The .htaccess File

Adding password protection to a directory using .htaccess takes two stages. The first part is to add the appropriate lines to your .htaccess file in the directory you would like to protect. Everything below this directory will be password protected:

AuthName "Section Name"
AuthType Basic
AuthUserFile /full/path/to/.htpasswd
Require valid-user

There are a few parts of this which you will need to change for your site. You should replace "Section Name" with the name of the part of the site you are protecting e.g. "Members Area".

The /full/parth/to/.htpasswd should be changed to reflect the full server path to the .htpasswd file (more on this later). If you do not know what the full path to your webspace is, contact your system administrator for details.

The .htpasswd File

Password protecting a directory takes a little more work than any of the other .htaccess functions because you must also create a file to contain the usernames and passwords which are allowed to access the site. These should be placed in a file which (by default) should be called .htpasswd. Like the .htaccess file, this is a file with no name and an 8 letter extension. This can be placed anywhere within you website (as the passwords are encrypted) but it is advisable to store it outside the web root so that it is impossible to access it from the web.

Entering Usernames And Passwords

Once you have created your .htpasswd file (you can do this in a standard text editor) you must enter the usernames and passwords to access the site. They should be entered as follows:

username:password

where the password is the encrypted format of the password. To encrypt the password you will either need to use one of the premade scripts available on the web or write your own. There is a good username/password service at the KxS site which will allow you to enter the user name and password and will output it in the correct format.

For multiple users, just add extra lines to your .htpasswd file in the same format as the first. There are even scripts available for free which will manage the .htpasswd file and will allow automatic adding/removing of users etc.

Accessing The Site

When you try to access a site which has been protected by .htaccess your browser will pop up a standard username/password dialog box. If you don't like this, there are certain scripts available which allow you to embed a username/password box in a website to do the authentication. You can also send the username and password (unencrypted) in the URL as follows:

http://username:password@www.website.com/directory/

.htaccess file

Instead of including a file manually in all the files we can make use of .htaccess file.

create a file .htaccess in the root folder of the project and include the following lines.

php_value auto_prepend_file "/var/www/foldername/config.php"


Open this file and give allow override All in

sudo gedit /etc/apache2/sites-enabled/000-default

Thursday, February 4, 2010

How to install fonts in Ubuntu 8.04?

You can download and install thousands of free windows .ttf true type fonts from the web and install and use them in Ubuntu (or any other distribution) Linux.

Just download the fonts you want from free online web sites and archives, if necessary - unzip them to the desktop or another directory of your choice.

Then using terminal create a directory for your new fonts where the fonts are stored on your system.

The /usr/share/fonts is the location in Ubuntu Linux:

So, please open a Terminal from the menu Applications->Accessories->Terminal and type:

sudo mkdir /usr/share/fonts/myfonts

give your user password when requested, you don't see nothing when you type it, then press enter.

Then still using Terminal to install them:

sudo cp /home/user/Desktop/*.ttf /usr/share/fonts/myfonts/

and refresh your font cache like this:

sudo fc-cache -f

* If you exchange docs with Windows users using OpenOffice please also install some basic Win truetype fonts provided by the msttcorefonts deb package.

First using Synaptic please first enable the universe repository:

Launch Synaptic from menu: System->Administration->Synaptic package manager
From Synaptic menu: Settings->Repositories-> Tab Ubuntu software
enable "Community Maintained open source software (universe)"
Close Synaptic

Then using Terminal simply install package, please type:

sudo apt-get update
sudo apt-get install msttcorefonts

Wednesday, February 3, 2010

Another instance of skype running problem

to see all the skype instances

ps -A | grep skype

Then kill all the instances using the kill it

kill -9 processid
eg : kill -9 12578

Now restart the skype and it will be working for u.

Tuesday, February 2, 2010

Installing skype in Ubuntu Linux

download skype from http://download.skype.com/linux/skype_static-2.1.0.81.tar.bz2

To enable audio in skpe follow the below given instructions

killall pulseaudio

sudo apt-get remove pulseaudio

sudo apt-get install esound

sudo apt-get install pulseaudio