Archive for the ‘Apache’ Category

Starting LAMPP automatically on startup

Thursday, April 3rd, 2008

For starting LAMPP automatically on startup, add the following line to you /etc/rc.local file

/opt/lampp/lampp start

where /opt/lampp is the location where XAMPP files are kept. You will have to substitute the path to your XAMPP in the above command.

Do let me know whether it worked for you ;)

XAMPP an easy LAMP installation solution

Monday, February 25th, 2008

Earlier I had messed up my LAMP test server trying to upgrade PHP from 4 to 5 and it was a real headache till I got everything to work..

Someone asked me a question – is there a simple way to install everything (Apache, MySQL PHP with necessary modules) in one shot without configuring each and everything manually.. I had no clue that time but I understood that there is a solution for this..

Just browsed http://www.apachefriends.org/en/xampp.html and found proof that there is a solution available.

Have you tried this? I have to mess up my server again if I have to test this ;) So let me see when time permits :) :)

[Update] There wasn’t mysql enabled on PHP5 when I installed RHEL5 afresh. So I had to remove the rpms of PHP, stop httpd,vsftpd and mysqld forever. Installed XAMPP and everything is working perfectly now..

There is a bit of security issues in XAMPP (Not so big if you take care). So read their documents properly.

Apache’s Mod_Rewrite magics

Wednesday, October 24th, 2007

First lets see what is mod_rewrite

mod_rewrite is basically an apache module, using which we can play around with the URL’s

 Configuration

You need to cross check in your httpd.conf whether the following lines are present

LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

If its not there, make sure to add it along with the other modules of apache which is mentioned in httpd.conf

again check for the directives mentioned for the directory block where your scripts reside.

thats something withing <Directory ..></Directory> tags

Inside which make sure you have the following line for AllowOverrides

AllowOverride All

See Apache’s documentation for further info on the above configurations.

Put into action

create a file with name .htaccess in your website/folder where you would like to make fancy url’s. say we have kept in a folder /fancy

Now edit the .htaccess file and type in following.

#### URL Rewriting example by Ramkumar – 08032007 #####

Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /fancy
RewriteRule ^(.*)/(.*)/(.*)\.html$ index.php?c=$1&s=$2&p=$3 [L]
RewriteRule ^(.*)/(.*)\.html$ index.php?c=$1&p=$2 [L]
RewriteRule ^(.*)\.html$ index.php?p=$1 [L]

In the above code, see the line RewriteBase /fancy , which is very important, this says from where the rewrite rules need to be applied (the folder)

Now create a php page with following contents.

 <?php
$page=$_GET['p'];

if(isset($_GET['c']))
echo “<h2>You are on category: <font color=’#FF0000′>”.str_replace(“-”,” “,$_GET['c']).”</font></h2>”;
if(isset($_GET['s']))
echo “<h3>You are on subcategory: <font color=’#FF0000′>”.str_replace(“-”,” “,$_GET['s']).”</font></h3>”;

echo “<h4>You are viewing page: <font color=’#FF0000′>”.str_replace(“-”,” “,$_GET['p']).”</font></h4>”;
?>

Open the page in browser under your webserver and try following URL combinations

/fancy/first/second/third.html

/fancy/first/second.html

/fancy/first.html

You are sure that the files corresponding to above URL’s  doesn’t exist in server, but you will still see a valid page (provided the mod_rewrite is working fine). If it works, thats the example of URL manipulation using mod_rewrite !!