Thursday, 17 October 2013

Difference between rewrite and redirect

The main difference between rewriting and redirecting is,  Redirecting sends a HTTP 301 or 302 to the client, telling the client that it should try to access the page using another URL. This means that the client knows that there is another URL that should be used. The communication between the server and client is like:

Request 1 (from client):     Get index.php
Response 1 (from server).  The file is moved, please request the file temp_index.php
Request 2 (from client):     Get temp_index.php
Response 2 (from server):  Here is the content of temp_index.php

Rewriting happens on the server, and simply is a translation of one URL to another, that is used by your web application. The client does not know that internally there is another URL, it just sees the one it sent to the server.

Request 1 (from client):       Get  index.php
URL Rewriting (on server):   Translate the URL  index.php  to temp_index.php
Web application (on server): Process the request (run any code in temp_index.php)
Response 1 (from server):    Here is the content of index.php (note that the client does not know that this is the content of temp_index.php)

Monday, 7 October 2013

MediaWiki Installation

MediaWiki is a free, open source wiki software developed by Wikimedia Fountation.

Prerequisites

Install Apache, MySQL, PHP and necesary PHP modules.

create database called mediawikidb and user called mediawikiadmin with password centos.

mysql> create database mediawikidb;
Query OK, 1 row affected (0.03 sec)

mysql> GRANT ALL PRIVILEGES ON mediawikidb.* TO 'mediawikiadmin' IDENTIFIED BY 'centos';
Query OK, 0 rows affected (0.05 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

Download the latest version from

[root@station254 src]# wget http://download.wikimedia.org/mediawiki/1.21/mediawiki-1.21.1.tar.gz
[root@station254 src]# tar zxvf mediawiki-1.21.1.tar.gz
[root@station254 src]# mv mediawiki-1.21.1 /var/www/html/mediawiki

Begin Installation

Navigate to http://ip-address or domain/mediawiki/ from your browser and follow the onscreen instructions.


Click On setup the wiki first link. Select your language and click Continue


Now the installer will perform the environment checks. If everything seems Ok, Click Continue.



Enter MySQL Settings such as Database name, user and password etc. 



Select MySQL storage engine and click Continue.


Enter your Wikipedia website name and create a  new administrative account with username, password and mail id.



Click Continue.



Now the Wikipedia website has been installed successfully. The installer will download a file called LocalSettings.php which contains all your configuration details. It is recommended to download and keep it safe, you will need it. 


Copy the downloaded LocalSettings.php file to the mediawiki directory. And set write permissions of the LocalSettings.php and WebStart.php files. 

[root@station254 mediawiki]# chmod 755 LocalSettings.php

[root@station254 mediawiki]# chmod 755 includes/WebStart.php


Now click on enter to wiki link or navigate to http://ip-address or domain/mediawiki/ from your browser. Now you will be redirected to your wikipedia home page. 



Thats it. Start uploading contents and spread the word of your new wiki website.


Thursday, 3 October 2013

How to install wkhtmltopdf on a linux based web server

64bits OS
---------

wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf


32bits OS
---------

wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2
mv wkhtmltopdf-i386 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf



conversion: /usr/local/bin/wkhtmltopdf www.google.com google.pdf