[How-To] Install Redmine On A Zpanel Server Using Apache Passenger and Subversion

For those of you that would like to run Redmine with your Zpanel client follow this how-to below. I see there are a lot of programmers here so I hope this helps you out. This is a tutorial put together by a buddy of mine (Tide). Thanks Tide. I felt like this would be a good how to here. Maybe even a sticky? hint, hint. Cool

Also, Ballen...I noticed somewhere before that you were working on a Redmine module for zpanel. If you are still working on it I hope this help you out.

This has been tested on the following set up.

Centos 6.3 , zpanel 10.0.2

Centos 6.4 , zpanel 10.1.0

Here's what you need.

Centos 6.3 or Centos 6.4

Zpanel 10.0.2 or Zpanel 10.1.0

SSH Access

Patience (You need lots of this Big Grin )

Time

Time

And More Time

Did I mention you need a lot of time? Cool

Before we get started lets assume the following.

You domain is: "www.myexample.com"

Your sub-domain will be "svn.myexample.com"

Your user home directory will be "testclient"

You have SSH access to your server

You have root access.

You know how to use NANO or another Linux editor.

You have working email on your Zpanel server

If you do not have all of the above.........STOP.....Fix those before continuing. Thanks Cool

Important! You should disable SElinux before installing. You can enable it and configure the IPtables later. This is not a tutorial for setting up iptables. 

So, Let's get started.

Log into your zpanel client.

Create your new site for http://www.myexample.com 

Create your dns records for http://www.myexample.com

Make sure you point your domain to the server.

Wait for this to resolve. This is important! Make sure your page comes up with the default Zpanel creation page before you continue. This will make sure you have a working page before Redmine is installed. This way if it breaks, you know it's Redmine causing the issue. Once your new domain resolves you can continue.

Now that you can see your newly created site lets create the sub domain that subversion will use.

Go to sub domains in Zpanel.

Create a sub domain svn.myexample.com (Remember...Use your actual domain)

Now create an "A" record for svn.myexample.com

Those settings for this "A" record will be.....

Host Name = svn

TTL = 86400

Target = xxx.xxx.xxx.xxx (This will be your IP Address)

Save your settings.

Wait for this to resolve. This is important! Make sure your svn sub domain page comes up with the default Zpanel creation page before you continue. This will make sure you have a working page before subversion is installed. This way if it breaks, you know it's subversion causing the issue. Once your new domain resolves you can continue.

Log into SSH (Under Root) I know this is not recommended but this was the best way.

Now you need to install the following....Run these in SSH and follow the prompts. 

Code:
yum update
Code:
yum -y install ruby rubygems
Code:
yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel gcc ruby-devel
Code:
yum -y install gcc-c++ make postgresql-devel ImageMagick-devel sqlite-devel perl-LDAP mod_perl perl-Digest-SHA
Code:
gem install passenger
Code:
passenger-install-apache2-module

Important! When your done installing Apache-Module you will see the code you need to use to configure the ruby.conf .Make sure you save that code. It will look like this.... 
Code:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.8/buildout/apache2/mod_passenger.so

PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.8

PassengerDefaultRuby /usr/bin/ruby

Now lets create and edit the ruby.conf

Code:
nano /etc/httpd/conf.d/ruby.conf

Once you open the ruby.conf add the code that Apache-Module gave you. Remember...The code I told you to save.... Big Grin

Now lets restart Apache

Code:
service httpd restart

Go to your user home Directory that you installed "www.myexample.com" in.

Code:
cd /var/zpanel/hostdata/testclient

Now lets download Redmine. Click here to see if you are getting the latest version

Code:
wget http://www.redmine.org/releases/redmine-2.4.2.tar.gz

Let's unzip it. (Make sure you have the version correct)

Code:
tar xvfz redmine-2.4.2.tar.gz

Now let's copy the file to the new Redmine directory. (Make sure you change the version if you downloaded a different one.)

Code:
mv redmine-2.4.2 redmine

Remove old files

Code:
rm -r redmine-2.4.2.tar.gz

Go to your new Redmine directory

Code:
cd redmine

Now install these....

Code:
gem install bundler
Code:
bundle install --without development test

Now go back to your zpanel client and create a new database and a new database user. Make sure you note this info down as you will need it later.

Then give the new user R/W access to the database you created.

Now lets set up some stuff in Redmine.

Go to this directory...Remember to use the correct user directory.

Code:
cd /var/zpanel/hostdata/testclient/redmine/config

Create the new Redmine config.

Code:
cp database.yml.example database.yml

Now lets edit the config.

Code:
nano database.yml

You need to change the database info under production.
Code:

production:

adapter: mysql

database: Enter your database here

host: localhost

username: Enter your database user name here

password: "" Enter your database password here

encoding: utf8

Save your settings.

Now lets go back to your Redmine directory.

Code:
cd /var/zpanel/hostdata/testclient/redmine/

Run these commands.

Code:
bundle install
Code:
rake generate_secret_token
Code:
RAILS_ENV=production rake db:migrate
Code:
RAILS_ENV=production rake redmine:load_default_data
Code:
mkdir -p tmp tmp/pdf public/plugin_assets

Lets chmod some files

Code:
chmod -R 755 files log tmp public/plugin_assets

Go to your public directory in Redmine

Code:
cd /var/zpanel/hostdata/testclient/redmine/public/

Run these commands.

Code:
cp dispatch.fcgi.example dispatch.fcgi
Code:
cp htaccess.fcgi.example .htaccess

Go back to your user directory

Code:
cd /var/zpanel/hostdata/testclient

Guess what........ We are going to download and install more stuff. Run these... 

Getting Apache to work with FastCGI:

Important! the following file version may change. If so go Here to check and see what the new version is.
Code:

rpm --import https://fedoraproject.org/static/0608B895.txt
Code:
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

 

Code:
rpm -ivh epel-release-6-8.noarch.rpm

 

Code:
yum -y install mod_fcgid

Now get rid of some old files...

Code:
rm -rf *rpm


Go to the Redmine config directory

Code:

cd /var/zpanel/hostdata/testclient/redmine/config


Important! Before you complete the next section make sure your email thru Zpanel is working properly.

Copy config file for Redmine email settings

Code:
cp configuration.yml.example configuration.yml

Open the config file

Code:
nano configuration.yml

Under attachments_storage in the configuration.yml put this...

Code:
attachments_storage_path: /var/zpanel/hostdata/testclient/redmine/files

Then change this for email settings...

Code:
email_delivery:

delivery_method: :smtp

smtp_settings:

address: Enter your email server here (Example: smtp.myexample.com)

port: Enter your port here (Default: 25)

domain: Enter your domain here (Example: myexample.com)

authentication: :login

user_name: "Enter your email username" (Example: testclient[at]myexample.com)

password: "Enter your email password here."

Yours will look more like this...

Code:
email_delivery:

delivery_method: :smtp

smtp_settings:

address: smtp.myexample.com

port: 25

domain: myexample.com

authentication: :login

user_name: "testclient[at]myexample.com"

password: "mypassword"

Save the new configuration.yml

Now chown the directory...

Code:
chown -R apache:apache /var/zpanel/hostdata/testclient/redmine/

Now go to zpanel page > Module Admin > Apache Config > Override a Virtual Host Setting and select myexample.com

Make sure OpenBase is unchecked.

add this to the custom entry section:

Code:
DocumentRoot "/var/zpanel/hostdata/testclient/redmine/public/"

MaxRequestLen 20971520

<Directory "/var/zpanel/hostdata/testclient/redmine/public/">

Options Indexes ExecCGI FollowSymLinks

Order allow,deny

Allow from all

AllowOverride all

</Directory>

Let's install subversion....

Code:
yum -y install mod_dav_svn subversion subversion-ruby

Make this directory...

Code:
mkdir /usr/share/perl5/vendor_perl/Apache

Run this....

Code:
ln -s /var/zpanel/hostdata/testclient/redmine/extra/svn/Redmine.pm /usr/share/perl5/vendor_perl/Apache/Redmine.pm

Make a new directory called "svn" ... (This directory will be in the same directory as Redmine)

Code:
cd /var/zpanel/hostdata/testclient
Code:
mkdir svn

Lets make sure that apache can read it.

Code:
chown -R apache:apache /var/zpanel/hostdata/testclient/svn

Now go to zpanel page > Module Admin > Apache Config > Override a Virtual Host Setting and select svn.myexample.com

Make sure OpenBase is unchecked.

Add this to the custom entry section:

Code:
PerlLoadModule Apache::Redmine

<Location />

DAV svn

SVNParentPath "/var/zpanel/hostdata/testclient/svn"AuthType Basic

AuthName "Redmine SVN Repository"

Require valid-user

PerlAccessHandler Apache::Authn::Redmine::access_handler

PerlAuthenHandler Apache::Authn::Redmine::authen_handler

RedmineDSN DBI:mysql:database=Enter_Your_Database_Here;host=localhost

RedmineDbUser Enter your database user name here

RedmineDbPass Enter your database password here

</Location>

Now restart Apache...

Code:
service httpd restart

You may also want to run the Zpanel daemon at Zpanel >Zpanel config > 

Your done!!! Congrats Cool I told you this takes a lot of time... Cool....

You can now go to http://www.myexample.com to see your new Redmine page. You can log into your new redmine installation by using the username: admin Password: admin . For security reasons make sure you change the username and password first thing.

svn.myexample.com is only there for subversion. It wont let you log in unless you have a project.

Also, with Redmine you will have to manually create repos. To keep from having to do this you can install SCM Creator. This will allow you to create and delete repos on the fly. This plugin for Redmine works with Subversion/Git/Mercurial/Bazaar. So you want to install it? Let's keep going.

[How-To] Install SCM Creator Plugin for Redmine

Information about the plugin.
You can view the plugin infomation HERE
You can download the plugin HERE
You can view the install instructions HERE

Let's get started.

If you followed the tutorial above you will have a working Redmine site and a working Subversion site. In the examples they were the following.

You domain is: "www.myexample.com" (This is the url for the Redmine site)

Your sub-domain will be "svn.myexample.com" (This is the url for subversion site)

Remember that the Redmine site (Folder) and the Subversion site (Folder) are located in the users directory in zpanel.

In the tutorial these folders are located in /var/zpanel/hostdata/testclient

Time to download the SCM plugin.

Go to your Redmine plugins directory.

Code:
cd /var/zpanel/hostdata/testclient/redmine/plugins

Download the latest version of the SCM Creator Plugin. You can check to see what the latest version is by clicking HERE

Code:
wget http://projects.andriylesyuk.com/attachments/download/486/redmine_scm-0.4.3.tar.bz2

Now extract the file you just downloaded.

Code:
tar xvjf redmine_scm-0.4.3.tar.bz2

Remove old files.

Code:
rm -r redmine_scm-0.4.3.tar.bz2

You should now have a folder for redmine_scm in your plugins directory. Let's move on.

Go to your users directory.

Code:
cd /var/zpanel/hostdata/testclient

Change the owner and the group of the subversion folder.

Code:
chown apache:apache /var/zpanel/hostdata/testclient/svn

Next make sure that the subversion folder is writeable by the user.

Code:
chmod 0755 /var/zpanel/hostdata/testclient/svn

Go to the SCM Creator plugin config directory in Redmiine.

Code:
cd /var/zpanel/hostdata/testclient/redmine/plugins/redmine_scm/config

Now you need to copy the scm.yml config file to the Redmine config directory.

Code:
cp scm.yml /var/zpanel/hostdata/testclient/redmine/config/scm.yml

Now we need to edit the newly copied config file. Go to the Redmine config folder.

Code:
cd /var/zpanel/hostdata/testclient/redmine/config

Nano the scm.yml config file so we can do some editing.

Code:
nano scm.yml

You will see the following lines.

Code:
production:

auto_create: true

deny_delete: false

pre_create: /usr/local/bin/pre-create.sh

post_create: /usr/local/bin/post-create.sh

pre_delete: /usr/local/bin/pre-delete.sh

post_delete: /usr/local/bin/post-delete.sh

svn:

path: /var/lib/svn

svnadmin: /usr/bin/svnadmin

url: svn

git:

path: /var/lib/git

git: /usr/bin/git

options: --bare

url: http://git.myhost.com

update_server_info: true

git_ext: true

append: .git

mercurial:

path: /var/lib/mercurial

hg: /usr/bin/hg

bazaar:

path: /var/lib/bazaar

bzr: /usr/bin/bzr

init: init-repository

log_encoding: UTF-8

append: trunk

You need to set the following options. I put explanations on what they do beside them. Click HERE for details on each setting.

auto_create: true (This option turns auto creation of repos on or off. If you want this plugin to work set it to true)

deny_delete: false (This allows the admin to delete a repo thru the plugin. Set this to false)

Under the svn lines edit the following. (You can check to see what the directory for your svnadmin tool is by running the following command.

Code:
which svnadmin

)

path: /var/zpanel/hostdata/testclient/svn (This is the path to your SVN folder) This setting is required!

svnadmin: /usr/bin/svnadmin (This is the path to your svnadmin tool) This setting is required! 

url: svn.myexapmle.com (Your subversion url)

Once you edited these lines save the scm.yml file.

Go to your Redmine directory.

Code:
cd /var/zpanel/hostdata/testclient/redmine

Now lets finish installing the plugin. Run this command.

Code:
rake redmine:plugins:migrate RAILS_ENV=production

To finsh the install you need to restart Redmine. To do this just restart Apache.

Code:
service httpd restart

Once Redmine has been restarted you can now go to your Redmine site and login. Go to the Administration section to view your new plugin.

[How-To] Configure SVN to use the usernames, passwords and permissions from Redmine.

If you are running Redmine with subversion using the tutorial above you are already set up. SVN is already using your Redmine database usernames and passowrds.

You can set up GIT and Mercurial as well. Some How-To's for those are below.

Note: For Redmine based SVN/Git/Mercurial authentication to work the repository name and the project identifier must be identical.

Here are some How-To's for GIT and Mercurial.

For GIT (This one is more complicated)

Repositories access control with apache, mod_dav_svn and mod_perl

HowTo configure Redmine for advanced git integration

Redmine.pm: add support for Git’s smart HTTP protocol

For Mercurial

HowTo configure Redmine for advanced Mercurial integration

I hope this tutorial helps someone and congrats if you made it all the way thru. I currently have this working on two servers.

Good LuckCool

Additional Tools for commiting to Redmine.

I use Visual Studio 2010 and Visual Studio 2013 for coding. To properly commit to a project in Redmine Use the tool below.

AnkhSVN - Subversion Support for Visual Studio

Their site is HERE

Their downloads are HERE

Once you download and install this plugin in Windows do the following.

1. Open Visual Studio

2. Go to "Tools" then "Options"

3. Click the expand arrow on "Source Control"

4. Click on Plug-in Selection

5. In the drop down select "AnhkSVN - Subversion Support for Visual Studio"

6. Click Ok

7. That's It!

Now look at your Solution Explorer in Visual Studio once your project is open. Right Click and you will see the options to commit your projects into your newly setup Redmine site.

(james30263 - http://forums.zpanelcp.com)