How to speed up your website


Varnish is an HTTP accelerator designed for content-heavy dynamic web sites as well as heavily consumed APIs.

Below steps explain how to install and configure Varnish cache server.

Operating System: CentOS 6.4
Hostname: server
IP Address: 192.168.1.6

Step 1: Install the varnish package

[root@server ~]# rpm -ivh http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release/varnish-release-3.0-1.el5.centos.noarch.rpm

[root@server ~]# yum install -y varnish

Step 2: Start apache server

[root@server ~]# /etc/init.d/httpd start
Starting httpd: [ OK ]

[root@server ~]# chkconfig --level 35 httpd on

Step 3: Configuring Varnish

[root@server ~]# vi /etc/varnish/default.vcl

Change the below parameters

From:

backend default {
.host = "127.0.0.1";
.port = "80";

To:

backend default {
.host = "127.0.0.1";
.port = "88";

Save and Exit (:wq!)

[root@server ~]# vi /etc/sysconfig/varnish

#Uncomment the below settings and change the parameter

VARNISH_VCL_CONF=/etc/varnish/default.vcl
VARNISH_LISTEN_ADDRESS=
VARNISH_LISTEN_PORT=80
VARNISH_SECRET_FILE=/etc/varnish/secret
VARNISH_MIN_THREADS=1
VARNISH_MAX_THREADS=1000
VARNISH_THREAD_TIMEOUT=120
VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
VARNISH_STORAGE_SIZE=512M
VARNISH_STORAGE=”malloc,${VARNISH_STORAGE_SIZE}”
VARNISH_TTL=120

Save and Exit (:wq!)

Step 4: Apache Configuration

Change the apache listen port from 80 to 88

[root@server ~]# vi /etc/httpd/conf/httpd.conf

From:

Listen 80

To:

Listen 88

Step 5: Run apache and varnish daemon

[root@server ~]# /etc/init.d/varnish start

[root@server ~]# /etc/init.d/varnish status
varnishd (pid 2587) is running...

[root@server ~]# chkconfig --level 35 varnish on

[root@server ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

[root@server ~]# chkconfig --level 35 httpd on

Step 6: Test your website

[root@server ~]# curl -I http://localhost
HTTP/1.1 200 OK
Server: Apache/2.2.15 (CentOS)
Last-Modified: Sun, 12 Apr 2015 07:15:32 IST
ETag: "3942-2a-51381c35c67f1"
Content-Type: text/html; charset=UTF-8
Content-Length: 42
Accept-Ranges: bytes
Date: Sun, 12 Apr 2015 07:16:55 IST
X-Varnish: 612706973
Age: 0
Via: 1.1 varnish
Connection: keep-alive

[root@server ~]# varnishlog

[root@server ~]# varnishstat

Enjoy… Cheers 🙂

Build your own website using Mediawiki


Mediawiki is a free and open-source tools, used to build a powerful websites such as Wikipedia. It is written in PHP language use MySQL/PostgreSQL/SQLite/Oracle for backend database use.

System Requirements:

CentOS 6.4 Operating System
Apache webserver
PHP version 5.3.2 or later (security reason use PHP 5.3.5+)
Mysql 5.0.2 or later

Step 1: Install Prerequisites applications

[root@server ~]# yum install -y mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-pecl-apc php*intl

Start the essential daemons

[root@server ~]# /etc/init.d/httpd start
[root@server ~]# chkconfig --level 35 httpd on

[root@server ~]# /etc/init.d/mysqld start
[root@server ~]# chkconfig --level 35 mysqld on

Step 2: Create a MySQL database

[root@server ~]# mysql -u -p
Enter password:

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database mediawikidb;

mysql> grant all on mediawikidb.* to 'mediawikiuser'@'localhost' identified by 'welcome';

mysql> flush privileges;

mysql> exit;

Step 3: Download and Install Mediawiki

Use the latest stable release to avoid any security related issues.

[root@server ~]# wget http://releases.wikimedia.org/mediawiki/1.23/mediawiki-1.23.8.tar.gz
[root@server ~]# tar -xzvf mediawiki-1.23.8.tar.gz
[root@server ~]# mv mediawiki-1.23.8/ /var/www/html/mediawiki
[root@server ~]# chown -R apache:apache /var/www/html/mediawiki
[root@server ~]# chmod -R 755 /var/www/html/mediawiki

Now open your web browser, type http://localhost/mediawiki or http://ip-address/mediawiki

Follow the below steps to complete the installation.

- Click "set up the wiki" link
- Select "English" as your language ( you can change as per your need)
- Environment Checks, if everythings looks Ok, Click "Continue"
- MySQL Database settings
== Database host: localhost
== Database name: mediawikidb
== Database table prefix: mediawiki_
== Database username: mediawikiuser
== Database password: welcome

- Select "MySQL storage engine" and Click Continue
- Enter Administrator account details and wikipedia website name, click Continue

After successfull completion of installation, the installer will download a file “LocalSettings.php” which contains all configuration details, so keep it safe.

Copy the “LocalSettings.php” file to /var/www/html/mediawiki directory.

[root@server ~]# cp LocalSettings.php /var/www/html/mediawiki

Open web browser, type http://localhost/mediawiki or http://ip-address/mediawiki, it will automatically direct you to the home page.

That’s it. Now you can able to share your post on the newly created website.