Apache - RewriteRule in htaccess vs httpd.conf

Typically Apache’s RewriteRule sets from mod_rewrite go in .htaccess files, but sometimes you have a good reason to put them in your general server config instead:

your httpd.conf orapache2.conf file (or a file you Include from one of those). If you’ve done this before, you’ve probably been surprised that it didn’t work quite the same. So while this works in .htaccess: RewriteEngine On RewriteCond%{REQUEST_FILENAME} !-f RewriteRule . /index.php [L] Putting the same thing in your VirtualHost doesn’t work at all: <VirtualHost *:80> DocumentRoot /var/www/example/ <Directory /var/www/example/> Allow From All </Directory> RewriteEngine On RewriteCond%{REQUEST_FILENAME} !-f RewriteRule . /index.php [L]

CentOS - LVM quick notes

Please refer to full documentation online - LVM Administrator's Guide

Am not responsible if you break your server by following my notes.

TIP: If not sure, always try on TEST server before running your commands on PRODUCTION.

SCENARIO: There is a Fresh install of CentOS on VM (TEST Server)

[root@localhost ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root  6.7G  1.1G  5.3G  17% /
tmpfs                         250M  4.0K  250M   1% /dev/shm
/dev/sda1                     485M   31M  430M   7% /boot

By default LVM is used.

REQUIREMENT: Add new logical volume to the server (use existing Volume Group called "VolGroup").

1. add new Virtual Hard Disk (at VMWARE or VIRTUALBOX level)
2. fdisk -l ( e.g newly added disk is /dev/sdb)
3. pvcreate /dev/sdb
4. pvs (verify)
5. vgextend VolGroup /dev/sdb
6. vgs (verify)
7. lvcreate -L 450M -n mydata VolGroup  (create new logical volume of 450MB named "mydata")
8. lvs (verify,…

The Zen of Python

    Long time Pythoneer Tim Peters succinctly channels the BDFL's
    guiding principles for Python's design into 20 aphorisms, only 19
    of which have been written down.

The Zen of Python

    Beautiful is better than ugly.    Explicit is better than implicit.    Simple is better than complex.    Complex is better than complicated.    Flat is better than nested.    Sparse is better than dense.    Readability counts.    Special cases aren't special enough to break the rules.    Although practicality beats purity.    Errors should never pass silently.    Unless explicitly silenced.    In the face of ambiguity, refuse the temptation to guess.    There should be one-- and preferably only one --obvious way to do it.    Although that way may not be obvious at first unless you're Dutch.    Now is better than never.    Although never is often better than *right* now.    If the implementation is hard to explain, it's a bad idea.    If the implementation is easy to …

Windows 3.1 is still being used in the most important networks and systems today

I was really surprised when I read this news from zdnet: … "A Paris airport was forced to shut down earlier this month after a computer running Windows 3.1, a prehistoric operating system from 23 years ago, crashed in bad weather." … But old is not necessary bad as the article says: … "A few years ago we did a complete analysis of our entire network. Cyber engineers found out that the system is extremely safe and extremely secure on the way it's developed,"
"Those older systems provide us some, I will say, huge safety, when it comes to some cyber issues that we currently have in the world,"

Read the full report on the below given link.

Practical sed commands

I am posting a summary of my  commands after a bit of Googling and after playing on my CentOS VM with sed.

1. Always backup your files before playing with sed

2.The -i option in sed will replace the original file. So I recommend you run your
sed commands without the -i option first. Once you get the desired results of your sed command you
can then use the -i option.

append after <body>

sed  '/<body>/a Hello World' sample.html
sed -i  '/<body>/a Hello World' sample.html

append contents of file header-js.txt after <body>

sed -i '/<body>/ r header-js.txt' sample.html
sed -i '/<\/body>/ r footer-js.txt' sample.html

Some tests before proceeding further (tip: don't ignore the single quote)

[root@localhost mydir]# find . -name '*.html'

combine find with sed for mass modifications

find . -iname '*.html' -exec sed -i '/<body>/ r header-js.txt…

Bandwidth vs Speed Part 2

In one of my earlier posts I wrote about bandwidth vs speed using the road and car analogy.

This post has been written by Chandan Singh Takuli from CISCO.

Too fast Too furious - who doesn't like speed, especially when we talk about the internet or network connectivity? But the real question is, which is better to have: fast speed or more bandwidth? Although these terms are inter-related, they're not same. As an internet or network user, "fast speed" means a faster rate of data communications. That sounds good, because who doesn't want a fast network connection? But when we start thinking about it as network engineers, things change a little bit as we talk about bandwidth over WAN and speed over LAN. Many network engineering friends of mine ask me, "What’s the difference?" So let’s dive into it.
The data traveling speed over media is a different concept than the speed of network we are talking about here. When we say "high speed network," we are n…

Cisco - Sending Syslog Messages As SNMP Traps and Informs

The following is an extract from the book Cisco IOS Cookbook,2nd edition (available online) Problem You want to send syslog messages as SNMP traps or informs. Solution You can configure the router to forward syslog messages to your network management server as SNMP traps instead of syslog packets with the following configuration commands: Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#logging history informational Router(config)#snmp-server enable traps syslog Router(config)#snmp-server host ORATRAP syslog Router(config)#