Sunday, October 18, 2009

Apache: How to configure Directory Indexing in Apache?

Edit the /etc/httpd/conf/httpd.conf file :

Just Look at the line starting:

[Please note: Do add lesser than sign in front of directory]
directory "/var/www/html/pdfs"


Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

/Directory

Restart the Apache.
Try browsing http://localhost/pdfs

Saturday, October 10, 2009

Sudo: How to provide access rights to a user?

The syntax of the file is pretty explanatory,

Quote:

user MACHINE=COMMANDS

So if the username is 'eth1' and you want to provide access to the command /sbin/mount to the user then,

Quote:

eth1 ALL=/sbin/mount

Example:
Quote:
username ALL=NOPASSWD: /sbin/fdisk

Find out the path of command using

which fdisk or etc..

Also, You can also split the specifications up using User_Alias and Cmnd_Alias to make it a little easier to organize.
Here is a contrived example for ya'.


Code:
### User Aliases

## This is a list of users that have the ability to sudo the same commands.
User_Alias USERLST1=user1,user2

## This group has the ability to sudo the same commands.
## 'webadmgp' is a primary or secondary group that some of your users have.
User_Alias WEBGROUP=%webadmgp


### Command Aliases

## Storage
Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount

## Networking
Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool

## Webadmin
Cmnd_Alias WEBADMIN = /etc/rc.d/init.d/httpd


### The Commands Section

## The USERLST1 users (user1 and user2) can sudo all the commands listed in Cmnd_Alias STORAGE.
## They don't need to enter a password.

USERLST1 ALL=NOPASSWD: STORAGE

## The WEBGROUP users (every user that has 'webadmgp' as a primary or secondary group)
## can sudo all of the commands listed in the NETWORKING an WEBADMIN Cmnd_Alias lists.
## They don't need to enter a password either.

WEBGROUP ALL=NOPASSWD: NETWORKING,WEBADMINWhere things go doesn't seem to be important.

When you save the file, 'visudo' will tell you if you have a syntax error or some inconsistancy.

And be careful if you cut and paste into the file. If you cut a single long line that has wrapped on your screen, it'll paste in as multiple lines. When you file, 'visudo' will complain...

Friday, October 9, 2009

LVM: Deleting LVM Partition

I have a LVM Partitioned in such manner:

[root@ideathon ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
13G 3.4G 8.4G 29% /
/dev/cciss/c0d0p1 190M 15M 166M 8% /boot
none 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/VolGroup00-lvfs
2.0G 65M 1.9G 4% /home/fstop
/dev/mapper/VolGroup00-lvfsrecord
7.9G 158M 7.4G 3% /home/fstop/records
/dev/mapper/VolGroup00-lvfslog
2.0G 44M 1.9G 3% /home/fstop/logs
/dev/mapper/VolGroup00-lvfstomcat
1008M 77M 881M 8% /home/fstop/tomcat
/dev/mapper/VolGroup00-lvmydata
58G 84M 56G 1% /home/fstop/mysql/data
/dev/mapper/VolGroup00-lvmylog
20G 74M 19G 1% /home/fstop/mysql/logs
/dev/mapper/VolGroup00-lvfsarchive
6.0G 45M 5.6G 1% /home/fstop/archive

Now What I want is: How to delete LVM partition?

Solution:

Say, I want to remove the following LVM partition:


/dev/mapper/VolGroup00-lvmydata
58G 84M 56G 1% /home/fstop/mysql/data

So I will follow the following commands:

#umount /home/fstop/mysql/data

It may run successfully but if it shows error like:

Cannot umount: device is busy

Then You need to run fuser command to kill the process held by some other processes.

Just running:

#fuser /home/fstop
/home/fstop: 28406c 28425c 28453c 28479c 28526c 28592c 28644c 28740c
#fuser -ku /home/fstop

Using the above switches you can kill the process which is holding the file and free the file/folders.

Try running df command again:


[root@ideathon ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
13G 3.4G 8.4G 29% /
/dev/cciss/c0d0p1 190M 15M 166M 8% /boot
none 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/VolGroup00-lvfs
2.0G 65M 1.9G 4% /home/fstop
/dev/mapper/VolGroup00-lvfsrecord
7.9G 158M 7.4G 3% /home/fstop/records
/dev/mapper/VolGroup00-lvfslog
2.0G 44M 1.9G 3% /home/fstop/logs
/dev/mapper/VolGroup00-lvfstomcat
1008M 77M 881M 8% /home/fstop/tomcat

/dev/mapper/VolGroup00-lvmylog
20G 74M 19G 1% /home/fstop/mysql/logs
/dev/mapper/VolGroup00-lvfsarchive
6.0G 45M 5.6G 1% /home/fstop/archive

(to be contd..)

Wednesday, October 7, 2009

Apache: Port-Based Virtual Hosts

Problem

You want to present different content for HTTP connections on different ports.

Solution

Explicitly list the port number in the declaration:
Listen 8080


DocumentRoot


Listen 9090


DocumentRoot /www/vhosts/port9090

Apache:Splitting Up a LogFile

Problem

Because of a large number of virtual hosts, you want to have a single logfile for all of them and split it up afterward.

Solution

LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost
CustomLog logs/vhost_log vhost

Then, after rotating your logfile:
split-logfile < logs/vhost_log

Saturday, October 3, 2009

Episode 21: Sendmail /etc/mail/virtusertable Setup?

File: /etc/mail/virtusertable


finance@intinfra.com finance

#cd /etc/mail

#makemap hash virtusertable.db < virtusertable #service sendmail restart File: /etc/mail/access



finance: azit,abhi,receiver

#newaliases
#service sendmail restart

Try out sending mail to finance@groupinfra.com
And Found mail to all the three Users:

[receiver@Innova ~]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/receiver": 1 message 1 new
>N 1 sender@intinfra.co Sun Oct 4 03:34 16/650 "hi"
& t
Message 1:
From sender@intinfra.com Sun Oct 4 03:34:25 2009
Date: Sun, 4 Oct 2009 03:34:25 +0530
From: sender@intinfra.com
To: finance@intinfra.com
Subject: hi

hello

&