Apache Server Configuration in Linux


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 http://www.alex.net

ServerName http://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 http://www.alex.net

service httpd restart

elinks http://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 http://www.hunt.net

ServerName http://www.hunt.net

ErrorLog /var/log/web.txt

<!–VirtualHost>

vim /etc/hosts

Insert entry for your website

192.200.1.214 http://www.hunt.net

service httpd restart

elinks http://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 http://www.alex.net   http://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 http://www.alex.net

ServerName http://www.alex.net

ServerAlias http://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 http://www.alex.net

ErrorLog /var/log/web.txt

<directory “=”” var=”” www=”” virtual=”” http://www.alex.net=”&#8221; html=”” <span=”” class=”hiddenSpellError” pre=””>accountinfo”>

Options Indexes

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

service httpd restart

Type this url in browser
http://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 http://www.alex.net

ErrorLog /var/log/web.txt

<directory “=”” var=”” www=”” virtual=”” http://www.alex.net=”&#8221; 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

About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Server Configuration. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s