Monday, August 2, 2010

RHCE study notes: Apache web server


system admin Dave intend to install web server with apache

a:install apache server and configure single website in /var/www/index.html

# yum install httpd*
# chkconfig httpd on
# service httpd start
firefox http://192.168.0.11    //test page,apache install successful
# vim /etc/httpd/conf/httpd.conf      // configure apache
NameVurtualHost  *:80                 //start to this function
DocumentRoot: /var/www/html/
ServerName:   station11.example.com
Errorlog:    logs/station11.example.com_errolog
Customlog:   logs/station11….
# vim /var/www/html/index.html
# service httpd restart
firefox http://192.168.0.11   //test index.html

b: configure virtual host with /myweb/index.html

# vim /etc/httpd/conf/httpd.conf
DocumentRoot: /myweb/
ServerName: www.163.com
…..
…..
# vim /etc/hosts
192.168.0.11   www.163.com
# mkdir myweb
# vim /myweb/index.html
# service httpd restart
# chgrp apache /myweb
# chgrp apache /myweb/index.html
# chcon -R –reference=/var/www/html  /myweb
# ls -LZ
# service httpd restart
firefox http://www.163.com   //test index.html

c: Security–Certificate

# yum install mod_ssl
# cd /etc/pki/tls/certs–>localhost.crt    //original cert
# rm -f localhost.crt
# make testcert
CN->JS->NJ->Wanho->IT->common name(station11.example.com)
# vim /etc/httpd/conf.d/ssl.conf           //check detail, recommend no modify this file
# service httpd restart

d:Control access website with adding user and pin

# vim /etc/httpd/conf/httpd.conf
               //setting in /myweb/test
AllowOverride All
AuthName “http test”
AuthType basic
AuthUserFile  /etc/httpd/.htpasswd
Require valid-user
# htpasswd -cm /etc/httpd/.htpasswd user1
# service httpd restart
# chkconfig httpd on
firefox http://www.163.com/test   //type user and pin