Install the required rpms

#yum install httpd*
Start The service

# service httpd on

Make sure service is automatically started at boot time

# chkconfig httpd on

Configure virtual hosting

mkdir -p /var/www/virtual/www.alex.net/html

cd /var/www/virtual/www.alex.net/html

vim index.html            #do any coding in this file

vim /etc/httpd/conf/httpd.conf

<VirtualHost 192.200.1.214:80>

ServerAdmin root@www.alex.net

DocumentRoot /var/www/virtual/www.alex.net/html             # site name is www.alex.net

ServerName www.alex.net

ErrorLog /var/log/web.txt

<!–VirtualHost>

vim /etc/hosts

Insert entry for your website

192.200.1.214 server server
192.200.1.214 www.alex.net

service httpd restart

elinks www.alex.net

Configure multiple site with same ip address

mkdir -p /var/www/virtual/www.hunt.net/html

cd /var/www/virtual/www.hunt.net/html

vim index.html            #do any coding in thsi file

vim /etc/httpd/conf/httpd.conf

<VirtualHost 192.200.1.214:80>

ServerAdmin root@www.hunt.net

DocumentRoot /var/www/virtual/www.hunt.net/html            # site name is www.hunt.net

ServerName www.hunt.net

ErrorLog /var/log/web.txt

<!–VirtualHost>

vim /etc/hosts

Insert entry for your website

192.200.1.214 www.hunt.net

service httpd restart

elinks www.hunt.net

How to create site alias

vim /etc/hosts
Insert entry for your website

192.200.1.214 server server
192.200.1.214 www.alex.net   www.manish.net

vim /etc/httpd/conf/httpd.conf

<VirtualHost 192.200.1.214:80>

ServerAdmin root@www.alex.net

DocumentRoot /var/www/virtual/www.alex.net/html         #site name is www.alex.net

ServerName www.alex.net

ServerAlias www.manish.net

ErrorLog /var/log/web.txt

</VirtualHost>

service httpd restart

Hosting virtual Directory or how to crate a virtual directory on a website

mkdir -p /var/www/virtual/www.alex.net/html/accountinfo

cd /var/www/virtual/www.alex.net/html/accountinfo

cat > sec.txt

vim /etc/httpd/conf/httpd.conf

<VirtualHost 192.200.1.214:80>

ServerAdmin root@www.alex.net

DocumentRoot /var/www/virtual/www.alex.net/html

ServerName www.alex.net

ErrorLog /var/log/web.txt

<directory “=”” var=”” www=”” virtual=”” www.alex.net=”” html=”” <span=”” class=”hiddenSpellError” pre=””>accountinfo”>

Options Indexes

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

service httpd restart

Type this url in browser
www.alex.net/accountinfo

How to secure a web site using HT access

vim /etc/httpd/conf/httpd.conf

<VirtualHost 192.200.1.214:80>

ServerAdmin root@www.alex.net

DocumentRoot /var/www/virtual/www.alex.net/html

ServerName www.alex.net

ErrorLog /var/log/web.txt

<directory “=”” var=”” www=”” virtual=”” www.alex.net=”” html=”” <span=”” class=”hiddenSpellError” pre=””>accountinfo”>

AllowOverride Authconfig

</Directory>

</VirtualHost>

vim /var/www/virtual/www.alex.net/html/accountinfo/.htaccess

AuthUserFile    /etc/httpd/htpasswd

AuthType         basic

AuthName        “plz use a valid username and pasword”

require valid-user      alex

useradd alex
passwd alex

htpasswd -mc /etc/httpd/htpasswd  alex

chmod 777 /var/www/virtual/www.alex.net/html/accountinfo/

chmod 644 /var/www/virtual/www.alex.net/html/accountinfo/.htaccess

service httpd restart

Posted in: Linux.
Last Modified: January 12, 2017

Leave a reply