Saturday, May 9, 2009

HowTo Configure Port Based Virtual Host on Apache2

1] Change to root user to make changes

$ su -

2] Modify apache config file

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

3] Locate the line which shows 'Listen 80' and add a line under it with the port number on which virtual host needs to run, in this example 8080.

Listen 8080

4] Then locate virtual host section in the config file which is usually at the end of the config file. And add new virtual host section as shown in the example below and save the file. Please m necessary changes in the below section as per your requirement.

# vhost

ServerAdmin webmaster@vhost.com
DocumentRoot /var/www/vhost
ServerName vhost.com
ErrorLog logs/vhost.com-error_log
CustomLog logs/vhost.com-access_log common


5] Above virtual host section we have defined html web page path as /var/www/vhost, so this directory has to exist along with the index.html page for apache to serve http request received on 8080.

6] Now check if apache config for errors

# /usr/sbin/apachectl -t

7] And if output say 'Syntax OK' then restart apache services

# service httpd restart

8] Now start your browser and open and bingo your Virtual Website is serving pages

http://ServerIP:8080

Replace ServerIP with the real ip address of your web server

Howto Disable SELINUX on CentOS 5.x / RHEL 5.x

1] Change to root user to make changes

$ su -

2] Check the status of SELINUX using following command

# sestatus
SELinux status: enabled

3] To disable SELINUX modify config file

# vi /etc/selinux/config

4] Search for the line 'SELINUX=enforcing' and modify this line as

SELINUX=disabled

5] Now save the file and reboot the system.

6] Once the system is restarted check the status of SELINUX run the command mentioned above in point 2 and now it should show SELINUX status as 'disabled'.