Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Monday, 28 August 2017

APACHE Web Server Configuration on Linux RHEL / CentOS 5&6


                       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




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) 
·                     configuration file  :  /etc/httpd/conf/httpd.conf

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 1003 to 1009)
paste under 1009 line
change as follows

         ServerAdmin root@www.bsrtech.net

         DocumentRoot /var/www/html/bsrtech/
         ServerName  www.bsrtech.net

        DirectoryIndex index.html
 


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

cd /var/www/html/

create directory name with bsrtech
 # mkdir bsrtech

 # cd bsrtech
 
 #vim index.html
(type as follows)
  
 
      
           
                  

"    welcome to BSR TECHNOLOGIES"


          


      

 
:save & quit
#service httpd restart
open firefox and type in url
http://www.bsrtech.net (now the website will appear)
 

To launch virtual websites using virtual hostnames

#vi /etc/httpd/conf/http.conf
(line no 990) # NameVitualHost *: 80 (remove # and *:80) type ur system ip
(NameVirtualHost 192.168.0.22:80 )
copy last five lines and paste under it

 NameVirtualHost 192.168.0.22:80
  
      ServerAdmin root@www17.redhat.com
      DocumentRoot /var/www/virtual
      serverName  www17.redhat.com
  


(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


"welcome to virtual website"




save & quit
#service httpd restart


to check
 
open mozilla
 
type http://www17.redhat.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

     ServerAdmin root@xxx17.redhat.com
     DocumentRoot /cyber
     serverName  xxx17.redhat.com
 

save&quit
#mkdir /cyber
#cd /cyber
#vi index.html


"welcome to cyber'+'technologies"




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......) 
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipVWEZ_OJhlq7n_jV0qZTadG7Ptv0FNkqpKfz4BsgpWUft5KRWE7YffepHMosCbzrbamvHqg7nef1V4L_BnPdlYqn3lNLn1TCExzyErv8YmbI-RGshIRrqSyjLik2K76t2sVCbmW4B6Q3F/s400/Client+Server+Architecture.bmp


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


      
  TRY   THINGS   AFTER    PRACTICING EXAM ESSENTIALS


to create link pages in a website

#vi /etc/httpd/httpd.conf

    ServerAdmin root@www17.redhat.com
    DocumentRoot /var/www/virtual
    serverName  www17.redhat.com
    Alias /training   /var/www/training (add this line in that website)
 


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

 
 AllowOverride AuthConfig
 

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


 Order Allow,deny
 Allow from all
 deny station12.redhat.com

( 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


No comments:

Post a Comment