Apache HTACCESS

November 25th, 2011

.htaccess is a configuration file working in Apache to provide a way to make configuration change per directory.


Username / Password Protection

Apache Configuration File
<Directory "/home/www/www.foo.com/htdocs">
       AllowOverride All
       Options +Includes
</Directory>

.htaccess File

AuthUserFile /home/www/www.foo.com/htpasswd
AuthName "Secret Area"
AuthType Basic
require valid-user

Create htpasswd file

htpasswd -c /home/www/www.foo.com/htpasswd johndoe


Restrict by IP Address

.htaccess File

AuthName “Secret Area”
AuthType Basic
order deny,allow deny from all
allow from 192.168.

Renew Self-Signed SSL Certificated for SBS 2008

October 24th, 2011

By default, the self-signed certificate for Windows SBS 2008 is valid for 2 years. Upon expiration, OWA will prompt an error about the certificate expiratory. Outlook will not be able to connect to Exchange Server. To Renew the Self-signed certificate, here are the steps to fix it.

1. Open Windows SBS Console.
2. Click Network and then Connectivity Tab
3. View Certificate Properties to verify certificate expiration date
4. to fix the certificate issue. Under the Connectivity Tasks -> Click Fix my network

Wildcard DNS Entries for Windows 2000 DNS Server

October 15th, 2011

To add a wildcard DNS entry to Windows 2000 DNS Server, you will need to create this under the CLI

for example, if you would like to add an entry like

*.dev.vicosys.com.hk

Try the following command

dnscmd.exe /RecordAdd vicosys.com.hk *.dev A 1.1.1.1

htaccess using http header information

August 30th, 2011

this is a sample how to restricted web access using X-FORWARDED-FOR information from http header.

SetEnvIf X-FORWARDED-FOR ^1.1.1.1$ allowclient

<limit GET POST PUT>
order deny,allow
deny from all
allow from env=allowclient
</limit>

Setting up Network Bonding

August 4th, 2011

Network Bonding can provide resiliency to your server in case if one of the network connection failed.

Loading Bonding Driver

/etc/modprobe.conf
[ADD the following lines to the end of the file]
alias bond0 bonding
options bond0 mode=1 miimon=100

You can set up your bond interface according to your needs. Changing one parameters (mode=X) you can have the following bonding types:

mode=0 (balance-rr) Round-robin policy
mode=1 (active-backup) Active-backup policy:
mode=2 (balance-xor) XOR policy:
mode=3 (broadcast) Broadcast policy:
mode=4 (802.3ad) IEEE 802.3ad Dynamic link aggregation.
mode=5 (balance-tlb) Adaptive transmit load balancing:
mode=6 (balance-alb) Adaptive load balancing:


/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
BROADCAST=192.168.242.255
IPADDR=192.168.242.50
NETMASK=255.255.255.0
NETWORK=192.168.242.0
USERCTL=no
GATEWAY=192.168.242.1
TYPE=BOND

/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=xx:xx:xx:xx:xx:xx
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
TYPE=Ethernet

/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
HWADDR=xx:xx:xx:xx:xx:xx
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
TYPE=Ethernet

To Find and Remove Files that has updated x days ago

July 28th, 2011

Where X is the number of days

find . -mtime +X -exec ls -l {} \;

to remove these files

find . -mtime +X -exec rm -f {} \;

Splitting a Large Mailbox into multiple files

July 20th, 2011

By using formail – we can split a large mailbox into multiple small one easily.

+skip
Skip the first skip messages while splitting.

-total
Output at most total messages while splitting.

 

The following command will output the first 10 messages into mailbox.1 and the next 10 messages to the mailbox.2, etc etc.

cat mailbox | formail -10 -s > mailbox.1
cat mailbox | formail +10 -10 -s >mailbox.2
cat mailbox | formail +20 -10 -s >mailbox.3

 

Extending a Logical Volume

July 17th, 2011

There are two steps to extend a logical volume.

1. To Extend the logical volume

lvextend -L+1G /dev/VolGroup00/LogVol06

2. To Expand the File System

resize2fs /dev/VolGroup00/LogVol06

To Display how much un-assigned Volume Group

vgdisplay

— Volume group —
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 7
Open LV 7
Max PV 0
Cur PV 1
Act PV 1
VG Size 232.50 GB
PE Size 32.00 MB
Total PE 7440
Alloc PE / Size 3934 / 122.94 GB
Free PE / Size 3506 / 109.56 GB
VG UUID lXSKxs-552n-VZ03-NsYv-c3qV-FZ3W-ONeIGD

NFS Client Failed

July 14th, 2011

If you are trying to mount a nfs volume and failed, check the following service is running.

service portmap start

 

 

Compiling PHP with mysql support on x64 platform

July 12th, 2011

In order to compile PHP on a 64 bit platform, you will need to include the following configure option
–with-libdir=lib64