Subscribe:

Ads 468x60px

Pages

Monday, July 4, 2011

Apache: customise error document

If you do not have custom files for handling error conditions and error codes like 404 ,500 and 401 etc ,the user experience would not be great. No one prefer to see the “404 Not Found” on their browser.The website developer should handle these scenarios.



You can do this by specifying the custom error document in your server web server configuration files.For Apache server you can do this by editing the .htaccess file.

Here given below are few of the common error codes and we can handle these
Client request Errors
400 – Bad request
401 – Authorization Required
403 – Forbidden
404 – Not Found
Server Errors
500 – Internal Server Error
501 – Not Implemented
502 – Bad Gateway
503 – Service Unavailable
504 – Gateway Timeout
505 – HTTP Version Not Supported
Here is the syntax to specify the error document.
1
2
3
4
 
ErrorDocument errornumber /Customfile.html
 OR
ErrorDocument code /directory/Customfile.extension
if you use the second example above you can keep the custom error file in any directory and use the directory name to replace “directory”.
For example
1
2
3
4
5
6
 
ErrorDocument 404 /MissingFile.html
 OR
ErrorDocument 403 /errors/ForbiddenFile.html
ErrorDocument 404 /errors/MissingFile.html
ErrorDocument 500 /errors/ServerError.html
Even though it is not advised you can specify a full URL rather than a virtual URL in the ErrorDocument string like http://abcd.com/errors/notfound.html rather than /errors/notfound.html.
This document is found from this is site: http://www.globinch.com/2010/03/25/how-to-specify-your-own-errordocuments-using-htaccess-file/

Please feel free to comment to make it more useful to everyone.
Read more...

Apache: Preventing Directory Listing

You do not want people to be able to browse through directory listing? Server to prevent directory  contents to be listed. To fix it:
IndexIgnore *

Where as * is a wildcard that matches all files.

if you dont want images? To fix it:
IndexIgnore *.jpg *.png *.gif


And conversely, if your server is setup to prevent directory listing, but you want to list the directories by default, you could simply throw this into an htaccess file the directory you want displayed:
Options +Indexes


Read more...

Saturday, July 2, 2011

Interview Questions - Part I


Harvest company interview question:
-----------------------------------


Mysql server
------------
1.what is the switch, router and hub?
2.who was owned by the ubuntu os?
3.how to share file through nfs?
4.why need of samba? what is the service name used of samba and config file of samba?
5.how to take a backup and restore the mysql server?
6.what is a port no for ftp, mysql and https
7.Do you have any idea on clouding?


Apache:
-------
1.What is virtualhost in apache?
2.what is ip based and namebase website
3.what are types of log files present in the apache and what r there?
4.can i create websites with multiple ports?
5.where u will mention the logs in config file?
6.what is the difference b/w the access and custom logs
7.where thes log files present?
8.what is are the log files present in the apache
9.How many virtualhost can we assign
10.what is 500 error? why it will get?
11.what is 404 error? why it will get?
12.what is rewrite?


LAMP:
-----
1.What is a LAMP suite?
2.I am setting up LAMP successfully.
  a.But when i browsing i am getting blanks page why?
  b.when i browsing the site. i can see the list of directories. when i click them it will be downloaded. but the directories should not be downloaded. then what u will do?(i dont not actually directories or files)
  c.I have index.php page. when the client visit to index page it should show index.html not index.php. wat u will do for this?
  (i said by doing alias we can do this. then interviewer questioned me. if i have multiple pages with .php extention then pages should be visible in html extension.)

Read more...

Tuesday, June 28, 2011

Installing and configuring the Postfix mail server


Postfix provides for easier administration, allows increased security, and supports virtual domains. It is also the default mail program on RHEL6. It is the outgoing mail server.


Step 1. To verify that Postfix is installed or not
# rpm -qa | grep postfix


If the package isn’t installed then install it
# yum install –y postfix


Step 2. To start service during system boot time
# chkconfig postfix on


Step 3. Nedd to Stop the sendmail service because you are going to use Postfix in place of the default Sendmail:
# service sendmail stop


Step 4. Need to off sendmail service during system boot if the service is on:
# chkconfig sendmail --list
# chkconfig sendmail off


Step 6. Change the default mail program to Postfix:
# alternatives --config mta
There are 2 programs which provide ‘mta’.
Selection Command
----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2


Step 7. Verify that the current default for mail is Postfix:
# alternatives --display mta | grep current


Edit the master.cf file:
# vim /etc/postfix/main.cf


Step 2. Change the following options:
myhostname = server1.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 192.168.1.0/24, 127.0.0.0/8


configure DNS server with the correct MX records before you start the Postfix service.


Step 3. Check sytax of config file:
# postfix check




Step 4. Start the Postfix service:
# service postfix start


Step 1.To open TCP port 25 for the SMTP service
# iptables -I INPUT 5 -p tcp -m tcp --dport 25 -j ACCEPT


Step 2. Save the rule:
# service iptables save


Step 3. Restart the iptables service:
# service iptables restart
Read more...

Email Service

The email system is divided into three different parts: 
1. MUA
2. MDA
3. MTA.


Mail User Agent(MAU):
It deals specifically with end users. It is what they use to type and read emails they receive. The MUA is a mail client of some sort, such as Thunderbird or Evolution. 


Mail Delivery Agent (MDA):
It handles the delivery of mail from the receiving mail server to the spool where the mail sits
until an MUA picks it up for the user. 


Mail Transfer Agent (MTA):
It is responsible for moving mail from one server to another until it arrives at its destination.
Read more...

Monday, June 27, 2011

Description of /etc/fstab fields

There are 5 fields present in the /etc/fstab:

1. Label - Lists the device to be mounted.



2. Mount Point - The directory where the filesystem will be mounted.


3. Filesystem Format - Describes the filesystem type. Valid filesystem types include ext,ext2, ext3, ext4, swap, msdos, vfat, proc, tmpfs, is09660, nfs and smb.


4. Dump value - It should be either 0 or 1. A value of 1 means that data is automatically saved to disk by the dump command when you exit linux.data should be backed up (also called dumping) before a system shutdown or reboot occurs. This field commonly uses a value of 1. A value of 0 might be used if the file system is a temporary storage space for files, such as /tmp.


5. Filesytem check order - It determines the order that filesystem are checked by fsck during the boot process. The root directory (/) filesystem should be set to 1, and other local filesystems should be set to 2. Removable filesystems such as /mnt/cdrom should be set to 0, which means that they are not checked during the linux boot process.

Read more...

Friday, June 24, 2011

Backup MySql server database using bash script

Create the bash shell script for taking the My Sql server database backup
#vim mysqlbackup.sh
#!/bin/sh
# backup mysql databases shell script

DATE=$(date +%Y-%m-%d)
MYSQL=$(which mysql)
MYSQLDUMP=$(which mysqldump)
MYSQL_USER="root"
MYSQL_PASS="password"
HOSTNAME=$(hostname)
GZIP=$(which gzip)
ARG="-u $MYSQL_USER -p$MYSQL_PASS"
DATABASES=$($MYSQL $ARG -s -e "SHOW DATABASES;")
BACKUP_PATH="/home/backup/$DATE/mysql"


! [ -d $BACKUP_PATH ] && mkdir -p $BACKUP_PATH

for DB in $DATABASES
do
BACKUP_FILE="$BACKUP_PATH/$HOSTNAME-mysql-$DB-$DATE.sql.gz"
$MYSQLDUMP $ARG $DB | $GZIP -9 > $BACKUP_FILE
done
:wq
Read more...

Installing and configuring the VNC(Virtual Networked Computing) server


VNC, or Virtual Networked Computing, is a way of controlling a remote computer just as though you are sitting in front of it. In the Windows world it is also known as remote desktop but it's normally referred to as VNC in the Linux world.

Local System:
Step1: Check if the package is installed or not
#rpm -qa | grep vnc

Step2 : Install the package if you did not get any output
#yum install tigervnc* -y

Step3 : Add atleast one VNC user
#vim /etc/sysconfig/vncserver
##Add the Following lines at last of the file
VNCSERVERS=”2: student”
VNCSERVERARGS[2]=”-geometry 800*600”

Note: you can add as many as user you like. And geometry sets the size

Save and Exit
:wq


Step4 : Add user student with assign password
#useradd student
#passwd student

Step5 : Login to student user
#su – student

Step6 : Assign the vnc servers password
#vncpasswd

And logout from user
#exit

Step7 : On the service at booting time
#chkconfig vncserver on

Step8 : Now start the apache service
#service vncserver restart

Step9 : check the vncserver port number
#netstat –ntlp | grep 590

Step10 : check the vncserver process running or not
#ps –ef | grep –i vnc

Remote System:
Step11 : Connect from remote machine using the local machine ip and
#vncviewer <remote systems ip>:<desktopnumber>
#vncviewer 192.168.0.254:2

Enter the password of the student user

Read more...