Monday, November 24, 2008

Creating Virtual Hosts in Apache for Fedora

In the /etc/httpd/conf/httpd.conf file add following line at the end or in the virtual host section.

NameVirtualHost *

# for domain
< VirtualHost * >
DocumentRoot /var/www/vhosts/mydomain1/htdocs
ErrorLog /var/www/vhosts/mydomain1/logs/error_log
CustomLog /var/www/vhosts/mydomain1/logs/access_log common
< /VirtualHost >

# for domain
< VirtualHost * >
DocumentRoot /var/www/vhosts/mydomain2/htdocs
ErrorLog /var/www/vhosts/mydomain2/logs/error_log
CustomLog /var/www/vhosts/mydomain2/logs/access_log common
< /VirtualHost >

Save end Close the file.

Create directories/files according to the virtual hosts defined in the httpd.conf file.

$ cd /var/www
$ mkdir vhosts
$ cd /var/www/vhosts
$ mkdir -p mydomain1/htdocs
$ cd mydomain1
$ mkdir logs
$ cd logs
$ touch error_log
$ touch access_log
$ cd mydomain1
$ chown -R apache:apache logs
$ chown -R apache:apache htdocs

Restart the web server (apache).

/etc/init.d/httpd restart

To teat the Virtual Host syntax:

$ /usr/sbin/httpd -S

(Output will be like below)

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:* is a NameVirtualHost
port * namevhost (/etc/httpd/conf/httpd.conf:1049)
port * namevhost (/etc/httpd/conf/httpd.conf:1057)
Syntax OK

Virtual Host can be easily set and tested on Local Fedora / Redhat machine
In local Fedora/RH machine:


< VirtualHost >
DocumentRoot "/var/www/html"
ServerName localhost
< /VirtualHost >

< VirtualHost >
DocumentRoot "/var/www/mysite"
< /VirtualHost >

Add the in the /etc/hosts file (at the end) localhost.localdomain localhost localhost
::1 localhost6.localdomain6 localhost6

Restart the Apache.

Point your browser at:

It will display the content under /var/www/html dir

It will display the content under /var/www/mysite dir

Tuesday, November 4, 2008

creating svn repository in Fedora

Lets first install subversion (svn server packages) and Apache module for subversion:

$ yum -y install subversion mod_dav_svn

$cd /etc/httpd/conf.d/
$ vi subversion.conf

# Make sure you uncomment the following if they are commented out
LoadModule dav_svn_module modules/
LoadModule authz_svn_module modules/

# Add the following to allow a basic authentication and point Apache to where the actual
# repository resides.

DAV svn
SVNPath /var/www/svn/repos
AuthType Basic
AuthName "SVN Access"
AuthUserFile /etc/httpd/conf.d/svnpassowrd
Require valid-user

Add user who can access the repository:
$ htpasswd -cm /etc/httpd/conf.d/svnpassowrd user1
(It will ask for the apssword for the user 'user1')

$ htpasswd -m /etc/httpd/conf.d/svnpassowrd user2
(It will ask for the apssword for the user 'user2')

Create the repository:

$ cd /var/www/
$ mkdir svn
$ cd svn
$ svnadmin create repos
$ chown -R apache:apache repos
$ service httpd restart

Access repository from a web browser:
(It will ask the apache authentication user and password, supply the user/pass we created using htpasswd command)

Imporing a project into repository:
$ svn import /home/sanjay/testproj/ file:///var/svn/repos/testptoj -m "initial testproject"

Here "repos" is the svn repository (created by svnadmin create command) and "testproj" is one project inside this repository.
/home/sanjay/testproj is the folder containing all the files we want to be in repos.

Adding a dir tree in the existing repository.
Case: Although we can use the svn add/commit but if the dir is too big and there is no UI access for svn repository then
better use the "import" command of svn.

Now if we want to add "wiki" folder into the "testproj" then use the import as below"

$ svn import /home/sanjay/testproj/wiki/ file:///var/svn/repos/testproj/wiki -m "wiki folder in testproj"

Whats new in Ajuby 0.5