Loading... ### Using an external Nginx installation #### Step 1 * Install gitlab-ce using the tutorial on [this page](https://about.gitlab.com/install/#centos-7?version=ce) #### Step 2 Edit `/etc/gitlab/gitlab.rb` to disable the built-in `NGINX` and `Unicorn` ```ruby # Define the external url external_url 'http://git.yourdomain.com' # Disable the built-in nginx nginx['enable'] = false # Disable the built-in unicorn unicorn['enable'] = false # Make changes effective sudo gitlab-ctl reconfigure # Restart all GitLab components sudo gitlab-ctl restart ``` #### Step 3 Install `Passenger` + `Nginx` Enable EPEL ```bash sudo yum install -y epel-release yum-utils sudo yum-config-manager --enable epel sudo yum clean all && sudo yum update -y ``` Repair potential system issues ```bash sudo date # if the output of date is wrong, please follow these instructions to install ntp sudo yum install -y ntp sudo chkconfig ntpd on sudo ntpdate pool.ntp.org sudo service ntpd start ``` Install `Passenger` packages ```bash # Install various prerequisites sudo yum install -y pygpgme curl # Add our el7 YUM repository sudo curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo # Install Passenger Nginx sudo yum install -y nginx passenger || sudo yum-config-manager --enable cr && sudo yum install -y nginx passenger ``` #### Step 4 * Read [this](https://docs.gitlab.com/omnibus/settings/nginx.html#using-an-existing-passengernginx-installation) documentation and create `Nginx` site file * Add `8080` port listening for your site ```nginx server { ... # This port is used to listen for incoming requests from gitlab-shell # please check the port specified by gitlab_url in the /opt/gitlab/embedded/service/gitlab-shell/config.yml file # default port 8080 listen 8080; ... } ``` then you can launch the site using `sudo service nginx start` ### Unexpected * If you get `[emerg] unknown directive "passenger_root"` or `[emerg] unknown directive "passenger_ruby"` error, then your Nginx is not from Phusion's YUM repository. The Passenger package has Passenger compiled with Nginx as a module, while the other package does not. You can use `sudo yum remove nginx passenger` to uninstall `nginx/passenger` and repeat step 3 fix that. * If your page looks like this ![file](https://wangshenjie.com/wp-content/uploads/2020/03/5e637597c50f9.png) Use `tail -f /var/log/nginx/error.log` view error log, if it is `Could not find a JavaScript runtime` error, use `sudo yum install nodejs` fix that. * `gitlab-shell self-check failed` and the detail is `Failed to connect to internal API`, is because you stopped `Unicorn` and replaced it with external `Nginx`, modify the port pointed by `gitlab_url` in the `/opt/gitlab/embedded/service/gitlab-shell/config.yml` file to the listening port of your `Nginx`, or add a listening port for `Nginx` to fix. * If you first setting root user password and get `10 errors prohibited this user from being saved`, maybe you enabled `smtp`. ```Ruby # Disable SMTP gitlab_rails['smtp_enable'] = false # Make changes effective sudo gitlab-ctl reconfigure # Restart all GitLab components sudo gitlab-ctl restart ``` ### Reference * [GitLab Installation](https://about.gitlab.com/install/#centos-7?version=ce) * [Using an existing Passenger/NGINX installation](https://docs.gitlab.com/omnibus/settings/nginx.html#using-an-existing-passengernginx-installation) * [Installing Passenger + Nginx](https://www.phusionpassenger.com/library/install/nginx/install/oss/el7/) * [Nginx unknown directive for passenger_root](https://stackoverflow.com/questions/21840707/nginx-unknown-directive-for-passenger-root) 最后修改:2020 年 11 月 27 日 © 允许规范转载 赞 0 如果觉得我的文章对你有用,请随意赞赏