All posts by Ruturaj Vartak

The httpd.conf file

The httpd.conf file is the main configuration file of Apache. It rests in “apache-install-dir/conf”

Now lets take a look at some important and useful parameters

This is param sets the default server name, it should generally be the FQDN or the Fully Qualified Domain Name of the machine, or the IP, if the machine doesn’t have any FQDN.

This is a setting which encloses any of the settings for the given directory. So you specify the physical directory as the argument. So if you have a directory as /websites/mywebsite/somedir, you would do the following.

<Directory /websites/mywebsite/somedir>
... your settings

The AllowOverride allows the user, to override some of the settings by using their own file. This own file is the magical .htaccess file. By default it is set to None, which means the user can’t override the settings by specifying the .htaccess file in the directory. But you can change the AllowOverride None setting to AllowOverride All

This directive takes several options, I’ll explain some them,
Indexes: This allows a directory listing. U must have come accross something like this
Directory Listing

FollowSymLinks: This allows apache to follow symbolic links, symbolic links are nothing but links in *nix systems, eg. “files” in /etc/ can point to /files/myfiles/files
You can use both these options at once by

Options +Indexes -FollowSymLinks

The above setting will allow directory listing but won’t allow Symbolic links. So “+” to apply and “-” to remove the setting

I talked about the magic file .htaccess, This is the place where you specify the name of the file, By default it is “.htaccess”
The . “period” start is to make it a hidden file in *nix systems

Denying files
To deny files over the web, is the job of the server, in apache, we can do exactly by using the Files directive.

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All

Note the ~ sign, this is used when you are giving a regular expression to match the files., Once the files are selected, they can be denied by using the Deny directive.
The above regex is to deny all the files that start with a “.ht”

Access Logs
To create access logs, we need to specify the format of the log, and the file path.
First we need to set the LogFormat directive
The most common is the “combined” log, which logs ip, user, time error code, referer and user agent

LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined

Note: the log format has been given a name “combined”, feel free to create different formats for your needs and name it accordingly
Then we need to set the filename of the log,

CustomLog /usr/local/apache/logs/access_log common

The second parameter of the CustomLog directive which sets the filename of the log is the log format name, that we defined earlier.

When you want to look at the current status of the server, ie whom is it responding to, what pages is it serving, how many servers are running… and so on..
There is no better way than to set server-status
Check the screen shot of it.


To enable it …

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from

check the configuration, it is allowing only IP 84 to check the stats and others are forbidden. You can set your IP as you wish.
If you want even more info. you can set the Extended status

ExtendedStatus On

Apache beginings

For guys who have reached here, but still don’t know what httpd is,
Apache is a web server, For all the web pages, websites, blogs, image galleries that are hosted on the web, there needs to be server who “serves” these documents (pages, images, files) to the client (the user’s browser)

Apache got its name from … well… its nothing but a “A patchy server”, httpd apache is an open-source project, which was programmed by many programmers over the world. And everytime a bug-fix, a new feature was required, the main code was just “patched”. And hence it got its name Apache.

Apache being a standard web-browser, runs on port 80, this is the standard HTTP port. Before you begin ahead, let me warn you changing the settings of Apache can change the way a website behaves, and to edit its settings you need root access or Administrator access.

To control apache, you basically need to edit 2 important files “httpd.conf” and “.htaccess”

Code for writing the comment to the DB

Now create a new page called ‘addcomment.php’

$conn = mysql_connect('localhost', 'username', 'password');

$comdate = $_POST['comdate'];
$articleid = $_POST['articleid'];
$comsubject = htmlspecialchars(addslashes($_POST['comsubject']));
$comuser = htmlspecialchars(addslashes($_POST['comuser']));
$comtext = htmlspecialchars(addslashes($_POST['comtext']));

//write the query
$sql = "insert into comments(comdate, articleid, comsubject, comuser, comtext)";
$sql .= " values ('" . $comdate . "', " . $articleid . ", '" . $comsubject . "', '" . $comuser . "', '" . $comtext . "');";

if (!@mysql_query($sql)) {
  echo ('We are unable to register your comment, sorry');
} else {
  echo ("Your comment was added successfully<br>");
  echo ("<A HREF="article.php">Back to Articles</A>");


User Interface for adding comments

Now that we have had some article in our dB, it is now time to show the article to the world. Plus we need to show the comment to them

Let us make a page called as ‘article.php’ and the article is fetched by getting the a url as ‘article.php?articleid=1’ This will fetch the article # 1 and is stored in the DB as articleid=1

If the articleid query is not given then the page has to display all the aritcle listing with the article subject as an link to ‘article.php?article=[the articleid]’

//if articleid query is not set, show all the article listing
if (!isset($_GET['articleid'])) {

$conn = mysql_connect('localhost', 'username', 'password');

$sql = "select * from articles;";
$result = mysql_query($sql);

echo('<table boder=0 cellpadding=3 cellspacing=1>');
while ($row = mysql_fetch_assoc($result)) {
  echo('<a href="aricle.php?articleid='.$row['articleid'].'"><b>'.$row['articlesubject'].'</b></a>');

} else {

$conn = mysql_connect('localhost', 'username', 'password');

$sql = "select * from articles where articleid=" . $_GET['articleid'] . ";";

if (!($result = @mysql_query($sql))) {
  echo('Sorry We are not able to process your request');
} else {
  //now display the data
  $row = mysql_fetch_assoc($result);
  echo ("<p><b>" . nl2br(htmlspecialchars($row['articlesubject'])) .
  echo ("<p>".nl2br(htmlspecialchars($row['articletext']))."<p>");

  Add Comment
  <form name='comment' action'addcomment.php' method=post >
  <input type=hidden name='comdate' value="<?php echo(date("Y-m-d H:i:s"))?>">
  <input type=hidden name='articleid' value="<?php echo($_GET['articleid'])?>">
  Subject<input type=text name='comsubject' />
  User<input type=text name='comuser' />
  <textarea name='comtext' rows=15 cols=50></textarea>
  <input type=submit value='Post Comment' />

  //now show all the comments for this article
  $sql = "select * from comments where articleid=" . $_GET['articleid'] . ";";   $result = mysql_query($sql);
  if (mysql_num_rows($result)<1) {
    echo('No comments posted for this article');
} else {
    while ($row = mysql_fetch_assoc($result)) {
      echo( htmlspechialchars(stripslashes($row['comsubject'])) . ' by ' . htmlspechialchars(stripslashes($row['comuser'])) . ' on ' date("d M Y h:i a", strtotime($row['comdate'])) . '<br>');
      echo( nl2br(htmlspechialchars(stripslashes($row['comtext']))) );


This now completes the code for viewing the article, the page also displays a form which as a subject textbox, a username textbox and a textarea for comment text.
When user clicks the ‘Post Comment’ button, the data is ‘post’ fed to the page ‘addcomment.php’


This entry is part 2 of 36 in the series Guitar

An acoustic guitar has 6 strings, hence the “6 string” 🙂
It starts from the E string (this is the string with the lowest pitch, or lowest frequency note), then the A string, followed by the D, G, B strings. And the last one is the e string. This one is the string with the highest pitch. This e sting produces the “E” note of the next octave begining from the base E string.

We’ll denote it as.., This is the plan view (top view) of the guitar, facing the strings.

e +---------------+
B +---------------+
G +---------------+
D +---------------+
A +---------------+
E +---------------+

Now hold the guitar as you generally hold it, the body of it on the lap, and your base of your right hand (considering your are right-handed) on the bridge. Bridge is the point from where the guitar strings start, it is NOT the end where you tune the string with the knobs.

Hold your thumb and index finger as you hold a pen, withing that grip hold the plectrum (pick). The blade of the pick should be at an angle to the strings, and not directly flat to the strings.

Now practice picking the strings, begining from the base E string to the high e string. All the picking should be down strokes. Go in an easy manner, till you get a feel of distances between the strings, etc…

Once you are comfortable with the simple picking start picking alternate strings. i.e. pick E, D, then A, G, then D, B, and G, e. and then back up again. This will help you in getting a hold of picking alternate, different strings.

I’ll explain you a notation that you will follow all over, It is not my notation, probably you must have seen it somewhere.
When I say you play C note, I’ll specify a fret. A fret is marking on which you play a note, to play a note you press your finger just before the nth fret (the fret that is mentioned to produce the note).

e +---------------+
B +---------------+
G +---------------+
D +----0----------+
A +--3------------+
E +---------------+

..means play the 3rd fret on the A string to produce the C note, then the play open D string (i.e do not fret the string anywhere) to play the D note.

Guitar Tutorial

This entry is part 1 of 36 in the series Guitar

This is my guitar class diary, you may consider it to be as your tutorial, guide or whatever, my purpose to publish this one is to keep the contents of my guitar class on the web.
thats it.

I start from my first class where I knew only 1 thing about guitar and that is “6 string” guitar or something… 🙂 quite an information to begin with.

Lets start now…