GitHub clone based on Debian Squeeze Gitolite Git Git-Daemon MySQL Nginx and Mongrel Cluster » History » Version 5

Andrew Perry, 2012-04-12 10:39
Adding instructions for a basic mail server so that passwords can be reset etc.

1 2 Paul zur Horst-Meyer
h1. GitHub clone based on Debian Squeeze, Gitolite, Git, Git-Daemon, MySQL, Nginx and Mongrel Cluster
2 1 Paul zur Horst-Meyer
3 1 Paul zur Horst-Meyer
h2. requirements
4 1 Paul zur Horst-Meyer
5 1 Paul zur Horst-Meyer
* fresh und updated debian squeeze installation (preferable 64bit)
6 1 Paul zur Horst-Meyer
* login as root
7 1 Paul zur Horst-Meyer
8 4 Paul zur Horst-Meyer
PS: i am sorry, but i don´t like to comment any part and command of this install notes. 
9 1 Paul zur Horst-Meyer
Copy and past should be work :P
10 1 Paul zur Horst-Meyer
11 1 Paul zur Horst-Meyer
h3. Debian package install:
12 1 Paul zur Horst-Meyer
13 5 Andrew Perry
 apt-get install imagemagick ruby ruby-dev libruby rubygems mysql-server libmysqlclient-dev libmagickwand-dev git sudo nginx exim4
14 1 Paul zur Horst-Meyer
15 1 Paul zur Horst-Meyer
Ruby Gems package install:
16 1 Paul zur Horst-Meyer
17 1 Paul zur Horst-Meyer
 gem install lockfile inifile net-ssh mysql rmagick rdoc mongrel mongrel_cluster
18 1 Paul zur Horst-Meyer
gem install rails -v=2.3.14
19 1 Paul zur Horst-Meyer
gem install i18n -v=0.4.2
20 1 Paul zur Horst-Meyer
21 1 Paul zur Horst-Meyer
h3. you have to link some installed gems:
22 1 Paul zur Horst-Meyer
23 1 Paul zur Horst-Meyer
 ln -s /var/lib/gems/1.8/bin/rake /usr/bin/
24 1 Paul zur Horst-Meyer
ln -s /var/lib/gems/1.8/bin/mongrel_rails /usr/bin/
25 1 Paul zur Horst-Meyer
26 1 Paul zur Horst-Meyer
h2. User configuration
27 1 Paul zur Horst-Meyer
28 1 Paul zur Horst-Meyer
 adduser --system --shell /bin/bash --gecos 'Git Administrator' --group --disabled-password --home /opt/gitolite git
29 1 Paul zur Horst-Meyer
adduser --system --shell /bin/bash --gecos 'Redmine Administrator' --group --disabled-password --home /opt/redmine redmine
30 1 Paul zur Horst-Meyer
31 1 Paul zur Horst-Meyer
run _visudo_ and add this content:
32 1 Paul zur Horst-Meyer
33 1 Paul zur Horst-Meyer
 redmine  ALL=(git)      NOPASSWD:ALL
34 1 Paul zur Horst-Meyer
git      ALL=(redmine)  NOPASSWD:ALL
35 1 Paul zur Horst-Meyer
36 1 Paul zur Horst-Meyer
h2. Setup Gitolite
37 1 Paul zur Horst-Meyer
38 1 Paul zur Horst-Meyer
... as _Git_ user:
39 1 Paul zur Horst-Meyer
40 1 Paul zur Horst-Meyer
 su git
41 1 Paul zur Horst-Meyer
cd ~
42 1 Paul zur Horst-Meyer
43 1 Paul zur Horst-Meyer
generate gitolite key pair for administration:
44 1 Paul zur Horst-Meyer
45 1 Paul zur Horst-Meyer
 ssh-keygen -t dsa
46 1 Paul zur Horst-Meyer
47 1 Paul zur Horst-Meyer
* Install path: /opt/gitolite/.ssh/gitolite_admin_id_rsa
48 1 Paul zur Horst-Meyer
* using passphrase: no
49 1 Paul zur Horst-Meyer
50 1 Paul zur Horst-Meyer
h3. getting sources:
51 1 Paul zur Horst-Meyer
52 1 Paul zur Horst-Meyer
 wget https://github.com/sitaramc/gitolite/tarball/master -O gitolite.tar.gz
53 1 Paul zur Horst-Meyer
tar -xf gitolite.tar.gz
54 1 Paul zur Horst-Meyer
55 1 Paul zur Horst-Meyer
create _.profile_ file in git home directory and put content:
56 1 Paul zur Horst-Meyer
57 1 Paul zur Horst-Meyer
 PATH=/opt/gitolite/bin:$PATH
58 1 Paul zur Horst-Meyer
59 1 Paul zur Horst-Meyer
prepare setup and install gitolite
60 1 Paul zur Horst-Meyer
61 1 Paul zur Horst-Meyer
 source .profile
62 1 Paul zur Horst-Meyer
sitaramc-gitolite-d59bc35/src/gl-system-install
63 1 Paul zur Horst-Meyer
gl-setup -q ~/.ssh/gitolite_admin_id_rsa.pub
64 1 Paul zur Horst-Meyer
rm -rf sitaramc-gitolite-d59bc35 gitolite.tar.gz
65 1 Paul zur Horst-Meyer
exit
66 1 Paul zur Horst-Meyer
67 1 Paul zur Horst-Meyer
h2. give Redmine the administration key pair
68 1 Paul zur Horst-Meyer
69 1 Paul zur Horst-Meyer
 mkdir 0700 /opt/redmine/.ssh
70 1 Paul zur Horst-Meyer
cp /opt/gitolite/.ssh/gitolite_admin_id_rsa* /opt/redmine/.ssh
71 1 Paul zur Horst-Meyer
chown -R redmine:redmine /opt/redmine/.ssh
72 1 Paul zur Horst-Meyer
73 1 Paul zur Horst-Meyer
h2. Setup Redmine
74 1 Paul zur Horst-Meyer
75 1 Paul zur Horst-Meyer
... as _Redmine_ user
76 1 Paul zur Horst-Meyer
77 1 Paul zur Horst-Meyer
 su redmine
78 1 Paul zur Horst-Meyer
cd ~
79 1 Paul zur Horst-Meyer
80 1 Paul zur Horst-Meyer
h3. getting sources:
81 1 Paul zur Horst-Meyer
82 1 Paul zur Horst-Meyer
 wget https://github.com/redmine/redmine/tarball/1.3.2 -O redmine.tar.gz
83 1 Paul zur Horst-Meyer
tar -xf redmine.tar.gz
84 1 Paul zur Horst-Meyer
mv redmine-redmine-3490d2a/* .
85 1 Paul zur Horst-Meyer
rm -rf redmine-redmine-3490d2a redmine.tar.gz
86 1 Paul zur Horst-Meyer
87 4 Paul zur Horst-Meyer
add a MySQL user and a database for Redmine (find your own way :P).
88 4 Paul zur Horst-Meyer
Insert connection data in configuration file ("Production" part):
89 1 Paul zur Horst-Meyer
90 1 Paul zur Horst-Meyer
 cp config/database.yml.example config/database.yml
91 1 Paul zur Horst-Meyer
nano config/database.yml
92 1 Paul zur Horst-Meyer
93 1 Paul zur Horst-Meyer
setup tables and example data:
94 1 Paul zur Horst-Meyer
95 1 Paul zur Horst-Meyer
 rake generate_session_store
96 1 Paul zur Horst-Meyer
RAILS_ENV=production rake db:migrate
97 1 Paul zur Horst-Meyer
RAILS_ENV=production rake redmine:load_default_data
98 1 Paul zur Horst-Meyer
99 1 Paul zur Horst-Meyer
h2. Setup plugin to manage repositories
100 1 Paul zur Horst-Meyer
101 1 Paul zur Horst-Meyer
 cd vendor/plugins
102 1 Paul zur Horst-Meyer
103 1 Paul zur Horst-Meyer
h3. getting sources:
104 1 Paul zur Horst-Meyer
105 1 Paul zur Horst-Meyer
 wget https://github.com/ericpaulbishop/redmine_git_hosting/tarball/master -O redmine_plugin.tar.gz
106 1 Paul zur Horst-Meyer
tar -xf redmine_plugin.tar.gz
107 1 Paul zur Horst-Meyer
mv ericpaulbishop-redmine_git_hosting-fdca404 redmine_git_hosting
108 1 Paul zur Horst-Meyer
rm redmine_plugin.tar.gz
109 1 Paul zur Horst-Meyer
110 1 Paul zur Horst-Meyer
edit _redmine_git_hosting/init.rb_ file and customize like you prefare, e.g:
111 1 Paul zur Horst-Meyer
112 1 Paul zur Horst-Meyer
 httpServer 'yourRedmine.tld'
113 1 Paul zur Horst-Meyer
gitServer 'yourRedmine.tld'
114 1 Paul zur Horst-Meyer
115 1 Paul zur Horst-Meyer
comment out line 87 to disable Git Urls in repository view if you like
116 1 Paul zur Horst-Meyer
117 1 Paul zur Horst-Meyer
connect to localhost and accept the public key, cancel with ctrl+c and migrate the plugin
118 1 Paul zur Horst-Meyer
119 1 Paul zur Horst-Meyer
 cd ~
120 1 Paul zur Horst-Meyer
ssh localhost
121 1 Paul zur Horst-Meyer
RAILS_ENV=production rake db:migrate_plugins
122 1 Paul zur Horst-Meyer
123 1 Paul zur Horst-Meyer
install mongrel/rails patch
124 1 Paul zur Horst-Meyer
125 1 Paul zur Horst-Meyer
 cd ~/config/initializers/
126 1 Paul zur Horst-Meyer
wget http://www.redmine.org/attachments/download/6901/mongrel.rb
127 1 Paul zur Horst-Meyer
exit
128 1 Paul zur Horst-Meyer
129 1 Paul zur Horst-Meyer
h2. Prepare Mongrel
130 1 Paul zur Horst-Meyer
131 1 Paul zur Horst-Meyer
directories:
132 1 Paul zur Horst-Meyer
133 1 Paul zur Horst-Meyer
 mkdir /etc/mongrel
134 1 Paul zur Horst-Meyer
mkdir /var/run/mongrel
135 1 Paul zur Horst-Meyer
chown redmine:redmine /var/run/mongrel
136 1 Paul zur Horst-Meyer
137 1 Paul zur Horst-Meyer
 mkdir /var/log/mongrel
138 1 Paul zur Horst-Meyer
chown redmine:redmine /var/log/mongrel
139 1 Paul zur Horst-Meyer
140 1 Paul zur Horst-Meyer
configuration:
141 1 Paul zur Horst-Meyer
142 1 Paul zur Horst-Meyer
 mongrel_rails cluster::configure -e production -p 3000 -N 3 -c /opt/redmine -C /etc/mongrel/redmine-cluster.yml -a 127.0.0.1 --user redmine --group redmine -l /var/log/mongrel/mongrel.log -P /var/run/mongrel/mongrel.pid
143 1 Paul zur Horst-Meyer
144 1 Paul zur Horst-Meyer
auto start up:
145 1 Paul zur Horst-Meyer
146 3 Paul zur Horst-Meyer
 wget http://www.redmine.org/attachments/download/7397/redmine_mongrel.sh -O /etc/init.d/redmine
147 1 Paul zur Horst-Meyer
chmod +x /etc/init.d/redmine
148 1 Paul zur Horst-Meyer
update-rc.d redmine defaults
149 1 Paul zur Horst-Meyer
150 1 Paul zur Horst-Meyer
h2. Setup Nginx
151 1 Paul zur Horst-Meyer
152 1 Paul zur Horst-Meyer
creating own SSL Cert. chain (only for testing, example!):
153 1 Paul zur Horst-Meyer
154 1 Paul zur Horst-Meyer
 mkdir /etc/nginx/ssl
155 1 Paul zur Horst-Meyer
cd /etc/nginx/ssl
156 1 Paul zur Horst-Meyer
openssl genrsa -des3 -out server.key 1024
157 1 Paul zur Horst-Meyer
openssl req -new -key server.key -out server.csr
158 1 Paul zur Horst-Meyer
cp server.key server.key.org
159 1 Paul zur Horst-Meyer
openssl rsa -in server.key.org -out server.key
160 1 Paul zur Horst-Meyer
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
161 1 Paul zur Horst-Meyer
162 3 Paul zur Horst-Meyer
configuration:
163 1 Paul zur Horst-Meyer
164 3 Paul zur Horst-Meyer
 wget http://www.redmine.org/attachments/download/7398/default.txt -O /etc/nginx/sites-available/default 
165 3 Paul zur Horst-Meyer
166 3 Paul zur Horst-Meyer
just overwrite existing file.
167 3 Paul zur Horst-Meyer
168 1 Paul zur Horst-Meyer
h2. Setup Git-Daemon
169 1 Paul zur Horst-Meyer
170 1 Paul zur Horst-Meyer
171 3 Paul zur Horst-Meyer
 wget http://www.redmine.org/attachments/download/7399/git_daemon.txt -O /etc/init.d/git-daemon
172 3 Paul zur Horst-Meyer
chmod +x /etc/init.d/git-daemon
173 1 Paul zur Horst-Meyer
update-rc.d -f git-daemon defaults
174 5 Andrew Perry
175 5 Andrew Perry
176 5 Andrew Perry
h2. Setup mail server
177 5 Andrew Perry
178 5 Andrew Perry
 dpkg-reconfigure exim4-config
179 5 Andrew Perry
180 5 Andrew Perry
Select "internet site; mail is sent and received directly using SMTP" and otherwise put in a sane FQDN and email account for root email to be forwarded to
181 1 Paul zur Horst-Meyer
182 1 Paul zur Horst-Meyer
h1. Finished!
183 1 Paul zur Horst-Meyer
184 1 Paul zur Horst-Meyer
 reboot
185 1 Paul zur Horst-Meyer
186 1 Paul zur Horst-Meyer
Login at http://yourRedmine.tld with:
187 1 Paul zur Horst-Meyer
188 1 Paul zur Horst-Meyer
 Login: admin
189 1 Paul zur Horst-Meyer
password: admin