PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/doc/install/installation.md

https://gitlab.com/fabien-archambault/gitlab-ci
Markdown | 264 lines | 161 code | 103 blank | 0 comment | 0 complexity | c2788f2daf9d3fe20e5a0843f0befc11 MD5 | raw file
  1. # Select Version to Install
  2. Make sure you view this installation guide from the branch (version) of GitLab CI you would like to install. In most cases
  3. this should be the highest numbered stable branch (example shown below).
  4. ![capture](http://i.imgur.com/fmdlXxa.png)
  5. If this is unclear check the [GitLab Blog](http://blog.gitlab.org/) for installation guide links by version.
  6. ## GitLab CI 7.9 requires GitLab 7.9 or newer
  7. other [requirements](requirements.md)
  8. # Setup:
  9. ## 1. Packages / Dependencies
  10. `sudo` is not installed on Debian by default. Make sure your system is
  11. up-to-date and install it.
  12. sudo apt-get update
  13. sudo apt-get upgrade
  14. **Note:**
  15. During this installation some files will need to be edited manually. If
  16. you are familiar with vim set it as default editor with the commands
  17. below. If you are not familiar with vim please skip this and keep using
  18. the default editor.
  19. # Install vim
  20. sudo apt-get install vim
  21. sudo update-alternatives --set editor /usr/bin/vim.basic
  22. Install the required packages:
  23. sudo apt-get install wget curl gcc checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql++-dev make build-essential zlib1g-dev openssh-server git-core libyaml-dev postfix libpq-dev libicu-dev openssl nodejs
  24. sudo apt-get install redis-server
  25. # 2. Ruby
  26. Download Ruby and compile it:
  27. mkdir /tmp/ruby && cd /tmp/ruby
  28. curl --progress http://cache.ruby-lang.org/pub/ruby/ruby-2.1.6.tar.bz2 | tar xj
  29. cd ruby-2.1.6/
  30. ./configure --disable-install-rdoc
  31. make
  32. sudo make install
  33. Install the Bundler Gem:
  34. sudo gem install bundler --no-ri --no-rdoc
  35. ## 3. GitLab CI user:
  36. sudo adduser --disabled-login --gecos 'GitLab CI' gitlab_ci
  37. ## 4. Prepare the database
  38. You can use either MySQL or PostgreSQL.
  39. ### MySQL
  40. # Install the database packages
  41. sudo apt-get install mysql-server mysql-client libmysqlclient-dev
  42. # Login to MySQL
  43. $ mysql -u root -p
  44. # Create the GitLab CI database
  45. mysql> CREATE DATABASE IF NOT EXISTS `gitlab_ci_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
  46. # Create the MySQL User change $password to a real password
  47. mysql> CREATE USER 'gitlab_ci'@'localhost' IDENTIFIED BY '$password';
  48. # Grant proper permissions to the MySQL User
  49. mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlab_ci_production`.* TO 'gitlab_ci'@'localhost';
  50. # Logout MYSQL
  51. mysql> exit;
  52. ### PostgreSQL
  53. # Install the database packages
  54. sudo apt-get install -y postgresql-9.1 libpq-dev
  55. # Login to PostgreSQL
  56. sudo -u postgres psql -d template1
  57. # Create a user for GitLab CI. We do not specify a password because we are using peer authentication.
  58. template1=# CREATE USER gitlab_ci;
  59. # Create the GitLab CI production database & grant all privileges on database
  60. template1=# CREATE DATABASE gitlab_ci_production OWNER gitlab_ci;
  61. # Quit the database session
  62. template1=# \q
  63. # Try connecting to the new database with the new user
  64. sudo -u gitlab_ci -H psql -d gitlab_ci_production
  65. ## 5. Get code
  66. cd /home/gitlab_ci/
  67. sudo -u gitlab_ci -H git clone https://gitlab.com/gitlab-org/gitlab-ci.git
  68. cd gitlab-ci
  69. sudo -u gitlab_ci -H git checkout 7-9-stable
  70. ## 6. Setup application
  71. # Edit application settings
  72. # Production
  73. sudo -u gitlab_ci -H cp config/application.yml.example config/application.yml
  74. sudo -u gitlab_ci -H editor config/application.yml
  75. # Development
  76. #sudo -u gitlab_ci -H cp config/application.yml.example.development config/application.yml
  77. # Edit web server settings
  78. sudo -u gitlab_ci -H cp config/unicorn.rb.example config/unicorn.rb
  79. sudo -u gitlab_ci -H editor config/unicorn.rb
  80. # Create socket and pid directories
  81. sudo -u gitlab_ci -H mkdir -p tmp/sockets/
  82. sudo chmod -R u+rwX tmp/sockets/
  83. sudo -u gitlab_ci -H mkdir -p tmp/pids/
  84. sudo chmod -R u+rwX tmp/pids/
  85. ### Install gems
  86. # For MySQL (note, the option says "without ... postgres")
  87. sudo -u gitlab_ci -H bundle install --without development test postgres --deployment
  88. # Or for PostgreSQL (note, the option says "without ... mysql")
  89. sudo -u gitlab_ci -H bundle install --without development test mysql --deployment
  90. ### Setup db
  91. # mysql
  92. sudo -u gitlab_ci -H cp config/database.yml.mysql config/database.yml
  93. # postgres
  94. sudo -u gitlab_ci -H cp config/database.yml.postgresql config/database.yml
  95. # Edit user/password (not necessary with default Postgres setup)
  96. sudo -u gitlab_ci -H editor config/database.yml
  97. # Setup tables
  98. sudo -u gitlab_ci -H bundle exec rake setup RAILS_ENV=production
  99. # Setup schedules
  100. sudo -u gitlab_ci -H bundle exec whenever -w RAILS_ENV=production
  101. ## 7. Install Init Script
  102. Copy the init script (will be /etc/init.d/gitlab_ci):
  103. sudo cp /home/gitlab_ci/gitlab-ci/lib/support/init.d/gitlab_ci /etc/init.d/gitlab_ci
  104. Make GitLab CI start on boot:
  105. sudo update-rc.d gitlab_ci defaults 21
  106. Start your GitLab CI instance:
  107. sudo service gitlab_ci start
  108. # or
  109. sudo /etc/init.d/gitlab_ci start
  110. # 8. Nginx
  111. ## Installation
  112. sudo apt-get install nginx
  113. ## Site Configuration
  114. Download an example site config:
  115. sudo cp /home/gitlab_ci/gitlab-ci/lib/support/nginx/gitlab_ci /etc/nginx/sites-available/gitlab_ci
  116. sudo ln -s /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-enabled/gitlab_ci
  117. Make sure to edit the config file to match your setup:
  118. # Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
  119. # to the IP address and fully-qualified domain name
  120. # of your host serving GitLab CI
  121. sudo editor /etc/nginx/sites-enabled/gitlab_ci
  122. ## Check your configuration
  123. sudo nginx -t
  124. ## Start nginx
  125. sudo /etc/init.d/nginx start
  126. # 9. GitLab OAuth2 application
  127. Go to the admin area of GitLab, to the `Application` section. Create an application for the GitLab CI
  128. For callback URL use: `http://ci.example.com/user_sessions/callback` if you use http, or `https://ci.example.com/user_sessions/callback` if you use https.
  129. When `app_id` and `app_secret` are generated add them to the GitLab CI config:
  130. ```
  131. production:
  132. gitlab_server:
  133. url: 'http://gitlab.example.com'
  134. app_id: XXXXXX
  135. app_secret: XXXXXX
  136. ```
  137. # 10. Runners
  138. Now you need Runners to process your builds.
  139. Checkout the [Gitlab Runner section](https://about.gitlab.com/gitlab-ci/#gitlab-runner) to install it
  140. # Done!
  141. Visit YOUR_SERVER for your first GitLab CI login.
  142. You will be asked to authorize with your GitLab credentials.
  143. **Enjoy!**
  144. ## Advanced settings
  145. ### SMTP email settings
  146. If you want to use SMTP do next:
  147. # Copy config file
  148. sudo -u gitlab_ci -H cp config/initializers/smtp_settings.rb.sample config/initializers/smtp_settings.rb
  149. # Edit it with your settings
  150. sudo -u gitlab_ci -H editor config/initializers/smtp_settings.rb
  151. Restart application
  152. ### Custom Redis Connection
  153. If you'd like Resque to connect to a Redis server on a non-standard port or on
  154. a different host, you can configure its connection string via the
  155. `config/resque.yml` file.
  156. # example
  157. production: redis://redis.example.tld:6379
  158. If you want to connect the Redis server via socket, then use the "unix:" URL scheme
  159. and the path to the Redis socket file in the `config/resque.yml` file.
  160. # example
  161. production: unix:/path/to/redis/socket