Wednesday, May 21, 2014

WEB Server

Install

[root@www ~]# yum -y install httpd
# remove welcome page
[root@www ~]# rm -f /etc/httpd/conf.d/welcome.conf
# remove default error page
[root@www ~]# rm -f /var/www/error/noindex.html
# create a link for Perl
[root@www ~]# ln -s /usr/bin/perl /usr/local/bin/perl

Configure httpd.


[root@www ~]# vi /etc/httpd/conf/httpd.conf
# line 44: change
ServerTokens Prod
# line 76: change to ON
KeepAlive On
# line 262: Admin's address
ServerAdmin root@server.world
# line 276: change to your server's name
ServerName www.server.world:80
# line 331: change (enable CGI and disable Indexes)
Options FollowSymLinks ExecCGI
# line 338: change
AllowOverride All
# line 402: add file name that it can access only with directory's name
DirectoryIndex index.html index.cgi index.php
# line 536: change
ServerSignature Off
# line 759: make it comment
#AddDefaultCharset UTF-8
# line 796: uncomment and add file-type that apache looks them CGI
AddHandler cgi-script .cgi .pl
[root@www ~]# /etc/rc.d/init.d/httpd start
Starting httpd: [ OK ]
[root@www ~]# chkconfig httpd on
------------------------------------------------------------------------------------------------------------

Configration of SSL
[root@www ~]# yum -y install mod_ssl
[root@www ~]# vi /etc/httpd/conf.d/ssl.conf
# line 77: uncomment
DocumentRoot "/var/www/html"
# line 78: uncomment and specify server name
ServerName www.server.world:443
# line 105: specify certificate
SSLCertificateFile /etc/pki/tls/certs/server.crt
# line 112: specify certification key
SSLCertificateKeyFile /etc/pki/tls/certs/server.key
[root@www ~]# /etc/rc.d/init.d/httpd restart 
Stopping httpd: [ OK ]
Starting httpd: [ OK
------------------------------------------------------------------------------------------------------------
Virtual Hostings

[root@www ~]# vi /etc/httpd/conf/httpd.conf
# line 990: uncomment
NameVirtualHost *:80
# at the last lines: ( for original domain )
<VirtualHost *:80>
   DocumentRoot /var/www/html
   ServerName www.server.world
</VirtualHost>
# at the last lines: ( for virtual domain )
<VirtualHost *:80>
   DocumentRoot /home/cent/public_html
   ServerName www.virtual.host
   ServerAdmin webmaster@virtual.host
   ErrorLog logs/virtual.host-error_log
   CustomLog logs/virtual.host-access_log combined
</VirtualHost>
[root@www ~]# /etc/rc.d/init.d/httpd restart 
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]
------------------------------------------------------------------------------------------------------------


Log Visitors

[root@www ~]# yum -y install graphviz
[root@www ~]# wget http://www.hping.org/visitors/visitors-0.7.tar.gz
[root@www ~]# tar zxvf visitors-0.7.tar.gz
[root@www ~]# cd visitors_0.7
[root@www visitors_0.7]# make
[root@www visitors_0.7]# cp visitors /usr/local/bin/
[root@www visitors_0.7]# cd
[root@www ~]# mkdir /var/www/html/visitors
[root@www ~]# vi /etc/httpd/conf.d/visitors.conf
# create new
<Location /visitors>
   Order Deny,Allow
   Deny from all
   Allow from 10.0.0.0/24# IP address you allow
</Location>
[root@www ~]# /etc/rc.d/init.d/httpd restart
Stopping httpd: [  OK  ]
Starting httpd: [  OK  ]
# generate common reports
[root@www ~]# visitors -A /var/log/httpd/access_log -o html > /var/www/html/visitors/index.html
--
11 lines processed in 1 seconds
0 invalid lines, 0 blacklisted referers
# generate page tour reports
[root@www ~]# visitors -A -m 30 /var/log/httpd/access_log -o html --trails --prefix http://www.server.world > /var/www/html/visitors/trails.html
--
11 lines processed in 1 seconds
0 invalid lines, 0 blacklisted referers
# generate page tour image
[root@www ~]# visitors /var/log/httpd/access_log --prefix http://www.server.world -V > /var/www/html/visitors/graph.dot
--
11 lines processed in 1 seconds
0 invalid lines, 0 blacklisted referers
[root@www ~]# dot -Tpng /var/www/html/visitors/graph.dot > /var/www/html/visitors/graph.png

0 comments: