Commit 8f3adf9f03465c8610800a63e7d7e05adea36e29

Authored by randx
Committed by Dmitriy Zaporozhets
1 parent b6628b4a

Improved installation manual

Showing 1 changed file with 140 additions and 112 deletions   Show diff stats
doc/installation.md
... ... @@ -30,14 +30,6 @@ We recommend to use server with at least 1GB RAM for gitlab instance.
30 30  
31 31 ## This installation guide created for Debian/Ubuntu and properly tested.
32 32  
33   -The installation consists of 6 steps:
34   -
35   -1. Install packages / dependencies
36   -2. Install ruby
37   -3. Install Gitolite
38   -4. Install and configure GitLab.
39   -5. Start the web front-end
40   -6. Start a Resque worker (for background processing)
41 33  
42 34 ### IMPORTANT
43 35  
... ... @@ -47,6 +39,26 @@ Only create a GitHub Issue if you want a specific part of this installation guid
47 39  
48 40 Also read the [Read this before you submit an issue](https://github.com/gitlabhq/gitlabhq/wiki/Read-this-before-you-submit-an-issue) wiki page.
49 41  
  42 +
  43 +# Basic setup
  44 +
  45 +The basic installation will provide you a GitLab setup with options:
  46 +
  47 +1. ruby 1.9.3
  48 +2. mysql as main db
  49 +3. gitolite v3 fork by gitlab
  50 +4. nginx + unicorn
  51 +
  52 +The installation consists of next steps:
  53 +
  54 +1. Install packages / dependencies
  55 +2. Install ruby
  56 +3. Install Gitolite
  57 +4. Install mysql and create db
  58 +5. Install and configure GitLab.
  59 +6. nginx + unicorn
  60 +7. service gitlab
  61 +
50 62 > - - -
51 63 > The first 3 steps of this guide can be easily skipped by executing an install script:
52 64 >
... ... @@ -65,6 +77,7 @@ Also read the [Read this before you submit an issue](https://github.com/gitlabhq
65 77 > for more detailed instructions read the HOWTO section of [the script](https://github.com/gitlabhq/gitlab-recipes/blob/master/install/debian_ubuntu_aws.sh)
66 78 > - - -
67 79  
  80 +
68 81 # 1. Install packages
69 82  
70 83 *Keep in mind that `sudo` is not installed on Debian by default. You should install it as root:*
... ... @@ -78,54 +91,6 @@ Now install the required packages:
78 91  
79 92 sudo apt-get install -y wget curl gcc checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh-server git-core python-dev python-pip libyaml-dev postfix libpq-dev
80 93  
81   -
82   -# Database
83   -
84   -## SQLite
85   -
86   - sudo apt-get install -y sqlite3 libsqlite3-dev
87   -
88   -## MySQL
89   -
90   - sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
91   -
92   - # Login to MySQL
93   - $ mysql -u root -p
94   -
95   - # Create the GitLab production database
96   - mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
97   -
98   - # Create the MySQL User change $password to a real password
99   - mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
100   -
101   - # Grant proper permissions to the MySQL User
102   - mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
103   -
104   -
105   -## PostgreSQL
106   -
107   - sudo apt-get install -y postgresql-9.2 postgresql-server-dev-9.2
108   -
109   - # Connect to database server
110   - sudo -u postgres psql -d template1
111   -
112   - # Add a user called gitlab. Change $password to a real password
113   - template1=# CREATE USER gitlab WITH PASSWORD '$password';
114   -
115   - # Create the GitLab production database
116   - template1=# CREATE DATABASE IF NOT EXISTS gitlabhq_production;
117   -
118   - # Grant all privileges on database
119   - template1=# GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production to gitlab;
120   -
121   - # Quit from PostgreSQL server
122   - template1=# \q
123   -
124   - # Try connect to new database
125   - $ su - gitlab
126   - $ psql -d gitlabhq_production -U gitlab
127   -
128   -
129 94 # 2. Install Ruby
130 95  
131 96 wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
... ... @@ -201,7 +166,25 @@ Permissions:
201 166 Check the [Trouble Shooting Guide](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide)
202 167 and ensure you have followed all of the above steps carefully.
203 168  
204   -# 4. Clone GitLab source and install prerequisites
  169 +
  170 +# 4. Mysql database
  171 +
  172 + sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
  173 +
  174 + # Login to MySQL
  175 + $ mysql -u root -p
  176 +
  177 + # Create the GitLab production database
  178 + mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
  179 +
  180 + # Create the MySQL User change $password to a real password
  181 + mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
  182 +
  183 + # Grant proper permissions to the MySQL User
  184 + mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
  185 +
  186 +
  187 +# 5. Clone GitLab source and install prerequisites
205 188  
206 189 sudo gem install charlock_holmes --version '0.6.8'
207 190 sudo pip install pygments
... ... @@ -220,30 +203,15 @@ and ensure you have followed all of the above steps carefully.
220 203 # Rename config files
221 204 sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
222 205  
223   -#### Select the database you want to use
224   -
225   - # SQLite
226   - sudo -u gitlab cp config/database.yml.sqlite config/database.yml
227   -
228   - # Mysql
229   - sudo -u gitlab cp config/database.yml.mysql config/database.yml
230   -
231   - # PostgreSQL
232   - sudo -u gitlab cp config/database.yml.postgres config/database.yml
233   -
  206 + # Copy mysql db config
234 207 # make sure to update username/password in config/database.yml
  208 + sudo -u gitlab cp config/database.yml.mysql config/database.yml
235 209  
236 210 #### Install gems
237 211  
238 212 # mysql
239 213 sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment
240 214  
241   - # or postgres
242   - sudo -u gitlab -H bundle install --without development test sqlite mysql --deployment
243   -
244   - # or sqlite
245   - sudo -u gitlab -H bundle install --without development test mysql postgres --deployment
246   -
247 215 #### Setup database
248 216  
249 217 sudo -u gitlab bundle exec rake gitlab:app:setup RAILS_ENV=production
... ... @@ -277,30 +245,57 @@ Checking status:
277 245  
278 246 If you got all YES - congratulations! You can go to the next step.
279 247  
280   -# 5. Start the web server
  248 +# 6. nginx + unicorn
  249 +
  250 +## 1. Unicorn
  251 +
  252 + cd /home/gitlab/gitlab
  253 + sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb
  254 +
  255 +## 2. Nginx
  256 +
  257 + # Install first
  258 + sudo apt-get install nginx
  259 +
  260 + # Add GitLab to nginx sites & change with your host specific settings
  261 + sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/
  262 + sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
  263 +
  264 + # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
  265 + # to the IP address and fully-qualified domain name
  266 + # of the host serving GitLab.
  267 + sudo vim /etc/nginx/sites-enabled/gitlab
  268 +
  269 + # Restart nginx:
  270 + sudo /etc/init.d/nginx restart
281 271  
282   -Application can be started with next command:
283 272  
284   - # For test purposes
285   - sudo -u gitlab bundle exec rails s -e production
286 273  
287   - # As daemon
288   - sudo -u gitlab bundle exec rails s -e production -d
  274 +# 7. service gitlab
  275 +
  276 +Create init script in /etc/init.d/gitlab:
  277 +
  278 + sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
  279 + sudo chmod +x /etc/init.d/gitlab
  280 +
  281 +GitLab autostart:
  282 +
  283 + sudo update-rc.d gitlab defaults 21
  284 +
  285 +Now you can start GitLab like:
  286 +
  287 + sudo service gitlab start
  288 +
289 289  
290 290 You can login via web using admin generated with setup:
291 291  
292 292 admin@local.host
293 293 5iveL!fe
294 294  
295   -# 6. Run Resque process (for processing job queue).
296 295  
297   - # Manually
298   - sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes
299 296  
300   - # GitLab start script
301   - sudo -u gitlab ./resque.sh
302   - # if you run this as root /home/gitlab/gitlab/tmp/pids/resque_worker.pid will be owned by root
303   - # causing the resque worker not to start via init script on next boot/service restart
  297 +# Advanced setup tips:
  298 +
304 299  
305 300 ## Customizing Resque's Redis connection
306 301  
... ... @@ -313,42 +308,75 @@ a different host, you can configure its connection string in the
313 308 **Ok - we have a working application now. **
314 309 **But keep going - there are some things that should be done **
315 310  
316   -# Nginx && Unicorn
317 311  
318   -## 1. Unicorn
  312 +# Database
319 313  
320   - cd /home/gitlab/gitlab
321   - sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb
322   - sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D
  314 +## SQLite
323 315  
324   -## 2. Nginx
  316 + sudo apt-get install -y sqlite3 libsqlite3-dev
325 317  
326   - # Install first
327   - sudo apt-get install nginx
  318 +## MySQL
328 319  
329   - # Add GitLab to nginx sites & change with your host specific settings
330   - sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab -P /etc/nginx/sites-available/
331   - sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
  320 + sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
332 321  
333   - # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
334   - # to the IP address and fully-qualified domain name
335   - # of the host serving GitLab.
336   - sudo vim /etc/nginx/sites-enabled/gitlab
  322 + # Login to MySQL
  323 + $ mysql -u root -p
337 324  
338   - # Restart nginx:
339   - sudo /etc/init.d/nginx restart
  325 + # Create the GitLab production database
  326 + mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
340 327  
341   -## 3. Init script
  328 + # Create the MySQL User change $password to a real password
  329 + mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
342 330  
343   -Create init script in /etc/init.d/gitlab:
  331 + # Grant proper permissions to the MySQL User
  332 + mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
344 333  
345   - sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab -P /etc/init.d/
346   - sudo chmod +x /etc/init.d/gitlab
347 334  
348   -GitLab autostart:
  335 +## PostgreSQL
349 336  
350   - sudo update-rc.d gitlab defaults 21
  337 + sudo apt-get install -y postgresql-9.2 postgresql-server-dev-9.2
  338 +
  339 + # Connect to database server
  340 + sudo -u postgres psql -d template1
  341 +
  342 + # Add a user called gitlab. Change $password to a real password
  343 + template1=# CREATE USER gitlab WITH PASSWORD '$password';
  344 +
  345 + # Create the GitLab production database
  346 + template1=# CREATE DATABASE IF NOT EXISTS gitlabhq_production;
  347 +
  348 + # Grant all privileges on database
  349 + template1=# GRANT ALL PRIVILEGES ON DATABASE gitlabhq_production to gitlab;
  350 +
  351 + # Quit from PostgreSQL server
  352 + template1=# \q
  353 +
  354 + # Try connect to new database
  355 + $ su - gitlab
  356 + $ psql -d gitlabhq_production -U gitlab
  357 +
  358 +
  359 +
  360 +#### Select the database you want to use
  361 +
  362 + # SQLite
  363 + sudo -u gitlab cp config/database.yml.sqlite config/database.yml
  364 +
  365 + # Mysql
  366 + sudo -u gitlab cp config/database.yml.mysql config/database.yml
  367 +
  368 + # PostgreSQL
  369 + sudo -u gitlab cp config/database.yml.postgres config/database.yml
351 370  
352   -Now you can start/restart/stop GitLab like:
  371 + # make sure to update username/password in config/database.yml
353 372  
354   - sudo /etc/init.d/gitlab restart
  373 +#### Install gems
  374 +
  375 + # mysql
  376 + sudo -u gitlab -H bundle install --without development test sqlite postgres --deployment
  377 +
  378 + # or postgres
  379 + sudo -u gitlab -H bundle install --without development test sqlite mysql --deployment
  380 +
  381 + # or sqlite
  382 + sudo -u gitlab -H bundle install --without development test mysql postgres --deployment
... ...