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

Paul zur Horst-Meyer, 2012-03-31 23:44

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 1 Paul zur Horst-Meyer
PS: i am sorry, but i don´t like to comment any part and command ob 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 1 Paul zur Horst-Meyer
 apt-get install imagemagick ruby ruby-dev libruby rubygems mysql-server libmysqlclient-dev libmagickwand-dev git sudo nginx
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 1 Paul zur Horst-Meyer
prepare database configuration for Redmine:
88 1 Paul zur Horst-Meyer
89 1 Paul zur Horst-Meyer
add a MySQL user and a database for Redmine (find your own way :P):
90 1 Paul zur Horst-Meyer
91 1 Paul zur Horst-Meyer
 cp config/database.yml.example config/database.yml
92 1 Paul zur Horst-Meyer
nano config/database.yml
93 1 Paul zur Horst-Meyer
94 1 Paul zur Horst-Meyer
setup tables and example data:
95 1 Paul zur Horst-Meyer
96 1 Paul zur Horst-Meyer
 rake generate_session_store
97 1 Paul zur Horst-Meyer
RAILS_ENV=production rake db:migrate
98 1 Paul zur Horst-Meyer
RAILS_ENV=production rake redmine:load_default_data
99 1 Paul zur Horst-Meyer
100 1 Paul zur Horst-Meyer
h2. Setup plugin to manage repositories
101 1 Paul zur Horst-Meyer
102 1 Paul zur Horst-Meyer
 cd vendor/plugins
103 1 Paul zur Horst-Meyer
104 1 Paul zur Horst-Meyer
h3. getting sources:
105 1 Paul zur Horst-Meyer
106 1 Paul zur Horst-Meyer
 wget https://github.com/ericpaulbishop/redmine_git_hosting/tarball/master -O redmine_plugin.tar.gz
107 1 Paul zur Horst-Meyer
tar -xf redmine_plugin.tar.gz
108 1 Paul zur Horst-Meyer
mv ericpaulbishop-redmine_git_hosting-fdca404 redmine_git_hosting
109 1 Paul zur Horst-Meyer
rm redmine_plugin.tar.gz
110 1 Paul zur Horst-Meyer
111 1 Paul zur Horst-Meyer
edit _redmine_git_hosting/init.rb_ file and customize like you prefare, e.g:
112 1 Paul zur Horst-Meyer
113 1 Paul zur Horst-Meyer
 httpServer 'yourRedmine.tld'
114 1 Paul zur Horst-Meyer
gitServer 'yourRedmine.tld'
115 1 Paul zur Horst-Meyer
116 1 Paul zur Horst-Meyer
comment out line 87 to disable Git Urls in repository view if you like
117 1 Paul zur Horst-Meyer
118 1 Paul zur Horst-Meyer
connect to localhost and accept the public key, cancel with ctrl+c and migrate the plugin
119 1 Paul zur Horst-Meyer
120 1 Paul zur Horst-Meyer
 cd ~
121 1 Paul zur Horst-Meyer
ssh localhost
122 1 Paul zur Horst-Meyer
RAILS_ENV=production rake db:migrate_plugins
123 1 Paul zur Horst-Meyer
124 1 Paul zur Horst-Meyer
install mongrel/rails patch
125 1 Paul zur Horst-Meyer
126 1 Paul zur Horst-Meyer
 cd ~/config/initializers/
127 1 Paul zur Horst-Meyer
wget http://www.redmine.org/attachments/download/6901/mongrel.rb
128 1 Paul zur Horst-Meyer
exit
129 1 Paul zur Horst-Meyer
130 1 Paul zur Horst-Meyer
h2. Prepare Mongrel
131 1 Paul zur Horst-Meyer
132 1 Paul zur Horst-Meyer
directories:
133 1 Paul zur Horst-Meyer
134 1 Paul zur Horst-Meyer
 mkdir /etc/mongrel
135 1 Paul zur Horst-Meyer
mkdir /var/run/mongrel
136 1 Paul zur Horst-Meyer
chown redmine:redmine /var/run/mongrel
137 1 Paul zur Horst-Meyer
138 1 Paul zur Horst-Meyer
 mkdir /var/log/mongrel
139 1 Paul zur Horst-Meyer
chown redmine:redmine /var/log/mongrel
140 1 Paul zur Horst-Meyer
141 1 Paul zur Horst-Meyer
configuration:
142 1 Paul zur Horst-Meyer
143 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
144 1 Paul zur Horst-Meyer
145 1 Paul zur Horst-Meyer
auto start up:
146 1 Paul zur Horst-Meyer
147 1 Paul zur Horst-Meyer
 download "Redmine start script"
148 1 Paul zur Horst-Meyer
chmod +x /etc/init.d/redmine
149 1 Paul zur Horst-Meyer
update-rc.d redmine defaults
150 1 Paul zur Horst-Meyer
151 1 Paul zur Horst-Meyer
h2. Setup Nginx
152 1 Paul zur Horst-Meyer
153 1 Paul zur Horst-Meyer
creating own SSL Cert. chain (only for testing, example!):
154 1 Paul zur Horst-Meyer
155 1 Paul zur Horst-Meyer
 mkdir /etc/nginx/ssl
156 1 Paul zur Horst-Meyer
cd /etc/nginx/ssl
157 1 Paul zur Horst-Meyer
openssl genrsa -des3 -out server.key 1024
158 1 Paul zur Horst-Meyer
openssl req -new -key server.key -out server.csr
159 1 Paul zur Horst-Meyer
cp server.key server.key.org
160 1 Paul zur Horst-Meyer
openssl rsa -in server.key.org -out server.key
161 1 Paul zur Horst-Meyer
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
162 1 Paul zur Horst-Meyer
163 1 Paul zur Horst-Meyer
download Nginx configuration and copy to _/etc/nginx/sites-available/default_, just overwrite existing file.
164 1 Paul zur Horst-Meyer
165 1 Paul zur Horst-Meyer
h2. Setup Git-Daemon
166 1 Paul zur Horst-Meyer
167 1 Paul zur Horst-Meyer
download "Git-Daemon start script" to _/etc/init.d/git-daemon_
168 1 Paul zur Horst-Meyer
169 1 Paul zur Horst-Meyer
 chmod +x /etc/init.d/git-daemon
170 1 Paul zur Horst-Meyer
update-rc.d -f git-daemon defaults
171 1 Paul zur Horst-Meyer
172 1 Paul zur Horst-Meyer
h1. Finished!
173 1 Paul zur Horst-Meyer
174 1 Paul zur Horst-Meyer
 reboot
175 1 Paul zur Horst-Meyer
176 1 Paul zur Horst-Meyer
Login at http://yourRedmine.tld with:
177 1 Paul zur Horst-Meyer
178 1 Paul zur Horst-Meyer
 Login: admin
179 1 Paul zur Horst-Meyer
password: admin