APACHE Web Server Configuration

Different web servers in world :-

Tux : Kernel based only text support, Very fast
Stronghold : from RedHat Linux
Sun one : Also known as iPlanet from Sun Microsystems
AOL server : American online free web server
Apache : Open source
NETSCAPE

what is apache?

Apache is a freeware & is the Most Popular& widely used Web Server which consumes 60% of web market that can be configured in both windows and LINUX.

apache server is used to launch  our web pages  as websites.

service profile:
type : System V-managed service
packages : httpd,httpd-devel,httpd-manual
Daemon : /usr/sbin/httpd
script :/etc/init.d/httpd
ports : 80(http).443(https)
conf file: /etc/httpd/conf/httpd.conf
related : system-config-httpd,mod_ssl
default selinux daemon : /var/www

steps to configure apache:

#yum install httpd-* -y
#service httpd start
#chkconfig httpd on
#vi /etc/httpd/conf/httpd.conf

copy 7 lines (line no 984 to 990)
paste under 990 line
change as follows
<VirtualHost 192.168.0.17>
992     ServerAdmin root@station17.redhat.com
993     DocumentRoot /var/www/html
994     ServerName  station17.redhat.com
995    </VirtualHost>

(here 192.168.0.17 is our system’s ip & /var/www/html is the document root here we have to place web page to convert as web site NOTE: web page must be with a name of index.html)
save&quit

cd /var/www/html
vi index.html

(type as follows)
<head>
<body bgcolor=red>
<h1> ”    welcome to cyber web services” <h1>
</body>
</head>
save & quit

#service httpd restart

open firefox and type in url
http://linuxbeginners.com(now the website will appear)

to launch virtual websites using virtual hostnames

#vi /etc/httpd/conf/http.conf

(line no 971) # name vitual host *: 80 (remove # and *:80) type ur system ip
(namevirtualhost 192.168.0.17 )
copy last five lines and paste under it

< VirtualHost 192.168.0.17>
ServerAdmin root@www17.redhat.com
DocumentRoot /var/www/virtual
serverName  www17.redhat.com
</VirtualHost>

(here we are changing system name as www17.redhat.com and document root under /var/www/virtual)
save & quit

#mkdir -p /var/www/virtual
# cd /var/www/virtual
# vi index.html

<head>
<body bgcolor=green>
<h1> “welcome to virtual website” <h1>
</body>
</head>
save & quit
#service httpd restart

to check
open mozilla
type http://server1.linuxbeginners.com

to create virtual webpages under any directory

by default selinux allows webpages which are located under /var/www/  if we want to launch a webpage which is not present under /var/www we have to change selinux context,boolean values.

ex:

# vi /etc/httpd/conf/httpd.conf

<VirtualHost 192.168.0.17>
ServerAdmin root@xxx17.redhat.com
DocumentRoot /cyber
serverName  xxx17.redhat.com
</VirtualHost>
save&quit
#mkdir /cyber
#cd /cyber
#vi index.html
<html>
<body bgcolor=blue>
<h1> “welcome to cyber’+’technologies” <h1>
</body>
</html>
save & quit
#chcon -R –reference=/var/www/html /cyber
#service httpd restart

to check :
open mozilla
type in url box as follows
http://xxx17.redhat.com(u will get website)

(Click On below image to large……)

##############################################################################

TRY   THINGS   AFTER    PRACTICING EXAM ESSENTIALS

to create link pages in a website

#vi /etc/httpd/httpd.conf
<VirtualHost 192.168.0.17>
ServerAdmin root@www17.redhat.com
DocumentRoot /var/www/virtual
serverName  www17.redhat.com
Alias /training   /var/www/training (add this line in that website)
</VirtualHost>

save & quit
# cd /var/www/
#cat > training
(type any thing)
save
#service httpd restart

to check  :
go to mozilla
type www17.redhat.com/training

to create Authenticated websites
#vi /etc/httpd/conf/httpd.conf

<Directory /var/www/html>
AllowOverride AuthConfig
</Directory>
save & quit

# cd /var/www/html
#vi .htaccess
AuthName “it”
AuthType Basic
AuthUserfile /etc/httpd/conf/passwd
require valid-user

we have to provide http password for an user to view this website
#htpasswd -mc /etc/httpd/conf/passwd sam
(type password 2 times)

#service httpd restart

to check :

open mozilla —clear private data —in url type http://station17.redhat.com
(give username&password)

To restrict a particular user or particular system to access a website

#vi /etc/httpd/conf/httpd.conf

<Directory “/var/www/html”>
Order Allow,deny
Allow from all
deny station12.redhat.com
</Directory>
( here we are denying station12.redhat.com)

to check try to open station17.redhat.com from station12 system

to create ssl certificate for an web server

#yum install openssl-* -y
#yum install mod-ssl-* -y
#vi /etc/httpd/conf.d/ssl.conf

(line no134) #SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt (remove #)
save&quit

#cd /etc/pki/tls/certs
make genkey
provide passphrase
#make testcert
passphrase(create with samepassword)
provide country,city,office,mailaddress
#service httpd restart

to run scripts

#vi test.sh
#!/bin/bash
echo Content-Type:text/html
echo

date
ls -l
echo welcome to cyber services

save&quit

#mkdir -p /var/www/hml/cgi-bin
#cp -rf test.sh /var/www/html/cgi-bin/
#cd /var/www/html/cgi-bin/
#cd ..
#chown -R apache.apache cgi-bin
#cd cgi-bin
#chmod 755 test.sh
#vi /etc/httpd/conf/httpd.conf

add a line in website data
ScriptAlias /cgi-bin  “/var/www/html/cgi-bin”
save&quit

#service httpd restart
#setsebool -P httpd_tty_comm on
#setsebool -P httpd_enable_cgi 1
#setsebool -P httpd_sys_script_exec_t rw

to check:

open mozilla

type http://station17.redhat.com/cgi-bin

2 thoughts on “Apache Web Server Configuration

Leave a Reply

Your email address will not be published. Required fields are marked *