標籤:
(轉載)https://segmentfault.com/q/1010000002646550
之前在本機上部署了gitlab服務,可以通過localhost、127.0.0.1 和本機IP訪問到本機gitlab頁面。
現在想在本機建立一個網站做些測試,可是不知道怎麼訪問到建立的網站,搜尋了相關資料,據說要修改nginx的設定檔,我在設定檔裡添加 myhome.cn 網域名稱,並綁定到網站目錄,可是訪問 myhome.cn 後,開啟的還是gitlab的頁面。
按照網上的相關說明,我又修改了gitlab的設定檔:
/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml/opt/gitlab/embedded/service/gitlab-shell/config.yml
把 host 改成了 git.test.com,用gitlab-ctl restart命令重新啟動gitlab後效果也一樣。
/etc/hosts裡也添加了網域名稱:
127.0.0.1 git.test.com127.0.0.1 myhome.cn
然而,並沒有什麼用,不管什麼網域名稱,都是訪問gitlab的頁面,有沒有什麼解決方案?
用ps -ef | grep nginx命令看了下,發現啟動並執行nginx的路徑是/opt/gitlab/embedded/sbin/nginx,而設定檔路徑是/var/opt/gitlab/nginx,怪不得我開啟/etc/nginx/nginx.conf沒看到gitlab相關的配置。
試著改了下/var/opt/gitlab/nginx/nginx.conf 和 /var/opt/gitlab/nginx/gitlab-http.conf,重啟服務後,頁面無法訪問了,我先折騰一下。
在/var/opt/gitlab/nginx/nginx.conf開頭處有這樣的內容:
# This file is managed by gitlab-ctl. Manual changes will be# erased! To change the contents below, edit /etc/gitlab/gitlab.rb# and run `sudo gitlab-ctl reconfigure`.
呃,原來可以通過修改/etc/gitlab/gitlab.rb來配置,我再折騰一下。
server { listen 80; server_name git.test.com; access_log /var/log/nginx/XXX.access_log main; error_log /var/log/nginx/XXX.error_log info; root /home/www/xxx; index index.html index.php; //接下來配置github cgi介面}server { listen 80; server_name myhome.cn; access_log /var/log/nginx/XXX.access_log main; error_log /var/log/nginx/XXX.error_log info; root /home/www/xxx2; index index.html index.php; //接下來配置別的cgi介面}
在本機部署gitlab後,如何在nginx上配置多網域名稱?