Notebook (Posts about ruby)/categories/cat_ruby.atom2019-05-05T21:20:57ZToni MüllerNikolaGitLab: Changing the URL/posts/gitlab-changing-the-url/2013-11-23T17:22:00+01:002013-11-23T17:22:00+01:00Toni Mueller<div><p>Recently, I had the problem of moving my <a href="http://gitlab.org">GitLab</a>
installation from one URL to another. I guess the problem will hit
many people every once in a while. On
<a href="http://stackoverflow.com">StackOverflow</a>, someone posted half of the
<a href="http://stackoverflow.com/questions/20023573/how-to-change-nginx-site-url">answer</a>.</p>
<p>Make a backup and stop GitLab first! Then:</p>
<p>Quote:</p>
<ol>
<li>
<p>In your application.rb file:</p>
<pre class="code literal-block"><span></span>config.relative_url_root = "/gitlab"
</pre>
</li>
<li>
<p>In your gitlab.yml file:</p>
<pre class="code literal-block"><span></span>relative_url_root: /gitlab
</pre>
</li>
<li>
<p>In your unicorn.rb:</p>
<pre class="code literal-block"><span></span>ENV["RAILS_RELATIVE_URL_ROOT"] = "/gitlab"
</pre>
</li>
</ol>
<p>You also need to re-configure your web server appripriately.</p>
<p>Now... that does part of the job, but after doing it, I could not
properly reach nor use my GitLab site. The two remaining issues are
(a) adjusting the URLs in the database, and (b) updating the assets
cache. Here are the remaining bits, assuming that you are on MySQL
(adapt for other database engines, accordingly):</p>
<pre class="code literal-block"><span></span><span class="nt">mysql</span><span class="o">></span> <span class="nt">update</span> <span class="nt">events</span> <span class="nt">set</span> <span class="nt">data</span> <span class="o">=</span> <span class="nt">replace</span><span class="o">(</span><span class="nt">data</span><span class="o">,</span> <span class="s2">"http://1.1.1.1/"</span><span class="o">,</span> <span class="s2">"http://1.1.1.1/gitlab/"</span><span class="o">);</span>
</pre>
<p>Next, as the appropriate user, do this:</p>
<pre class="code literal-block"><span></span>$ rake gitlab:satellites:create <span class="nv">RAILS_ENV</span><span class="o">=</span>production
$ rake assets:clean <span class="nv">RAILS_ENV</span><span class="o">=</span>production
$ rake assets:precompile <span class="nv">RAILS_ENV</span><span class="o">=</span>production
</pre>
<p>Then restart GitLab.</p>
<p>If you omit the recompiling of the assets, that will yield you broken
icons, or, if you simply deleted them, a lot of 502s, until Rails was
able to compile them.</p>
<p>At this point, you have access to your projects using the web, but SSH
access does not yet work. You will see "Access denied" message. To fix
that, you have to
<a href="http://stackoverflow.com/questions/15444483/gitlab-shell-git-push-u-origin-master-fatal-the-remote-end-hung-up-unexp/15504051#15504051">update your <code>gitlab-shell</code> configuration</a>. Then
put this in your <code>config.yml</code>:</p>
<pre class="code literal-block"><span></span>gitlab_url: "http://1.1.1.1/gitlab"
</pre>
<p>This URL must reflect the new URL you have chosen. After that,
re-install <code>gitlab-shell</code>.</p>
<p>Thanks to <code><rikurrr></code> for the idea of directly looking into the
database.</p></div>