Tuesday, July 25, 2006

Integrating PHP - Apache in windows

I was trying to intgrate php into apache. My PHP version was PHP 5.1.4 and Apache was Apache 2.0.58 in a Windows XP machine.

I added my php5_apache entry into the httpd.conf of apache
"LoadModule php5_module d:/php/php5apache2.dll"

Then I added
"PHPIniDir d:/php
AddType application/x-httpd-php .php "

In the php.ini file I had uncommented "extension=php_mysql.dll" because I wanted php to use mysql and Apache was simply refusing to load the dll saying "D:\PHP\ext\php_mysql.dll is not found!" So much for legible error messages! Then I was trying to troubleshoot this thingy when I came across this entry which proved to be my savior. I just copied libmysql.dll from d:\php to my system32 folder and Apache stoppped complaining!

But I simple couldnt understand why the dll was not being found!

Friday, July 14, 2006

The edge-seater - > converting a cvsnt project to subversion.

Nows when the nightmare starts I thought when I wanted my CVSNT project to be migrated with all details to Subversion. One thing that was in my favour was there was nothing CVSNT specific that I used and my project was pretty simple project.

First I downloaded cvs2svn and extracted it.
Then I downloaded Python and installed it.
I opened a command prompt to the extracted cvs2svn directory and then typed d:\python2.4\python setup.py install and it started pouring out its usual sysouts like
"install
running install
running build
running build_py
creating build
creating build\lib
....
..
running install_scripts
creating D:\Python24\Scripts
copying build\scripts-2.4\cvs2svn -> D:\Python24\Scripts"

Thats it..Python had created cvs2svn and I crossed my first hurdle.

Then I downloaded UnxUpdates because the sort feature is required by cvs2svn.

I made a copy of the cvs folder I wanted to migrate and then decided its time. I had made the choide to do exactly this! Ok enough of build up ...

I went to the folder where I made the CVS copy opened a command prompt and then typed away.

I first added the sort.exe I downloaded from unx to the path

"set path=%path%;;"

Then...here goes....

"D:\Python24\python D:\Python24\Scripts\cvs2svn --fs-type=fsfs --use-cvs -s d:\svnrepo\<svn_repo_name> <cvs_repo_path>"

The -fs-type is to tell the process to use the fsfs file system insted of the berkley thingy and then --use-cvs is to tell it to use cvs rather that RCS!

I waited with baited breath as the sysouts started to roll...

"----- pass 1 -----
Examining all CVS ',v' files...
....
..
Done
----- pass 2 -----
Checking for blocked exclusions...
Checking for forced tags with commits...
Checking for tag/branch mismatches...
Re-synchronizing CVS revision timestamps...
Done
----- pass 3 -----
Sorting CVS revisions...
Done
----- pass 4 -----
Copying CVS revision data from flat file to database...
Finding last CVS revisions for all symbolic names...
Done
----- pass 5 -----
Mapping CVS revisions to Subversion commits...
Creating Subversion r2 (commit)
Creating Subversion r3 (commit)
Creating Subversion r4 (commit)
....
...
.
----- pass 6 -----
Sorting symbolic name source revisions...
"

Yes, finally the sort is working!!!! If the path was not added, the process breaks exactly here!

"Done
----- pass 7 -----
Determining offsets for all symbolic names...
Done.

Done.

cvs2svn Statistics:
------------------
Total CVS Files: 137
Total CVS Revisions: 383
Total Unique Tags: 1
Total Unique Branches: 2
CVS Repos Size in KB: 124765
Total SVN Commits: 120
First Revision Date: Mon Jun 12 14:58:50 2006
Last Revision Date: Wed Jul 12 17:11:14 2006
------------------
Timings:
------------------
pass 1: 1 second
pass 2: 0 seconds
pass 3: 0 seconds
pass 4: 0 seconds
pass 5: 0 seconds
pass 6: 0 seconds
pass 7: 0 seconds
pass 8: 218 seconds
total: 222 seconds"


Thats it!, I had sucessfully migrated my project.


Integrating Subversion and Eclipse

Now that I have installed Subversion I decided to integrate it with by favorite IDE - Eclipse. I had version 3.1 running.

I went to Help->Software Updates -> Find and Install, created a new remote site and added the URL http://subclipse.tigris.org/update_1.0.x and then installed the Subclipse plugin and restarted the workbench.

Now File-> New Project -> SVN-> checkout New Projects from SVN or File -> Import -> checkout projects from SVN was all it took.

Enabling Webbrowsing for Subversion

Just so that I absolve myself of all responsibility, it so happened that Apache 2.0.x was already installed in my system when I installed the Subversion Server and going by a few posts wrong versions of Apache had caused riots in the enabling webbrowsing of subversion. It seems that you need version lesser than 2.1 of apache and anything above it, well help yourself!

All one needs to do is edit httpd.conf and add

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

For me, this was already added with the full path of the .so files in the bin directory of the subversion installation. i.e I had LoadModule dav_svn_module d:/Program Files/Subversion/bin/mod_dav_svn.so

I believe you can always copy these files into Apaches modules directory and then go ahead with the first 2 lines and everything should work.

Now add,

<location>
DAV svn
SVNParentPath d:/svnrepo/
</location>

This is so that the WebDAV browsing is taken care and I allow browsing of all repositories under my repository directory. If incase you need to enable browsing for only one repository you can go ahead and use SVNPath and give the name of the repository to which you want browsing enabled.

Now start Apache and type in http://localhost/svn/Test to browse the Test repository. Please note that /svn by itself will give you permission denied error. You need to type in the path of the repository also!

Now to provide some basic authentication to my repositories I used htpasswd of apache and added users with passwords and made the password file be available in the conf directory of apache. (htpasswd -c ../conf for the first time and without the -c the second time).

Edit httpd.conf and modify the location entry as follows
<location>
DAV svn
SVNParentPath d:/svnrepo/
AuthType Basic
AuthName "Subversion repository"
AuthUserFile d:/Apache2/conf/svn-auth-file
Require valid-user
</location>

Now restart Apache and everything should be fine, you can enter the website with the users you created via apache.

It is also possible that you can use an XSLT to control the output of the html over webDAV. Just add
SVNIndexXSLT "/svnindex.xsl" to the location tag of httpd.conf where svnindex.xsl is the xsl that you want to use for transformation.

For further tweaking the options please visit the Subversion Book.

Installing Subversion in Windows

I decided I had enough of CVSNT and went ahead to install Subversion in my machine.

First I downloaded Subversions exe svn 1.3.2

All of you who I think I am crazy not to have gone to the tigris site please stop your bad mouthings. The clicksetup thingy always returned a "page not found" so I decided I will choose this alternate site.

I also downloaded the TortoiseSVN 1.3.5 and Rapid SVN client 0.8.0 from the same site.

Then I went ahead and installed the subversion exe thingy to my system. Amazing enough it went without a hitch! The I installed the tortoise and Rapid SVN client thingy too and everything was amazingly sucessful. Now that was easy!

The Tortoise thingy asked me to restart my machine which I did and I could see it integrated with the windows explorer.

I created a folder called svnrepo where I decided I will keep all my repositories and then created another folder called Test under it.

I went inside Test, right clicked - > Tortoise - > Create New Repositiory and wallah I got a new repository. Ofcourse I selected the fsfs as the means of storage (mostly because I liked the name of the Berkeley thingy).

Then I downloaded SVNService placed the exe in the bin directory of subversion and ran "SVNService -install -d -r d:\svnrepo" and then started the service ensuring to change the startup type to automatic in the control panel.

Thats it....subversion was up and running and I had my first repostory too.