Tuesday 28 January 2014

BIND DNS in CentOS 6.4

BIND is open source software that implements the Domain Name System (DNS) protocols for the Internet.
It is a reference implementation of those protocols, but it is also production-grade software,
suitable for use in high-volume and high-reliability applications.

BIND is by far the most widely used DNS software on the Internet,
providing a robust and stable platform on top of which organizations
can build distributed computing systems with the knowledge that those
systems are fully compliant with published DNS standards.


BIND is an implementation of the Domain Name System (DNS) protocols.
The name BIND stands for “Berkeley Internet Name Domain”,
because the software originated in the early 1980s at the University of California at Berkeley.
In recent years, the word BIND has become, like “radar” and “laser”, more word than acronym.

The DNS protocols are part of the core Internet standards.
They specify the process by which one computer can find another computer on the basis of its name.
‘An implementation of DNS protocols’ means our software distribution contains all of the software
necessary for asking and answering name service questions.







Install Compile BIND DNS Server in CentOS 6.4 with Source

Note : I compiled bind with source file & in /opt .
 


-------------------------------------------------------------------------
1. Install Dependencies
-------------------------------------------------------------------------
# yum install gcc
# yum install openssl
# yum install openssl-devel

----------------------------------------------------------------------------------------------------------------------
2. Download and Install BIND
----------------------------------------------------------------------------------------------------------------------
#mkdir /softwares

#cd /softwares

#wget https://www.isc.org/downloads/file/bind-9-9-4-p1-tar-gz/?version=tar.gz

# tar -zxvf bind-9.9.4.tar.gz
# cd bind-9.9.4
# ./configure  --prefix=/opt/dns
# make
# make install
# rm -rf /softwares/bind-9.9.4


----------------------------------------------------------------------------------------------------------------------
3. Configure BIND main configuration file i.e named.conf
----------------------------------------------------------------------------------------------------------------------

# cd /opt/dns
# vi etc/named.conf

options{
        directory "/opt/dns/var/named";
        };

zone "yourdomain.com" in {
                        type master;
                        file "db.yourdomain.com";
                };

zone "your-another-domain.com" in {
                        type master;
                        file "db.your-another-domain.com";
                };
 




----------------------------------------------------------------------------------------------------------------------
4. Configure BIND Zone configuration files 
----------------------------------------------------------------------------------------------------------------------
# mkdir -p /opt/dns/var/named

Note: ::    Now  create zone configuration  file  as mentioned   in named.conf.
        Here we create for 2 domain, you have to create as per your requirement.

db.yourdomain.com
db.your-another-domain.com
 


# vi /opt/dns/var/named/db.yourdomain.com

$TTL 3H
yourdomain.com.    IN      SOA     yourdomain.com.    root.yourdomain.com.       (
                                1       ;serial
                                3h      ;refresh after 3 hours
                                1h      ;retry
                                1w      ;expire
                                1h)     ;-ve ttl

;nameserver
yourdomain.com.            IN      NS      ns.yourdomain.com.
yourdomain.com.            IN      A       192.168.1.100
;address record
ns                      IN      A       192.168.1.110
symantec                IN      A       192.168.1.101
mtest                   IN      A       192.168.1.124



----------------------------------------------------------------------------------------------------------------------
5. Open 53 dns udp port in iptables
----------------------------------------------------------------------------------------------------------------------
# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT

# /etc/init.d/iptables restart
# /etc/init.d/iptables save




----------------------------------------------------------------------------------------------------------------------
6. Start named service
----------------------------------------------------------------------------------------------------------------------

# /opt/dns/sbin/named

---------------------------------------------------------------------------------------------------------------------- 
7. Check  named service is Started or Not
----------------------------------------------------------------------------------------------------------------------


ps -aef |grep bind



---------------------------------------------------------------------------------------------------------------------- 
8. Add  DNS entry in resolve.conf file
----------------------------------------------------------------------------------------------------------------------

Note: 192.168.1.2 is your DNS server IP

# vi /etc/resolv.conf
nameserver 192.168.1.2

---------------------------------------------------------------------------------------------------------------------- 
9. Verify DNS is working and resolving domains properly
----------------------------------------------------------------------------------------------------------------------

# nslookup mail.yourdomain.com
# nslookup google.com


---------------------------------------------------------------------------------------------------------------------- 
10. Re-Start named service (When you change any record you need to restart) ----------------------------------------------------------------------------------------------------------------------

# /opt/dns/sbin/named


---------------------------------------------------------------------------------------------------------------------- 
11. Check  named service is Started or Not
----------------------------------------------------------------------------------------------------------------------
ps -aef |grep bind




--------------------------------------------------   FINISH    ---------------------------------------------------

Apache Web server in CentOS 6.4

Apache is an open source freely available HTTP web server that runs on most UNIX-based operating systems as well as on Windows.
Apache web server is used to serve web pages like (.htm .php .pl .cgi .js) etc.
As per March 2012, Apache web server runs on almost 65.24% websites across all the domains.

As we all are aware that Apache is a very powerful, highly flexible and configurable Web server for Nix OS.
Here in this tutorial, we are going to discuss one more feature of Apache which allows us to host more than one website on a single Linux machine.
Implementing virtual hosting with Apache web server can help you to save costs you are investing on your server maintenance and their administration.



Types of Virtual Host


There are two types of virtual hosting is available with Apache.
 
Name Based Virtual Hosting 
With the name based virtual hosting you can host several domains/websites on a single machine with a single IP.
All domains on that server will be sharing a single IP. It’s easier to configure than IP based virtual hosting,
you only need to configure DNS of the domain to map it with its correct IP address and then configure Apache to
recognize it with the domain names.



IP Based Virtual Hosting 
With the IP based virtual hosting, you can assign a separate IP for each domain on a single server,
these IP’s can be attached to the server with single NIC cards and as well as multiple NICs.



  • Document root Directory: /var/www/html or /var/www
  • Main Configuration file: /etc/httpd/conf/httpd.conf
  • Default HTTP Port: 80 TCP
  • Default HTTPS Port: 443 TCP 
  • Test your Configuration file settings and syntax: httpd -t
  • Access Log files of Web Server: /var/log/httpd/access_log
  • Error Log files of Web Server: /var/log/httpd/error_log




 Install Compile Apache(Apache 2.2.25) in CentOS 6.4 with Source

----------------------------------------------------------------------------------------
1) Stop unwanted Services or settings
----------------------------------------------------------------------------------------
# /etc/init.d/NetworkManager stop
# chkconfig NetworkManager off
Note: Make sure you have configured Network i.e. (IP Address/Netmask/Gateway/DNS)

# vi /etc/sysconfig/selinux
SELINUX=disabled

----------------------------------------------------------------------------------------
2) Open Necessary Ports in iptables
----------------------------------------------------------------------------------------
# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT



Restart Iptables to Save the Rule
#/etc/init.d/iptables restart
#chkconfig iptables on

----------------------------------------------------------------------------------------------------
3) Install Dependencies for Apache
----------------------------------------------------------------------------------------------------

yum install make gcc automake zlib-devel bison cmake libtool wget gcc-c++ unzip ncurses-devel openssl-devel pcre-devel libxml2-devel curl-devel gd-devel libxslt-devel


----------------------------------------------------------------------------------------------------
4) Compile APR & APR Utils
----------------------------------------------------------------------------------------------------
#APR #wget http://mirrors.axint.net/apache//apr/apr-1.4.6.tar.gz

#tar -xvzf apr-1.4.6.tar.gz
#cd apr-1.4.6/
#./configure
#make
#make install
#cd ..


Note : if you get error= 

rm: cannot remove `libtoolT': No such file or directory issue. then follow the steps.


Edit your configure file

vi /softwares/apr-1.4.6/configure
Change the line

    $RM "$cfgfile"
      to
    $RM -f "$cfgfile"




# APR Utils#wget http://mirrors.axint.net/apache//apr/apr-util-1.4.1.tar.gz

#tar -xvzf apr-util-1.4.1.tar.gz
#cd apr-util-1.4.1
#./configure --with-apr=/usr/local/apr
#make
#make install



----------------------------------------------------------------------------------------
5) Install and Configure Apache
----------------------------------------------------------------------------------------
Stop Existing Apache#/etc/init.d/httpd stop
#chkconfig httpd off

Make One Directory#mkdir /softwares/
#cd /softwares/
Download Apache #wget http://archive.apache.org/dist/httpd/httpd-2.2.25.tar.gz

Extract Tar File
#tar -zxvf httpd-2.2.25.tar.gz
#cd httpd-2.2.25

Compile Apache (User Your Option I compile in /opt)

#./configure  --prefix=/opt/apache --with-apr=/usr/local/apr/
#make
#make install
#rm -rf /softwares/httpd-2.2.25

Edit Apache Conf File & Add Following Container into this file.
#vi /opt/apache/conf/httpd.conf

Listen 80
User apache
Group apache

Restart Apache
#/opt/apache/bin/apachectl -k restart


Check YOur Web Server (Apache) is Started or Not
#ps -aef |grep apache

OutPut :-


apache    6226  6006  0 17:08 ?        00:00:00 /opt/apache/bin/httpd -k restart
apache    6229  6006  0 17:08 ?        00:00:00 /opt/apache/bin/httpd -k restart
apache    6230  6006  0 17:08 ?        00:00:00 /opt/apache/bin/httpd -k restart
apache    6235  6006  0 17:08 ?        00:00:00 /opt/apache/bin/httpd -k restart
apache    6251  6006  0 17:08 ?        00:00:00 /opt/apache/bin/httpd -k restart











Ref:http://www.tecmint.com

Mod_Pagespeed in CentOS 6.4


PageSpeed Module


 

PageSpeed speeds up your site and reduces page load time.
This open-source web server module automatically applies web performance best practices to pages and associated
assets (CSS, JavaScript, images) without requiring that you modify your existing content or workflow.



The goal of mod_pagespeed is to speed up your website. It does this by applying filters to a variety of files in order to reduce the number of trips the browser has to make to grab what it needs, to reduce the size of those files and to optimize the length those files are cached.


Features

    Automatic website and asset optimization
    Latest web optimization techniques
    40+ configurable optimization filters
    Free, open-source, and frequently updated
    Deployed by individual sites, hosting providers, CDNs

PageSpeed improves web page latency and bandwidth usage by changing the resources on that web page to implement web performance best practices.
Each optimization is implemented as a custom filter in PageSpeed, which are executed when the HTTP server serves the website assets.
Some filters simply alter the HTML content, and other filters change references to CSS, JavaScript, or images to point to more optimized versions.



Install & Compile mod_pagespeed with Apache in CentOS 6.4


----------------------------------------------------------------------------------------
1) Stop unwanted Services or settings
----------------------------------------------------------------------------------------
# /etc/init.d/NetworkManager stop
# chkconfig NetworkManager off
Note: Make sure you have configured Network i.e. (IP Address/Netmask/Gateway/DNS)

# vi /etc/sysconfig/selinux
SELINUX=disabled

----------------------------------------------------------------------------------------
2) Open Necessary Ports in iptables

----------------------------------------------------------------------------------------
# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
#/etc/init.d/iptables restart
#chkconfig iptables on

----------------------------------------------------------------------------------------------------
3) Install Dependencies for Apache (install as per your requirement.)
----------------------------------------------------------------------------------------------------

yum install make gcc automake zlib-devel bison cmake libtool wget gcc-c++ unzip ncurses-devel mod_ssl openssl openssl-devel php* pcre-devel libxml2-devel curl-devel gd-devel libxslt-devel  zlib* libtool* gcc*


----------------------------------------------------------------------------------------------------
4) Compile APR & APR Utils
----------------------------------------------------------------------------------------------------
#APR
#wget http://mirrors.axint.net/apache//apr/apr-1.4.6.tar.gz

#tar -xvzf apr-1.4.6.tar.gz
#cd apr-1.4.6/
#./configure
#make
#make install
#cd ..


Note : if you get error= 

rm: cannot remove `libtoolT': No such file or directory issue. then follow the steps.
Edit your configure file

vi /softwares/apr-1.4.6/configure
Change the line

    $RM "$cfgfile"
      to
    $RM -f "$cfgfile"




# APR Utils
#wget http://mirrors.axint.net/apache//apr/apr-util-1.4.1.tar.gz

#tar -xvzf apr-util-1.4.1.tar.gz
#cd apr-util-1.4.1
#./configure --with-apr=/usr/local/apr
#make
#make install



----------------------------------------------------------------------------------------
5) Install and Configure Apache
----------------------------------------------------------------------------------------

#/etc/init.d/httpd stop
#chkconfig httpd off
#cd /softwares/
#wget http://archive.apache.org/dist/httpd/httpd-2.2.25.tar.gz
#tar -zxvf httpd-2.2.25.tar.gz
#cd httpd-2.2.25
#./configure  --prefix=/opt/apache --with-apr=/usr/local/apr/ --enable-deflate
#make
#make install
#rm -rf /softwares/httpd-2.2.25
#vi /opt/apache/conf/httpd.conf

Listen 80
User apache
Group apache



#cp /etc/httpd/modules/libphp5* /opt/apache/modules/
#cp /etc/httpd/conf.d/php.conf /opt/apache/conf/


#/opt/apache/bin/apachectl -k restart


----------------------------------------------------------------------------------------------------
6)        ############ Mod Pagespeed Installation ############
----------------------------------------------------------------------------------------------------


#mkdir /opt/mod_pagespeed

if you do not already have installed
#yum install at

Download the mod_pagespeed RPM to build.
#wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm

#rpm2cpio mod-pagespeed-stable_current_x86_64.rpm | cpio -idmv
#cp usr/lib64/httpd/modules/mod_pagespeed.so /opt/apache/modules/
#chmod 755 /opt/apache/modules/mod_pagespeed.so

#mkdir -p /var/mod_pagespeed/{cache,files}
#chown nobody.nobody /var/mod_pagespeed/*


#Mod_Pagespeed has a dependency that you want to enable: mod_deflate
#Enable mod_deflate module with following command

#/opt/apache/bin/apxs -c -i /softwares/httpd-2.2.25/modules/filters/mod_deflate.c



Open pagespeed configuration file & Paste Following container in configuration file

#vi /opt/apache/conf/pagespeed.conf


############## mod_pagespeed Config ##############
LoadModule pagespeed_module /opt/apache/modules/mod_pagespeed.so

<IfModule pagespeed_module>
    ModPagespeed on
ModPagespeedFetchWithGzip on
SetOutputFilter DEFLATE

    AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html

ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"
ModPagespeedGeneratedFilePrefix      "/var/mod_pagespeed/files/"

ModPagespeedRewriteLevel PassThrough

ModPagespeedFileCacheSizeKb          102400
ModPagespeedFileCacheCleanIntervalMs 3600000
ModPagespeedLRUCacheKbPerProcess     1024
ModPagespeedLRUCacheByteLimit        16384
ModPagespeedCssInlineMaxBytes        2048
ModPagespeedImageInlineMaxBytes      2048
ModPagespeedCssImageInlineMaxBytes   2048
ModPagespeedJsInlineMaxBytes         2048
ModPagespeedCssOutlineMinBytes       3000
ModPagespeedJsOutlineMinBytes        3000

ModPagespeedEnableFilters extend_cache,combine_css,move_css_to_head,rewrite_javascript,rewrite_images,add_head,rewrite_css,collapse_whitespace,remove_comments,remove_quotes,sprite_images,convert_meta_tags
ModPagespeedRespectVary on

    <Location /mod_pagespeed_beacon>
          SetHandler mod_pagespeed_beacon
    </Location>

    <Location /mod_pagespeed_statistics>
        Order allow,deny
        Allow from localhost
        Allow from 127.0.0.1
        SetHandler mod_pagespeed_statistics
    </Location>


############## mod_pagespeed Config ##############



Make a copy of your apache configuration httpd.conf file.
#cp /opt/apache/conf/httpd.conf /opt/apache/conf/httpd.conf-BACKUP


Edit and include the pagespeed configuration.
#vi /opt/apache/conf/httpd.conf

Include /opt/apache/conf/pagespeed.conf




Save and restart apache service.

#/opt/apache/bin/apachectl -k restart

Thats finished Test your page speed modules on website headers.

curl -I http://localhost    OR    http://127.0.0.1

Output :

HTTP/1.1 200 OK
Date: Tue, 28 Jan 2014 09:39:30 GMT
Server: Apache/2.2.25 (Unix) PHP/5.3.3
Accept-Ranges: bytes
X-Mod-Pagespeed: 1.6.29.7-3566
Vary: Accept-Encoding
Cache-Control: max-age=0, no-cache
Content-Length: 44
Content-Type: text/html






Check syntax
#httpd -M | grep page








Note :Enable Filters as per Your requirement (ModPagespeedEnableFilters in vi /opt/apache/conf/pagespeed.conf)



Ref:https://developers.google.com/speed/pagespeed/module
----------------------------------------------------------------------------------------------------
                                              Enjoy  mod_pagespeed
----------------------------------------------------------------------------------------------------