|
| 1 | +``` |
| 2 | +Distribution : Ubuntu 14.04, Ubuntu 12.04, Debian 7.4 |
| 3 | +GitLab version : 6.9+ |
| 4 | +Web Server : Apache, Nginx |
| 5 | +Init system : upstart, sysvinit |
| 6 | +Database : PostgreSQL |
| 7 | +Contributors : @crohr |
| 8 | +Additional Notes : This install guide uses packages generated on https://pkgr.io |
| 9 | +``` |
| 10 | + |
| 11 | +## Overview |
| 12 | + |
| 13 | +This install guide makes use of prepackaged versions of Gitlab, available on <https://pkgr.io/apps/gitlabhq/gitlabhq>. |
| 14 | + |
| 15 | +### Important Notes |
| 16 | + |
| 17 | +The following steps have been known to work and should be followed from up to bottom. |
| 18 | +If you deviate from this guide, do it with caution and make sure you don't violate |
| 19 | +any assumptions GitLab makes about its environment. |
| 20 | + |
| 21 | + |
| 22 | +#### If you find a bug |
| 23 | + |
| 24 | +If you find a bug/error in this guide please submit an issue or a Merge Request |
| 25 | +following the contribution guide (see [CONTRIBUTING.md](https://gitlab.com/gitlab-org/gitlab-recipes/blob/master/CONTRIBUTING.md)). |
| 26 | + |
| 27 | +- - - |
| 28 | + |
| 29 | +The GitLab installation consists of setting up the following components: |
| 30 | + |
| 31 | +1. Install the package |
| 32 | +1. Setup the peripheral services (mail, postgres, redis) |
| 33 | +1. Configure the package |
| 34 | +1. Web server |
| 35 | +1. Maintenance |
| 36 | + |
| 37 | +**This guide assumes that you run every command as root.** |
| 38 | + |
| 39 | +## 1. Install the package |
| 40 | + |
| 41 | +We assume that you're starting from a clean install of any of the supported distributions. Then, use the section dedicated to your distribution to install the package. |
| 42 | + |
| 43 | +### Ubuntu Trusty 14.04 |
| 44 | + |
| 45 | +```shell |
| 46 | +wget -qO - https://deb.pkgr.io/key | apt-key add - |
| 47 | +echo "deb https://deb.pkgr.io/gitlabhq/gitlabhq trusty 6-9-stable" | tee -a /etc/apt/sources.list.d/gitlabhq.list |
| 48 | +``` |
| 49 | + |
| 50 | +### Ubuntu Precise 12.04 |
| 51 | + |
| 52 | +```shell |
| 53 | +wget -qO - https://deb.pkgr.io/key | apt-key add - |
| 54 | +echo "deb https://deb.pkgr.io/gitlabhq/gitlabhq precise 6-9-stable" | tee -a /etc/apt/sources.list.d/gitlabhq.list |
| 55 | +``` |
| 56 | + |
| 57 | +### Debian Wheezy 7.4 |
| 58 | + |
| 59 | +```shell |
| 60 | +wget -qO - https://deb.pkgr.io/key | apt-key add - |
| 61 | +echo "deb https://deb.pkgr.io/gitlabhq/gitlabhq wheezy 6-9-stable" | tee -a /etc/apt/sources.list.d/gitlabhq.list |
| 62 | +``` |
| 63 | + |
| 64 | +For all distributions, install the package by doing: |
| 65 | + |
| 66 | +```shell |
| 67 | +apt-get update |
| 68 | +apt-get install gitlab-ce |
| 69 | +``` |
| 70 | + |
| 71 | +## 2. Setup the peripheral services |
| 72 | + |
| 73 | +GitLab needs a running mail server, redis server, and postgres server. Let's install that: |
| 74 | + |
| 75 | +```shell |
| 76 | +apt-get install -y postgresql postgresql-contrib redis-server postfix ruby1.9.1 |
| 77 | +``` |
| 78 | + |
| 79 | +Now create a new postgres user and database: |
| 80 | + |
| 81 | +```shell |
| 82 | +echo "CREATE USER \"user\" SUPERUSER PASSWORD 'pass';" | su - postgres -c psql && \ |
| 83 | + echo "CREATE DATABASE gitlabhq;" | su - postgres -c psql && \ |
| 84 | + echo "GRANT ALL PRIVILEGES ON DATABASE \"gitlabhq\" TO \"user\";" | su - postgres -c psql |
| 85 | +``` |
| 86 | + |
| 87 | +## 3. Configure the package |
| 88 | + |
| 89 | +All packages come with a command line utility to help with various aspects of GitLab. It closely mirrors the heroku toolbelt, so if you ever deployed an app on Heroku you should be at home. |
| 90 | + |
| 91 | +In the rest of the guide, we will assume that the `SERVER_HOST` variable contains the hostname you will be using for GitLab. e.g. `SERVER_HOST=example.com` |
| 92 | + |
| 93 | +Set the url corresponding to the database we just created: |
| 94 | + |
| 95 | + gitlab-ce config:set DATABASE_URL=postgres://user:[email protected]/gitlabhq |
| 96 | + |
| 97 | +Set the url to the redis server: |
| 98 | + |
| 99 | + gitlab-ce config:set REDIS_URL=redis://127.0.0.1:6379 |
| 100 | + |
| 101 | +Set the url to your GitLab server: |
| 102 | + |
| 103 | + gitlab-ce config:set GITLAB_URL="http://${SERVER_HOST}" |
| 104 | + |
| 105 | +Set the port on which the ruby server will listen (defaults to 6000): |
| 106 | + |
| 107 | + gitlab-ce config:set PORT=6000 |
| 108 | + |
| 109 | +You can now configure `gitlab-shell`: |
| 110 | + |
| 111 | + gitlab-ce run rake gitlab:shell:install[v1.9.4] |
| 112 | + |
| 113 | +Finally, initialize the database: |
| 114 | + |
| 115 | + gitlab-ce run rake db:schema:load db:seed_fu |
| 116 | + |
| 117 | +And create the initialization scripts for the web and worker processes: |
| 118 | + |
| 119 | + gitlab-ce scale web=1 worker=1 |
| 120 | + |
| 121 | +## 4. Web Server |
| 122 | + |
| 123 | +### NginX |
| 124 | + |
| 125 | +```shell |
| 126 | +apt-get install -y nginx |
| 127 | + |
| 128 | +cat > /etc/nginx/sites-available/default <<EOF |
| 129 | +server { |
| 130 | + listen 80; |
| 131 | + server_name ${SERVER_HOST}; |
| 132 | + location / { |
| 133 | + proxy_pass http://localhost:6000; |
| 134 | + } |
| 135 | +} |
| 136 | +EOF |
| 137 | + |
| 138 | +service nginx restart |
| 139 | +``` |
| 140 | + |
| 141 | +### Apache |
| 142 | + |
| 143 | +```shell |
| 144 | +apt-get install -y apache2 |
| 145 | +sudo a2enmod proxy_http |
| 146 | +# setup apache configuration |
| 147 | +cat > /etc/apache2/sites-available/default <<EOF |
| 148 | +<VirtualHost *:80> |
| 149 | + ServerName ${SERVER_HOST} |
| 150 | + <Location /> |
| 151 | + ProxyPass http://localhost:6000/ |
| 152 | + </Location> |
| 153 | +</VirtualHost> |
| 154 | +EOF |
| 155 | +# restart apache |
| 156 | +sudo service apache2 restart |
| 157 | +``` |
| 158 | + |
| 159 | +## Done! |
| 160 | + |
| 161 | +Visit YOUR_SERVER in your web browser for your first GitLab login. |
| 162 | +The setup has created an admin account for you. You can use it to log in: |
| 163 | + |
| 164 | + root |
| 165 | + 5iveL!fe |
| 166 | + |
| 167 | +**Important Note:** |
| 168 | +Please go over to your profile page and immediately change the password, so |
| 169 | +nobody can access your GitLab by using this login information later on. |
| 170 | + |
| 171 | +## Maintenance |
| 172 | + |
| 173 | +If you wish to further configure GitLab, you can copy the example gitlab.yml configuration file to `/etc/gitlab-ce`, and edit it at your convenience. It will not be overwritten when you upgrade your GitLab installation: |
| 174 | + |
| 175 | + gitlab-ce run cp config/gitlab.yml /etc/gitlab-ce/ && chmod 0640 /etc/gitlab-ce/gitlab.yml |
| 176 | + vi /etc/gitlab-ce/gitlab.yml # edit any setting and save |
| 177 | + gitlab-ce config:set GITLAB_CONFIG=/etc/gitlab-ce/gitlab.yml |
| 178 | + service gitlab-ce restart |
| 179 | + |
| 180 | +If you need to upgrade to a newer version, run the following commands: |
| 181 | + |
| 182 | + apt-get update |
| 183 | + apt-get install gitlab-ce |
| 184 | + gitlab-ce run rake db:migrate |
| 185 | + service gitlab-ce restart |
| 186 | + |
| 187 | +You can find out about all the latest releases at <https://pkgr.io/apps/gitlabhq/gitlabhq>. |
| 188 | + |
| 189 | +**Enjoy!** |
0 commit comments