0

Install Indefero on Windows with XAMPP

februar 18, 2012 u 17:52  | Broj pregleda: 340

Looking for a decent project and code hosting software for a project I’m running, I’ve stumbled upon Indefero, which suites me because we’ve started using SVN, it has a familiar „face“ resembling Google Code, and seemes like a good thing to improve later on. However, I couldn’t find a decent dummy-proof tutorial on how to install it on Windows and with XAMPP which I use (although, heavily modified since it isn’t really safe otherwise). It’s dependable on Pluf framework and some PEAR classes, which can be a bit challenging to configure, so here we go, step by step.

Notice: I’m using XAMPP 1.7.4, because I’ve had numerous issues with 1.7.7 on Windows XP (which I use as a test VM). This version includes PHP 5.3.5 and that will sufice because Indefero v1.2 which we are installing requires PHP 5.2.4 or later. I will not use Git so I won’t be setting up SSH for access keys nor Python which is required for access control. Maybe some other time.

I will be installing and running Indefero v1.2 with SVN support through VisualSVN Server.

Step 0: Check your environment for requirements

Indefero requires the following to be included in your development env to work.

  • PHP Version 5.2.4 or later. (Version 5.3.5 in XAMPP 1.7.4)
  • Database (MySQL and PostgreSQL are supported, SQLite is supported but not recommended for production) (included in XAMPP)
  • php-cli (included in XAMPP)
  • Pluf framework
  • VisualSVN Server
  • Patience

If your developer environment doesn’t have all of these, update it. I find that my XAMPP has everything I need to start installing hopefully, without any issues.

Step 1: Get and set Pluf

Go to the Pluf homepage and download the master branch from the site. Unzip it and place it in your htdocs directory.

If your server document root is in /htdocs a good thing is to keep the number of files under the /htdocs folder to its minimum.

Your directory structure should look something like this:

/htdocs/pluf/src/
/htdocs/pluf/src/Pluf.php
/htdocs/pluf/src/migrate.php
/htdocs/indefero/src
/htdocs/indefero/www
/htdocs/indefero/www/index.php
/htdocs/indefero/www/media

Step 2: Upgrade PEAR

Some PEAR classes are used, and in order for Indefero to operate well, you should upgrade PEAR by opening your Command Prompt (cmd) in Windows, go to C:\xampp\php (in my case) and type:

PEAR upgrade-all

Now lots of packages are going to get downloaded and upgraded, Mail and Mail_mime will too, and these we need. Ok, next step.

Step 3: Get Indefero

Go to the Indefero’s download page and download the latest Indefero. Follow the directory structure mentioned earlier, unzip the files, and place them in your /htdocs folder.

One thing. The official documentation states that you should make a symbolic link. Since we’re on Windows, and let’s not get into symlinks on Windows we will do the following:

Look for /www subdirectory inside /indefero directory. Open it and move /media and index.php to /indefero. Now, open index.php and change line 24 from:

require dirname(__FILE__).'/../src/IDF/conf/path.php';

to:

require dirname(__FILE__).'/src/IDF/conf/path.php';

and line 26 from:

Pluf::start(dirname(__FILE__).'/../src/IDF/conf/idf.php');

to:

Pluf::start(dirname(__FILE__).'/src/IDF/conf/idf.php');

Why? Shut up and do it, it will make your installation a lot easier. If you know what you’re doing use NTFS symlinks (available on NTFS 3.0, I won’t for sake of Windows XP users)

Step 4: Install VisualSVN Server

Go to VisualSVN Server page and download it. Setup is mostly „Next, Accept, Next“ type except there is a dialog that asks where you want to install it, where do you want your repositories to be and which port and authentication type you want to use.

Caution: We don’t want any spaces in the path! I installed it in C:\SVN, my repositories are in C:\Repositories and I use HTTP, so untick secure connetion and set your Server Port to 3690, and use Subversion authentication. This authentication is required for use with Indefero. When you successfully install it, run it to make sure that the service is started properly. The free version of VisualSVN Server will serve you well with Indefero, and since it’s a service, it will run itself on startup.

Step 5: Configure and Install Indefero

Go to /src/IDF/conf folder and rename idf.php-dist and path.php-dist to idf.php and path.php. It’s time to configure Indefero.

Open idf.php file. This is the part where being on Windows becomes tricky, and it was for me on my first install, but 93% of all the trouble come from this file not being properly configured, and paths not set correctly. So, read very carefully, I shall write this only once.

Paths in Windows and Linux are different. For properly filling out this file, we will use absolute local paths (or if you know what you’re doing use environmental variables, I won’t). I will post uncommented code of idf.php, read it and change your file accourdingly:

Pay attention to the commented lines! I can’t stress enough how important this step is.

$cfg['allowed_scm'] = array('svn' => 'IDF_Scm_Svn'); //Enable SVN version control
$cfg['secret_key'] = 'ZSzspi89voxODPwq6cGcQcSRdNEgbRvr9b9MMcpw'; //You must generate an random string, 40 characters or more for your install
$cfg['debug'] = false;
$cfg['tmp_folder'] = 'c:/xampp/htdocs/indefero/tmp'; //Path to folder for caching, if you don't have it create it
$cfg['pear_path'] = 'C:/xampp/php/PEAR/'; //Path to PEAR folder in XAMPP installation
$cfg['upload_path'] = 'c:/idf/upload'; //Path to upload folder, MUST NOT be accessible through a web browser
$cfg['upload_issue_path'] = 'c:/idf/attachments'; //Path to attachments folder, MUST NOT be accessible through a web browser
$cfg['svn_path'] = 'C:\SVN\bin\svn.exe'; //Path to svn.exe in my SVN installation
$cfg['svnlook_path'] = 'C:\SVN\bin\svnlook.exe'; //svnlook.exe
$cfg['svnadmin_path'] = 'C:\SVN\bin\svnadmin.exe'; //svnadmin.exe
$cfg['hg_path'] = 'hg';
$cfg['git_path'] = 'git';
$cfg['mtn_path'] = 'mtn';
$cfg['mtn_opts'] = array('--no-workspace', '--no-standard-rcfiles');
$cfg['idf_base'] = '';
$cfg['url_base'] = 'http://domain.tld/indefero'; //Your domain, subfolder, when you install in root, just put domain name
$cfg['url_media'] = 'http://localhost/indefero/media'; //URLs here
$cfg['url_upload'] = 'http://localhost/indefero/media/upload';
$cfg['time_zone'] = 'Europe/Belgrade'; //Time zone
$cfg['languages'] = array('en', 'sr'); //Languages, you can enable or disable them here
$cfg['send_emails'] = false;
$cfg['mail_backend'] = 'mail';
$cfg['from_email'] = 'sender@example.com';
$cfg['bounce_email'] = 'no-reply@example.com';
$cfg['admins'] = array(
array('You', 'you@example.com'),
array('Bob', 'bob@example.com'),
);
//Be sure to create the database your are specifying before migration script to avoid trouble.
$cfg['db_engine'] = 'MySQL'; //Type of DB, don't use SQLite3 for production
$cfg['db_database'] = 'indefero'; //name of DB
$cfg['db_server'] = 'localhost'; //server of DB
$cfg['db_login'] = 'username'; //username for DB
$cfg['db_password'] = 'password'; //password for DB
$cfg['db_table_prefix'] = 'indefero_'; //prefix for DB
$cfg['cache_engine'] = 'Pluf_Cache_File';
$cfg['cache_timeout'] = 300;
$cfg['cache_file_folder'] = $cfg['tmp_folder'].'/cache';
$cfg['git_repositories'] = '/home/git/repositories/%s.git/';
$cfg['git_remote_url'] = 'git://137.121.75.54/%s.git';
$cfg['git_write_remote_url'] = 'git@137.121.75.54:%s.git';
$cfg['idf_plugin_syncgit_path_gitserve'] = '/home/www/indefero/scripts/gitserve.py';
$cfg['idf_plugin_syncgit_path_authorized_keys'] = '/home/git/.ssh/authorized_keys';
$cfg['idf_plugin_syncgit_sync_file'] = '/tmp/SYNC-GIT';
$cfg['idf_plugin_syncgit_git_home_dir'] = '/home/git';
$cfg['idf_plugin_syncgit_base_repositories'] = '/home/git/repositories';
//SVN STUFF - IMPORTANT
$cfg['allowed_scm']['svn'] = 'IDF_Scm_Svn';
$cfg['svn_repositories'] = 'file:///C:/Repositories/%s'; // Path to my repositories here, you have to use file with three slashes if you want to browse the source tree from Indefero
$cfg['svn_remote_url'] = 'http://domain.tld:3690/svn/%s/trunk'; //HTTP link to your SVN trunk, %s gets replaced with project name
$cfg['idf_plugin_syncsvn_authz_file'] = 'C:/Repositories/authz'; //Path to these two files, authz and htpasswd is absolute
$cfg['idf_plugin_syncsvn_passwd_file'] = 'C:/Repositories/htpasswd'; //don't try and change their names VisualSVN rewrites it, won't work
$cfg['idf_plugin_syncsvn_svn_path'] = 'C:/Repositories'; //Again, an absolute path to repositories
$cfg['idf_plugin_syncsvn_access_owners'] = 'rw';
$cfg['idf_plugin_syncsvn_access_members'] = 'rw';
$cfg['idf_plugin_syncsvn_access_extra'] = 'r';
$cfg['idf_plugin_syncsvn_access_public'] = 'r';
$cfg['idf_plugin_syncsvn_access_private'] = '';
$cfg['idf_plugin_syncsvn_remove_orphans'] = true;
$cfg['mercurial_repositories'] = '/home/mercurial/repositories/%s';
$cfg['mercurial_remote_url'] = 'http://example.com/hg/%s';
$cfg['idf_plugin_syncmercurial_hgrc'] = array(
'web' => array('push_ssl' => 'false',
'allow_push' => '',
'description' => '',
'allow_archive' => 'bz2, zip, gz',
'style' => 'gitweb',
'contact' => ''),
'hooks' => array(),
'extensions' => array(),
);
$cfg['idf_plugin_syncmercurial_passwd_file'] = '/home/mercurial/auth/.htpasswd';
$cfg['idf_plugin_syncmercurial_path'] = '/home/mercurial/repositories';
$cfg['idf_plugin_syncmercurial_private_notify'] = '/home/mercurial/tmp/notify.tmp';
$cfg['idf_plugin_syncmercurial_private_url'] = '/hg/%s';
$cfg['idf_plugin_syncmercurial_private_include'] = '/home/mercurial/scripts/private_indefero.conf';
$cfg['mtn_repositories'] = '/home/mtn/repositories/%s.mtn';
$cfg['mtn_remote_url'] = 'mtn://example.com/%s';
$cfg['mtn_db_access'] = 'local';
$cfg['installed_apps'] = array('Pluf', 'IDF');
$cfg['pluf_use_rowpermission'] = true;
$cfg['middleware_classes'] = array(
'Pluf_Middleware_Csrf',
'Pluf_Middleware_Session',
'IDF_Middleware',
'Pluf_Middleware_Translation',
);
$cfg['template_context_processors'] = array('IDF_Middleware_ContextPreProcessor');
$cfg['idf_views'] = dirname(__FILE__).'/urls.php';
$cfg['template_folders'] = array(
dirname(__FILE__).'/../templates',
);
$cfg['login_success_url'] = $cfg['url_base'].$cfg['idf_base'];
$cfg['after_logout_page'] = $cfg['url_base'].$cfg['idf_base'];
$cfg['idf_strong_key_check'] = false;
return $cfg;

Warning: Don’t just copy this code. Use it to compare the paths and values, it will not work if you just copy it. Change paths depending on your XAMPP and VisualSVN installation, in your own idf.php.

Step 6: Populating DB and Bootstraping of Indefero

Open your Command Prompt again, and navigate to your indefero/src directory (in my case C:\xampp\htdocs\indefero\src). There we will test and execute a small migration script, that will create tables in the database we specified in idf.php. Energize!
Run the test first. Parameter -u is a dummy, it will not actually generate tables.

php ../../pluf/src/migrate.php --conf=IDF/conf/idf. php -a -i -d -u

If you get something like this you can proceed:

Install all the apps
Pluf_Migrations_Install_setup
IDF_Migrations_Install_setup

Now all we have to do is remove -u and run the script to generate tables.

php ../../pluf/src/migrate.php --conf=IDF/conf/idf. php -a -i -d

Now we’ve successfully populated our database! Don’t close your Command Prompt, we’re almost done.

All we have to do now is to create a bootstrap.php script. This script will insert admin credentials to your database, and Indefero will become operational.

My tool of trade is Notepad++ but you can do it in Notepad, or any other text editor. We create a bootstrap.php with the following code and place it in root folder (in my case /htdocs):

<?php
require 'indefero/src/IDF/conf/path.php';
require 'Pluf.php';
Pluf::start('indefero/src/IDF/conf/idf.php');
Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));

$user = new Pluf_User();
$user->first_name = 'Your name';
$user->last_name = 'Your last name'; // Required!
$user->login = 'username'; // must be lowercase!
$user->email = 'me@mydomain.tld';
$user->password = 'password'; // the password is salted/hashed
// in the database, so do not worry :)
$user->administrator = true;
$user->active = true;
$user->create();
print "Bootstrap ok\n";
?>

now go your Command Prompt, navigate to your xampp htdocs folder and run:

php bootstrap.php

it should print out:

Bootstrap ok

If it does, that means you’ve actually installed a working instance of Indefero! Delete bootstrap.php afterwards, security is a priority.

Step 7: Check it out

Open your browser and go to http://localhost/indefero (or your install path) and if you configured Indefero properly, you should have a working Indefero instance.

Step 8: Important tweaks you must do

  1. Fix File_Passwd compatibility - Some PEAR libraries are not following PHP developement, one of those is File_Passwd, which we need for some essential SVN stuff, authentication with extra password and creating and deleting projects. To solve this, go to PEAR File_Passwd page and download it manually. Untar it and copy Passwd folder and Passwd.php to your PEAR/File folder (in my case it’s C:\xampp\php\PEAR\File).
  2. Fix Passwd.php deprecated references - As I said, some of these libs aren’t very compatible with PHP5.3. We need to fix this in order to have a working SVN. You should open Passwd.php and on line 359 change to:
    $instance = new $class()

    (yes, just delete the & character)

  3. Update SyncSVN to create initial structure – By default the SyncSVN in Indefero doesn’t create initial structure (tags, branches, trunk). I’ve fixed it using a patch submitted on Indefero’s issue tracker, and you can download the patched file on the bottom of the post. Unzip it and replace SyncSVN.php in indefero\src\IDF\Plugin with this version.

 

That’s it! We have a working instance of Indefero with SVN support.

Indefero instance browsing SVN source tree

Here you can see my test install, browsing a test project source tree. Again, I can’t stress this enought: Check paths, I’ve shown you how I do it, you change paths if you install it differently. I hope this tutorial will help many people like me with setting up Indefero as I find it’s a great piece of software, but the installation is a journey for itself. And believe me when I tell you, this thing has both quality and potential.

 

Patched SyncSVN.php
Download
Downloaded 19 times

Dif-tor heh smusma!

This took too long for one song, but this one kept me going.

Samba do Brasil – Ey Macalena*

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Oznake: apache, indefero, install, PEAR, php, pluf, subversion, svn, windows, xampp, xp

Datum objavljivanja članka je: subota, februar 18, 2012 u 17:52 u kategoriji PHP. Možete pratiti komentare kroz RSS 2.0 fid. Možete ostaviti odgovor ili preputiti sa vašeg sajta.

Slični članci

Ostavite odgovor