Ln-s/usr/local/bin/ruby/usr/bin/ruby ln-s/usr/local/bin/gem/usr/bin/gem ln-s/usr/ local/bin/bundle/usr/bin/bundle2.3 install Python2.7.2
Follow http://tz100.me/135.html.
3. Create a Git user
useradd -c 'GitLab' git
Mongodo
Add a row
Git ALL = (ALL) NOPASSWD: ALL
4. Install Gitlab-Shell
Download gitlab-shell
cd /home/gitsudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git
Switch to the stable gitlab-shell version suitable for gitlab5.1
cd /home/git/gitlab-shellsudo -u git -H git checkout v1.3.0sudo -u git -H cp config.yml.example config.yml
Copy the configuration file
sudo -u git -H cp config.yml.example config.yml
Edit the configuration file and change the line "gitlab_url: http: // localhost/" to your domain name or IP address.
Note: I used IP addresses for testing.
sudo -u git -H vi config.yml
As shown in:
Note: Do not remove the last part of the URL!
Install gitlab-shell
sudo -u git -H ./bin/install
The installation result page is as follows:
5. Create a database (based on mysql)
yum install mysql mysql-devel mysql-server -y
Start mysql and set the password
Service mysqld startmysqladmin-u root password 'your password'
Connect to mysql for database settings
mysql -u root -p
=
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';mysql> \q
Test connection
[root@mytest123 gitlab-shell]# sudo -u git -H mysql -u gitlab -p -D gitlabhq_productionEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.0.95 Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> \q
6. Install Gitlab
Download the source code and switch to stable version 5.1
cd /home/gitsudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlabcd /home/git/gitlabsudo -u git -H git checkout 5-1-stable
Configure
cd /home/git/gitlabsudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
Edit the gitlab. yml file and change host: localhost to your domain name or IP address (IP Address used ),
sudo -u git -H vi config/gitlab.yml
Grant the GIT user the required GITLAB directory and permissions
[root@mytest123 gitlab]# sudo chown -R git -R log [root@mytest123 gitlab]# sudo chown -R git -R tmp[root@mytest123 gitlab]# sudo chmod -R u+rwX log/[root@mytest123 gitlab]# sudo chmod -R u+rwX tmp/
Create a satellites directory
# sudo -u git -H mkdir /home/git/gitlab-satellites
Create a PID directory and grant permissions
sudo -u git -H mkdir tmp/pids/sudo -u git -H mkdir tmp/sockets/sudo chmod -R u+rwX tmp/pids/sudo chmod -R u+rwX tmp/sockets/
Create the upload directory. If the directory is not set up, the backup function will fail.
sudo -u git -H mkdir public/uploadssudo chmod -R u+rwX public/uploads
Copy the PUma configuration file
sudo -u git -H cp config/puma.rb.example config/puma.rb
Copy the database configuration file and edit and modify the username and password in the file to the database user and password you just created.
sudo -u git cp config/database.yml.mysql config/database.ymlsudo -u git -H vi config/database.yml
:
Install the required Gems
cd /home/git/gitlabsudo gem install charlock_holmes --version '0.6.9'sudo -u git -H bundle install --deployment --without development test postgres
Bundle install will install a lot of dependent packages. wait patiently and give two images.
Configure global variables for GIT users
sudo -u git -H git config --global user.name "GitLab"sudo -u git -H git config --global user.email "gitlab@YOUR_DOMAIN_NAME"
Start redis
Note: I do not understand why redis is needed. It is said that advanced features are required.
service redis start
Initialize Database
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
If no error occurs, the default gitlab user and password will appear. Record the password so that you can log onInstall the Startup Script
curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab
chmod +x /etc/init.d/gitlab
Run check
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=productionsudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
If the check fails, do not start it. Fix it based on the check result. The red color of the operating system does not matter.
If
Because redis is not started,
service gitlab start
Run the check again.
Start
sudo service mysqld startsudo service redis startsudo service gitlab start
Note: If the preceding user and password are displayed, the Gitlab installation in this step will be successful, but it can only use port 3000 and nginx, that is to say, gitlab-shell cannot be called, so it has not been fully called;
If it is acute, you can start debugging first, but I suggest you do not start it until nginx debugging is complete.
bundle exec rails s -e production
Code:
[root@mytest123 ~]# su -gitsu: invalid option -- gTry `su --help' for more information.[root@mytest123 ~]# su - git[git@mytest123 ~]$ cd gitlab[git@mytest123 gitlab]$ bundle exec rails s -e production -d/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /home/git/gitlab/vendor/bundle/ruby/1.9.1/bin in PATH, mode 040777/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /home/git/gitlab/vendor/bundle/ruby/1.9.1/bin in PATH, mode 040777=> Booting WEBrick=> Rails 3.2.13 application starting in production on http://0.0.0.0:3000[git@mytest123 gitlab]$
7. Install nginx
yum install nginx -y
Download gitlab's nginx configuration file
curl --output /etc/nginx/conf.d/gitlab.conf https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/nginx/gitlab
Edit the file and paste the two lines
Listen YOUR_SERVER_IP: 80 default_server; # e.g., listen 192.168.1.1: 80;
Server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
Change it to your domain name or IP address. my options are as follows:
Start nginx and access it with a domain name or IP address. The first error "502 Bad Gateway" was reported. Check gitlab_err.log as follows:
[Root @ mytest123 gitlab] # tail-f/var/log/nginx/gitlab_error.log
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public/" failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request: "GET/HTTP/1.1", host: "192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public // index.html" failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request: "GET/HTTP/1.1", host: "192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public /. html "failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request:" GET/HTTP/1.1 ", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 connect () to unix:/home/git/gitlab/tmp/sockets/gitlab. socket failed (13: Permission denied) while connecting to upstream, client: 180.159.220.7, server: 192.161.57.96, request: "GET/HTTP/1.1", upstream: "http: // unix: /home/git/gitlab/tmp/sockets/gitlab. socket:/", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public/favicon. ico "failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request:" GET/favicon. ico HTTP/1.1 ", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public/favicon. ico/index.html "failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request:" GET/favicon. ico HTTP/1.1 ", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public/favicon.ico.html" failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request: "GET/favicon. ico HTTP/1.1 ", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 connect () to unix:/home/git/gitlab/tmp/sockets/gitlab. socket failed (13: Permission denied) while connecting to upstream, client: 180.159.220.7, server: 192.161.57.96, request: "GET/favicon. ico HTTP/1.1 ", upstream:" http: // unix:/home/git/gitlab/tmp/sockets/gitlab. socket:/favicon. ico ", host:" 192.161.57.96 ″
There are two main points to be modified, and the/home/git/gitlab/directory should be granted permissions, and then:/home/git/gitlab/tmp/sockets/gitlab. you must also grant permissions to the socket file. I will grant permissions to the gitlab directory 777 directly.
[root@mytest123 gitlab]# chmod -R 777 /home/git/gitlab/
Restart gitlab and nginx and access again
Succeeded. The page is displayed ~
The command line check through gitlab-shell is successful, yeah!
[Root @ mytest123 git] # su-git
[Git @ mytest123 ~] $ Cd gitlab-shell/
[Git @ mytest123 gitlab-shell] $./bin/check
Check GitLab API access: OK
Check directories and files:
/Home/git/repositories: OK
/Home/git/. ssh/authorized_keys: OK
[Git @ mytest123 gitlab-shell] $
Reference: https://gist.github.com/wakefield/5304650