[英]Trying to install GitLab on Apache on CentOS 7
I'm trying to install GitLab, but I want to install it on an Apache web server on my VPS. 我正在尝试安装GitLab,但我想将它安装在我的VPS上的Apache Web服务器上。
I know that GitLab was built for nginx, but I honestly don't want to use it. 我知道GitLab是为nginx构建的,但老实说我不想使用它。 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. 我想知道如何能够进行设置以便mysite.com能够在/var/www/html
lab.mysite.com中检索文件(例如index.html,包含更多文件的文件夹等)检索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. 注意:在我使用本指南安装GitLab之前 ,不过这是针对Nginx的,所以我想知道我是否要使用本指南但是然后添加到它上面,或者如果我说这个都错了。
By default GitLab will install nginx but usually won't add nginx to your system's service manager (service or systemctl). 默认情况下,GitLab将安装nginx,但通常不会将nginx添加到系统的服务管理器(service或systemctl)。 This makes it confusing when trying to enable Apache (Apache won't start due to default port 80 in use by nginx). 这使得在尝试启用Apache时会让人感到困惑(由于nginx使用默认端口80,Apache无法启动)。
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). 假设您已根据默认安装说明安装了Gitlab,Nginx服务现在将由gitlab-ctl服务管理器(安装Gitlab时安装)进行管理。
To stop Nginx, run the following from a command line as root: 要停止Nginx,请以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). 现在端口80是免费的,你可以启动Apache(不要忘记安装Apache,如果它还没有/指令用于RHEL系统 - 相应地修改Ubuntu等)。 Assumes you are root user: 假设您是root用户:
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: 让我们编辑Gitlab配置文件以禁用nginx并告诉gitlab使用apache:
vi /etc/gitlab/gitlab.rb
Add either your domain or IP to the following: 将您的域或IP添加到以下内容:
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. 现在是Apache配置。 When we installed Gitlab, it added a user group called gitlab-www. 当我们安装Gitlab时,它添加了一个名为gitlab-www的用户组。 We need to allow the apache user access to that group. 我们需要允许apache用户访问该组。 The following assumes you've installed apache and the user apache (48) exists: 以下假设您已安装apache并且用户apache(48)存在:
To check which group gitlab installed itself under, you can run: 要检查gitlab安装在哪个组下,您可以运行:
getent group
Now lets modify apache's user and add it to the gitlab-www group: 现在让我们修改apache的用户并将其添加到gitlab-www组:
usermod apache --append --groups gitlab-www
Now we need an Apache Virtual Host to point to the gitlab install. 现在我们需要一个Apache虚拟主机来指向gitlab安装。
Add a virtual host to Apache's conf.d directory (this will create a new file): 将一个虚拟主机添加到Apache的conf.d目录(这将创建一个新文件):
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: ...现在重启Apache:
systemctl start httpd
You may run into issues with things like selinux - You can set things to permissive for debugging purposes. 您可能遇到像selinux这样的问题 - 您可以将事情设置为允许进行调试。
setenforce 0
I hope this helps someone! 我希望这可以帮助别人!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.