You are on page 1of 15

Web Server Setup using Apache

on CentOS 5.8

Prof Jeong Chul


tland12.wordpress.com

ITC and RUPP in Cambodia

Web Server Setup using Apache


on CentOS 5.8
Part 1

Step 1
Step 2
Step 3
Step 4

Package installation and Startup


Apache files basic configuration
Users page
Virtual hosting

Part 2

Step 5 Access Control


Step 6 CGI
Step 7 .htaccess file Directory authentication
Part 3
Step 8 Web server log monitoring - Webalizer
Step 9 Web server log monitoring - Awstats

Part 4

Step 10 Proxy Server - Squid

Step 1 Package installation & service startup


1. Package installation
httpd-2.2.3-76.el5.centos
httpd-devel-2.2.3-76.el5.centos
httpd-manual-2.2.3-76.el5.centos
system-config-httpd-1.3.3.3-1.el5
2. Service startup
# service httpd start
3. Service startup checking
# ps ef | grep httpd
# netstat nat | grep 80
4. Runlevel registration
# chkconfig httpd on
# chkconfig list httpd
5. Testing on Brower
http://localhost/index.html & index.php

Step 2 Apache Files


1. Apache files
Main files - /etc/httpd/conf/httpd.conf
log files
- /var/log/httpd/access_log error_log
document root - /var/www/
apache modules - /usr/lib/httpd/modules
scripts
- /etc/init.d/httpd -> service httpd start
system file - /etc/sysconfig/httpd
2. Basic Configuration
SeverTokens OS -> Prod
MaxClients 500
ServerAdmin root@chul.com
ServerName www.chul.com:80
ServerSignature off

Step 3 Users page


1. Configuration file
<IfModule mod_userdir.c>
#UserDir disable
UserDir www
</IfModule>

2. Making directory
/home/linux/www
$ chmod 755 www
$ cat > www/index.html
# service httpd restart

3. User home page without ~


Alias /linux/ /home/linux/www

4. Testing
http://www.chul.com/~linux

Step 4 Virtual Hosting


1. Types of Virtual Hosting

Name-based Virtual host Many domains using one IP


IP-based Virtual host
- One IP Address per each domain
Port-based Virtual host - Each port per each domain

2. Name server Configuration using nslookup

Main domain - www.chul.com


Adding new domain www.google.com

3. Configuration file for Virtual hosting


NameVirtualHost 192.168.80.25:80
<VirtualHost 192.168.80.25:80>
ServerAdmin admin@google.com
DocumentRoot /home/google/www
ServerName www.google.com
ErrorLog /home/google/logs/error_log
CustomLog /home/google/logs/access_log common
</VirtualHost>

4. Directory making

Step 5 Access Control


1. Order
order allow,deny //first allow, the rest deny
order deny,allow //first deny, the rest allow
2. Apache access control
<Directory /var/www/html>
Order allow,deny
Allow from .example.com
Deny from station2.example.com

</Directory>
3. Testing

Step 6 CGI
1.CGI (Common Gateway Interface)
Support dynamic contents for web server
/etc/httpd/conf/httpd.conf
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
2. Apache Modules for CGI

mod_perl : Giving super-fast dynamic content for perl scripts


mod_php : PHP code accelerators
mod_speling : Attempts to correct mistaken URLs

Step 7 .htaccess file

1.htaccess Directory authentication

need ID and Password for specific directory access

2. Configuration file - /etc/httpd/conf/httpd.conf


AllowOverride AuthConfig
3. Making .htaccess in /home/linux/www/
AuthName Directory Auth for Linux
AuthType Basic
AuthUserFile /home/linux/.htpasswd
require user linux
# chmod 644 .htaccess

4. $ htpasswd cm .htpasswd linux


$ chmod 644 .htpasswd
5. Testing
http://www.chul.com/~linux

Step 8 Web Server Log Monitoring


Webalizer - web server log monitoring program
1. Installation
webalizer-2.01_10-30.1

2. Configuration
/etc/webalizer.conf
# webalizer c /etc/webalizer.conf

3. Access control
/etc/httpd/conf.d/webalizer.conf

4. Testing
http://localhost/usage or www.chul.com/usage

Step 9 Web Server Log Monitoring


Awstats more specific than webalizer
1.Installation

awstats-7.0-2.el5.rf
perl-Geo-IP
GeoIP-data

2 Configuration in /etc/awstats/
# mv awstats.localhost.localdomain.conf awstats.www.chul.com.conf
# vi awstats.www.chul.com.conf

LogFile=/var/log/httpd/access_log
SiteDomain= chul.com
HostAliases= www.chul.com
DirData=/var/www/html/awstats
LoadPlugin=geoip GEOIP_STANDARD /var/lib/GeoIP/GeoIP.dat

Step 9 Web Server Log Monitoring


2. Configuraion - continued
# mv /var/www/awstats /var/www/html/awstats
# chown R apache.apahce /var/www/html/awstats
# vi /etc/httpd/conf.d/awstats.conf
Options FollowSymLinks
/var/www/html/awstats/
# service httpd restart
# cd /var/www/html/awstats
# perl awstats.pl config=www.chul.com update

3. Testing on Firefox
http://www.chul.com/awstats/awstats.pl

Step 10 Proxy Server - Squid


1.Squid Web Proxy Cache
2.Squid has three purposes:
Speeding delivery of content
Tracking what sites people are visiting
Limiting the sites people are visiting
3.Squid supports caching of FTP, HTTP, and other data
streams
4.Squid includes advanced features including access
control lists, cache hierarchies, and HTTP server
acceleration

Step 10 Proxy Server - Squid


1. Installation and startup
squid-2.6.STABLE21-6.el5

2. Configuration (/etc/squid/squid.conf)

http_port 3128
cache_mem 8 MB
cache_dir ufs /var/spool/squid 100 16 256
acl all src 0.0.0.0/0.0.0.0
acl localhost src 127.0.0.1/255.255.255.255
acl example src 192.168.80.0/255.255.255.0
http_access allow localhost
http_access allow example
http_access deny all

3. Service startup

# service squid start ; netstat nat | grep 3128


# chkconfig squid on

4. Browser configuration on Firefox


Edit->Preference->Advanced->Network->Settings

5. Testing

Web Server Setup using Apache


on CentOS 5.8

Thank you !!!

You might also like