HowTo: installing latest GitLab

HowTo: installing latest GitLab

Basically, follow this guide. (+ Note that I already had running mysql and Nginx installation.)

Install pre-requisites

Install latest ruby. (Download source code and compile it, instead of using apt-get. Ruby version must be larger than 2.0.0)

Now we need to install the Bundler gem:

[/crayon]
And create a git user for GitLab to use:

[/crayon]

Installing the GitLab Shell

Download the GitLab shell with the following commands:

[/crayon]
You now have a copy of GitLab Shell 1.7.0, and the example config.yml is ready to go.

If you have a domain name pointed at this VPS, then you should take the time to edit config.yml to use this domain.

[/crayon]
Near the top there will be a line that looks like:

[/crayon]
Change the http://localhost/ portion to match your domain name. So if your domain is www.YOURDOMAIN.com the line should look like this:

[/crayon]
Now you can run the GitLab shell installer:

[/crayon]

Database Setup

We’ll set up GitLab to use a MySQL backend. The first step is to install MySQL with the below command. During the install process it will ask you to set a MySQL root password. Set it to whatever you like, but note it down as you will need it for the next steps.

[/crayon]
MySQL is now installed and the root password is set to the value you chose in the last step. We now need to create a MySQL user for GitLab to use. To do this we’ll first save the necessary SQL queries to a temporary file. Type:

[/crayon]
Paste in the following, changing the $password on the first line to a real password. Keep track of this password as this will be your GitLab’s database password.

[/crayon]
Now save the file and execute the following command (entering your MySQL root password from the first step at the prompt) to have MySQL execute your queries:

[/crayon]
To make sure your new MySQL user was created successfully let’s log in to mysql using the gitlab user:

[/crayon]
If you see some text followed by a:

[/crayon]
line then everything worked successfully. Go ahead and type:

[/crayon]
at the mysql> prompt to exit MySQL, and delete the tempfile file since it contains a password:

[/crayon]
At this point we have everything configured to install GitLab successfully, so let’s proceed with the installation:

[/crayon]
Just like we did with the GitLab shell set up, if you have a domain configured for your VPS we need to edit the config.yml to use that domain.

[/crayon]
Near the top of the file you should a text block that looks like the following:

[/crayon]
Change the host: entry to match your domain name. If your domain is www.YOURDOMAIN.com, then it should look like this:

[/crayon]
change these fields too

email_from:
email_display_name:

Let’s also set some linux file permissions, configure the git user’s Git config, and set up some GitLab config and directories for the git user:

[/crayon]
Now we need to tell GitLab to use the gitlab MySQL user we set up earlier. To do this, edit the config/database.yml file:

[/crayon]
Near the top there will be a section called production: which will contain username and password entries. By default it looks like this:

[/crayon]
Change the username and password entries to match the GitLab database user we set up earlier. So if the password you used for your GitLab MySQL user was $password the edited file should look like this:

[/crayon]
Save the file, and we’ll secure it so that other users of the server can’t see the password:

[/crayon]
Let’s install a few more needed gems (this step may take awhile):

[/crayon]
And run some final setup (type yes when it asks if you want to continue):

[/crayon]
After this finishes it will print a lot of information onscreen and at the end will show Administrator account created and give you your administrator credentials. It should look something like the below:

[/crayon]
Now let’s set GitLab to start up whenever your server boots:

[/crayon]
Pre-compile assets:

[/crayon]
Run the following to make sure everything is working:

[/crayon]
 

Setting Up NGINX

GitLab works with the nginx web server by default. If you already have your own web server such as Apache set up then these steps don’t apply. Check out these recipes for info on how to configure GitLab with other web servers. Otherwise follow these directions to install and configure nginx to work with GitLab:

[/crayon]
Edit /etc/nginx/sites-available/gitlab to use your domain name:

[/crayon]
A little ways from the top of the file you will see an entry server_name which is set to YOUR_SERVER_FQDN. As in the previous steps, replace the YOUR_SERVER_FQDN with your domain name. The original file looks like this:

[/crayon]
If your domain is www.YOURDOMAIN.com then you should change it to look like this:

[/crayon]
And restart nginx:

[/crayon]
Voila! You’re done. Connect to GitLab via your web browser using the Admin login and password from above (default user: admin@local.host, pass: 5iveL!fe) and enjoy GitLab.

If you are using a 512MB VPS then due to GitLab’s memory requirements it’s quite likely you will run into a 502 Bad Gateway error. If that’s the case, read on…

If there are no error messages and the data outputted by that command looks right then your GitLab install is working. Almost finished! Start up GitLab with this command:

[/crayon]

 

 

 

An unexpected error occurred (redis-cli returned 1)

modify redis server configuration

$ redis-cli stat | grep config_file

modify configuration

Leave a Reply