Configuring a Gitlab hook on a CentOS server A series of issues raised

Source: Internet
Author: User
Tags centos server

In order to set up the Gitlab environment on the company's server and configure the hooks (implement the server automatic git pull after the local git push), the whole long time, finally solved the problem, the following is a series of problems caused by recording the installation Gitlab:

First build Gitlab is a reference to http://www.linuxidc.com/Linux/2016-06/131992.htm this article, using the Bitnami production of a key installation package, downloaded down is the run format file, You need to execute permissions on this file first:

chmod +x filename

FileName is the name of this file.

After the installation of Gitlab, the first thing to do is to let the Gitlab service on the Linux server each time the restart can be automatically started

1. Set the boot-up script on the Linux system

Edit/etc/rc.local This file, will need to boot execution command added to this file, I hope Gitlab can boot execution, so add/opt/gitlab-7.0.0-0/ctlscript.sh start to the file, but after doing so, After I restarted the server, I found that the script was not executed and found an article on the Web: http://soarwilldo.blog.51cto.com/5520138/1549656. The reason for this is that/etc/rc.local is pointing to/etc/rc.d/rc.local, but by default the/etc/rc.d/rc.local file does not have execute permissions, so you need to add execute permissions to it:

chmod +x/etc/rc.d/rc.local

The system will automatically open Gitlab related services each time it restarts.

2. Use PHP's Shell_exec () function to perform git pull

First, the shell_exec () function is generally disabled, and the workaround is to remove the shell_exec () from disable_functions in php.ini so that the function is lifted.

However, the light function has not been lifted, because the WWW user group Use this function is limited, that is, insufficient permissions, the solution is to use sudo to improve the WWW user group permissions,

Executes Visudo (or vi/etc/sudoers), gives the WWW user group root privileges, and does not require a password.

PHP code plus sudo

shell_exec ("/usr/bin/sudo/usr/bin/git pull");

After the local push, found still no synchronization, view log, error message: Sudo:sorry,you must has a TTY to run sudo

The workaround is to enter Visodu and comment out the defaults requiretty line

Then the WWW user group has the permission to execute the SHELL_EXEC function, so the hooks are configured properly.

Because it is the company's test server, so security does not need to be so high, the purpose of executing shell_exec is to configure hooks.

Configuring a Gitlab hook on a CentOS server A series of issues raised

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.