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 mydomain1.com
< VirtualHost * >
DocumentRoot /var/www/vhosts/mydomain1/htdocs
ServerName mydomain1.com
ErrorLog /var/www/vhosts/mydomain1/logs/error_log
CustomLog /var/www/vhosts/mydomain1/logs/access_log common
< /VirtualHost >


# for domain mydomain2.com
< VirtualHost * >
DocumentRoot /var/www/vhosts/mydomain2/htdocs
ServerName mydomain2.com
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 mydomain1.com (/etc/httpd/conf/httpd.conf:1049)
port * namevhost mydomain2.com (/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:

NameVirtualHost 127.0.0.1

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

< VirtualHost 127.0.0.1 >
DocumentRoot "/var/www/mysite"
ServerName mysite.com
< /VirtualHost >

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

Restart the Apache.

Point your browser at:
http://localhost

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

http://mysite.com/

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/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

# 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:
http://ip-address/repos
(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