Lot of Conditions – Install GitLab on Ubuntu on Nginx Subdirectory HP Cloud. It is possible to install Gitlab in Subdirectory on Nginx but is Complicated. You should be an advanced user and have a good server admin for the server, particularly if the root has WordPress. Nginx will need fresh compiling again. It is not really very easy. Most of the websites nowadays in favor of using subdirectory instead of subdomain due to increased number of HTTPS and HSTS websites.
Install GitLab on Ubuntu on Nginx Subdirectory (HP Cloud)
If it is HP Cloud / OpenStack installation, take a snapshot before proceeding. We are using Nginx as a Web server to host Rails app with Nginx and Passenger. Just the commands :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | apt update -y && apt upgrade # apt-get update -y && apt-get upgrade sudo useradd git -md /home/git -s /bin/bash sudo passwd git sudo nano /etc/sudoers ## check/add these lines # root ALL=(ALL:ALL) ALL # git ALL=(ALL:ALL) ALL ## we gave sudo privilege to git. you can add username if you want. # username ALL=(ALL:ALL) ALL ## end comment su -git sudo apt-get install curl git build-essential libgtk2.0-dev libmysqlclient-dev mysql-server dialog zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev python-docutils sysv-rc-conf nano ~/.gemrc # paste it # gem: --no-ri --no-rdoc # save and exit nano sudo apt-get install ruby ruby-dev && sudo gem install rails sudo apt-get install python-software-properties sudo apt-add-repository ppa:brightbox/ruby-ng sudo apt-get update -y sudo apt-get install ruby2.1 ruby2.1-dev sudo gem install rails sudo service redis-server restart && sudo sysv-rc-conf redis-server on git config --global user.name "GitLab" # edit git config --global user.email "gitlab@localhost.tld" git clone https://github.com/gitlabhq/gitlab-shell.git cd gitlab-shell/ # change according to need git checkout -b 1.8.5 v1.8.5 cp config.yml.example config.yml nano config.yml # edit the line gitlab_url: to indicate your subdomain with domain name ./bin/install git clone https://github.com/gitlabhq/gitlabhq.git gitlab cd gitlab # tested version git checkout -b 6.6.5 v6.6.5 cp config/gitlab.yml.example config/gitlab.yml nano config/gitlab.yml # host: www.something.tld # https: false or true # relative_url_root: /subdir_name ## change subdir_name to real nano config/application.rb # config.relative_url_root = "/subdir_name" # ENV['RAILS_RELATIVE_URL_ROOT'] = "/subdir_name" cp config/database.yml.mysql config/database.yml nano config/database.yml # username: root # password: "yours" bundle install --deployment --without development test postgres mkdir /home/git/gitlab/tmp/pids && mkdir /home/git/gitlab/public/uploads rake db:create RAILS_ENV=production rake gitlab:setup RAILS_ENV=production wget https://gist.githubusercontent.com/AbhishekGhosh/77ffb178005b70eb694f/raw/943c3209df9621ca6c196d513fb4209ae7165b1f/gitlab.sh # read it to edit # nano gitlab.sh chmod +x gitlab.sh sudo cp gitlab.sh /etc/init.d/gitlab sudo chmod 744 /etc/init.d/gitlab sudo sysv-rc-conf gitlab on sudo service gitlab start sudo gem install passenger && sudo passenger-install-nginx-module # select option in prompt carefully # edit path wget https://gist.githubusercontent.com/AbhishekGhosh/2113e134b3e91b34f300/raw/9776e6bedec87bc8a333b7cdcc3f0405b4cb31b2/nginx sudo chown www-data:www-data /opt/nginx -R sudo chmod 775 /opt/nginx -R sudo mv nginx /etc/init.d/ sudo chmod 755 /etc/init.d/nginx sudo chown root:root /etc/init.d/nginx sudo sysv-rc-conf nginx on nginx -t # service nginx start |
Now configuring Nginx’s nginx.conf
file :
---
1 2 3 4 5 6 7 8 | location ~ ^/gitlab { root /home/git/gitlab/public; passenger_app_root /home/git/gitlab; passenger_enabled on; rails_env production; access_log /opt/nginx/logs/gitlab.access.log; error_log /opt/nginx/logs/gitlab.error.log; } |
1 2 3 | cd /home/git/gitlab sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production sudo service nginx restart |
Point your browser to subdir to check whether its working or not. Debugging will be needed. We read it somewhere in a Jap website with Google Translate for our internal need.
Tagged With gitlab 8 subdir , gitlab https subdirectory , gitlab nginx subdir , gitlab subfolder ngix , paperuri:(f5a42fdee605ea283242576b6876440c)