5

Hey SuperUser community, I'm new to this forum so I'll make this quick. I'm an amateur CentOS System Administrator. I'm teaching myself as I go, but I recently hit a stumbling block. I'm trying to install GitLab, but I want to install it on an Apache web server on my VPS.

I know that GitLab was built for nginx, but I honestly don't want to use it. I was wondering how I would be able to have a setup so that

  • mysite.com would retrieve the files (like index.html, folders with more files in them, etc.) in /var/www/html
  • lab.mysite.com would retrieve GitLab.

I've heard you're supposed to use a virtual host, but remember, I'm still an amateur at best with this kind of stuff, so if anyone here is kind enough to make a short step-by-step guide to do this, I'd appreciate this.

Note: Before I've been using this guide to install GitLab, however this is for Nginx, so I was wondering if I was to use this guide but then add onto it, or if I'm going about this all wrong.

I just wiped my VPS so I can start again. I know how to install LAMP, Git, and all that, so please tell me at what point in this 'step-by-step' guide I should.

Thanks a bunch, Miles.

1
  • PS: Sorry for my ignorance in advance! ;p May 1 '16 at 20:59
0

I have run Gitlabs before but never with Apache, however a quick Google search revealed a dearth of information. In general it looks like you need to install Gitlabs and Apache, edit the Gitlabs config, add the Apache user to the Gitlabs group, create a VirtualHosts file so that Apache will host Gitlabs instead of nginx, enable the new VirtualHosts file, modify Apache if necessary, and restart Apache and Gitlabs if necessary. These links[1] [2] [3] [4] [5] go into much greater detail and should help you.

0
3

I recently answered this, including some instructions here:

https://stackoverflow.com/a/41168476/1856589

Not sure this is considered reposting, but here are those instructions again:



By default GitLab will install nginx but usually won't add nginx to your system's service manager (service or systemctl). This makes it confusing when trying to enable Apache (Apache won't start due to default port 80 in use by nginx).

Assuming you've installed Gitlab according to the default install instructions, the Nginx service will now be managed by the gitlab-ctl service manager (which is installed when installed Gitlab).

To stop Nginx, run the following from a command line as root:

gitlab-ctl stop nginx

Now that port 80 is free, you can start Apache (don't forget to install Apache if it's not already / Instructions are for RHEL systems - modify accordingly for Ubuntu etc). Assumes you are root user:

yum install -y httpd;
systemctl start httpd;
systemctl enable httpd;

Let's edit the Gitlab config file to disable nginx and tell gitlab to use apache:

vi /etc/gitlab/gitlab.rb

Add either your domain or IP to the following:

external_url 'http://git.yourdomain.com/'

Find:

# web_server['external_users'] = []

Change to (don't forget to remove the leading '#'):

web_server['external_users'] = ['apache']

Find:

# nginx['enable'] = true

Change to:

nginx['enable'] = false

And finally we have to run a "recompile" with:

gitlab-ctl reconfigure

gitlab-ctl restart

Now the Apache config. When we installed Gitlab, it added a user group called gitlab-www. We need to allow the apache user access to that group. The following assumes you've installed apache and the user apache (48) exists:

To check which group gitlab installed itself under, you can run:

getent group

Now lets modify apache's user and add it to the gitlab-www group:

usermod apache --append --groups gitlab-www

Now we need an Apache Virtual Host to point to the gitlab install.

Add a virtual host to Apache's conf.d directory (this will create a new file):

vi /etc/httpd/conf.d/gitlab.conf

Add the following (tweak according to your needs):

<VirtualHost *:80>
    ServerName git.yourdomain.com
    ServerSignature Off

    ProxyPreserveHost On

    <Location />
      Order deny,allow
      Allow from all

      ProxyPassReverse http://127.0.0.1:8080
      ProxyPassReverse http://git.yourdomain.com/
    </Location>

    RewriteEngine on
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA]

    # needed for downloading attachments
    DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public

    ErrorLog /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log combined env=!dontlog
</VirtualHost>

... And now restart Apache:

systemctl start httpd

You may run into issues with things like selinux - You can set things to permissive for debugging purposes.

setenforce 0

I hope this helps someone!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.