gitlab 7.4.5 nginx apache 配置

本文详细介绍了如何通过源码安装GitLab 7.4.5版本,并提供了运行环境需求及关键配置信息,包括解决Git-over-HTTP问题的策略、Nginx配置调整建议等。

gitlab 7.4.5 参照 1, 2 从源码安装。

本文 gitlab 7.4.5 运行环境 见 3

nginx 配置参照源码自带配置 lib/support/nginx/gitlab

## GitLab
## Maintainer: @randx
##
## Lines starting with two hashes (##) are comments with information.
## Lines starting with one hash (#) are configuration parameters that can be uncommented.
##
##################################
##        CHUNKED TRANSFER      ##
##################################
##
## It is a known issue that Git-over-HTTP requires chunked transfer encoding [0]
## which is not supported by Nginx < 1.3.9 [1]. As a result, pushing a large object
## with Git (i.e. a single large file) can lead to a 411 error. In theory you can get
## around this by tweaking this configuration file and either:
## - installing an old version of Nginx with the chunkin module [2] compiled in, or
## - using a newer version of Nginx.
##
## At the time of writing we do not know if either of these theoretical solutions works.
## As a workaround users can use Git over SSH to push large files.
##
## [0] https://git.kernel.org/cgit/git/git.git/tree/Documentation/technical/http-protocol.txt#n99
## [1] https://github.com/agentzh/chunkin-nginx-module#status
## [2] https://github.com/agentzh/chunkin-nginx-module
##
###################################
##         configuration         ##
###################################
##

upstream gitlab {
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=0;
}

## Normal HTTP host
server {
  #listen *:80 default_server;
  listen *:80 default_server;
  server_name mydomain.com; ## Replace this with something like gitlab.example.com
  server_tokens off; ## Don't show the nginx version number, a security best practice
  root /home/git/gitlab/public;

  ## Increase this if you want to upload large attachments
  ## Or if you want to accept large git objects over http
  client_max_body_size 20m;

  ## Individual nginx logs for this GitLab vhost
  access_log  logs/mydomain.gitlab_access.log;
  error_log   logs/mydomain.gitlab_error.log;

  location / {
    ## Serve static files from defined root folder.
    ## @gitlab is a named location for the upstream fallback, see below.
    try_files $uri $uri/index.html $uri.html @gitlab;
  }

  ## If a file, which is not found in the root folder is requested,
  ## then the proxy passes the request to the upsteam (gitlab unicorn).
  location @gitlab {
    ## If you use HTTPS make sure you disable gzip compression
    ## to be safe against BREACH attack.
    # gzip off;

    ## https://github.com/gitlabhq/gitlabhq/issues/694
    ## Some requests take more than 30 seconds.
    proxy_read_timeout      300;
    proxy_connect_timeout   300;
    proxy_redirect          off;

    proxy_set_header    Host                $http_host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto   $scheme;
    proxy_set_header    X-Frame-Options     SAMEORIGIN;

    proxy_pass http://gitlab;
  }

  ## Enable gzip compression as per rails guide:
  ## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
  ## WARNING: If you are using relative urls remove the block below
  ## See config/application.rb under "Relative url support" for the list of
  ## other files that need to be changed for relative url support
  location ~ ^/(assets)/ {
    root /home/git/gitlab/public;
    #gzip_static on; # to serve pre-gzipped version
    expires max;
    add_header Cache-Control public;
  }

  error_page 502 /502.html;
}

Apache
apache(2.2.9) 配置参照 测试于 6.0.0 的 gitlab.conf,和测试于 8.0.0 的 gitlab-8.0-apache2.2.conf

#######
#NameVirtualHost *:80

#This configuration has been tested on GitLab 6.0.0 and GitLab 6.0.1
#Note this config assumes unicorn is listening on default port 8080.
#Module dependencies
#  mod_rewrite
#  mod_proxy
#  mod_proxy_http
<VirtualHost *:80>
  ServerName mydomain.com
  ServerSignature Off

  ProxyPreserveHost On

  # Ensure that encoded slashes are not decoded but left in their encoded state.
  # http://doc.gitlab.com/ce/api/projects.html#get-single-project
  AllowEncodedSlashes NoDecode

  <Location />
    Order deny,allow
    Allow from all

    ProxyPassReverse http://127.0.0.1:9095
    ProxyPassReverse http://mydomain.com/
  </Location>

  #apache equivalent of nginx try files
  # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
  # http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
  RewriteEngine on
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule .* http://127.0.0.1:9095%{REQUEST_URI} [P,QSA,NE]

  # needed for downloading attachments
  DocumentRoot /home/git/gitlab/public

  #Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
  ErrorDocument 404 /404.html
  ErrorDocument 422 /422.html
  ErrorDocument 500 /500.html
  ErrorDocument 503 /deploy.html

  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
  ErrorLog  logs/mydomain.gitlab_error.log
  CustomLog logs/mydomain.gitlab_forwarded.log common_forwarded
  CustomLog logs/mydomain.gitlab_access.log combined env=!dontlog
  CustomLog logs/mydomain.gitlab.log combined

</VirtualHost>

PS:
使用 relative url 的配置 见 gitlab 7.4.5 relative url configuration

Redis 7.4.5 是一个假设的版本,因为截至当前(2024年)Redis 的最新稳定版本为 7.0.x 系列,尚未发布 7.4.5。然而,可以基于 Redis 的标准安装流程和配置方式提供一个通用的安装指南,适用于未来的版本,如 Redis 7.4.5。 ### 下载 Redis 7.4.5 如果 Redis 7.4.5 已发布,可以通过访问 Redis 官方网站的下载页面获取源码包: ```bash wget http://download.redis.io/releases/redis-7.4.5.tar.gz ``` 随后解压并进入解压后的目录: ```bash tar -xzvf redis-7.4.5.tar.gz cd redis-7.4.5 ``` ### 编译和安装 确保系统已安装 GCC 编译器,然后执行编译命令: ```bash make ``` 如果希望将 Redis 安装到特定目录,可以使用 `make install` 并指定安装路径: ```bash make install PREFIX=/usr/local/redis ``` ### 配置 Redis 7.4.5 在首次运行之前,需要对 `redis.conf` 文件进行必要的配置。复制配置文件到安装目录: ```bash cp redis.conf /usr/local/redis/etc/ ``` 编辑 `/usr/local/redis/etc/redis.conf` 文件以适应需求,例如设置后台启动、绑定 IP 地址、设置密码等[^2]。 #### 设置后台启动 将 `daemonize no` 改为 `daemonize yes` 以启用后台运行模式。 #### 设置密码 如果需要密码保护,找到 `requirepass` 行并设置密码: ```bash requirepass yourpassword ``` #### 允许远程访问 默认情况下,Redis 只绑定 `127.0.0.1`,如需允许远程连接,需将 `bind` 指令修改为: ```bash bind 0.0.0.0 ``` ### 启动 Redis 服务 使用配置文件启动 Redis: ```bash /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf ``` ### 验证安装 使用 Redis 客户端连接到服务器以验证安装是否成功: ```bash /usr/local/redis/bin/redis-cli ``` 如果设置了密码,连接后需要使用 `AUTH` 命令进行认证: ```bash AUTH yourpassword ``` ### Windows 上安装 Redis 7.4.5 对于 Windows 用户,可以从 Microsoft 的 GitHub 仓库获取 Redis 的 Windows 兼容版本。下载并解压后,可以使用命令行启动服务: ```cmd redis-server.exe --service-install redis.windows.conf --loglevel verbose ``` ### 设置 Redis 为系统服务(Linux) 为了确保 Redis 在系统重启后自动运行,可以将其配置为系统服务。创建一个 `redis.service` 文件,并将其放置在 `/etc/systemd/system/` 目录下: ```ini [Unit] Description=Redis After=network.target [Service] ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf ExecStop=/usr/local/redis/bin/redis-cli shutdown User=redis Group=redis Restart=always [Install] WantedBy=multi-user.target ``` 保存文件后,重新加载 systemd 并启用服务: ```bash systemctl daemon-reexec systemctl enable redis ``` ### 总结 以上步骤提供了 Redis 7.4.5 的安装和基本配置指南。尽管 7.4.5 版本尚未发布,但上述步骤基于 Redis 的标准安装和配置流程,适用于任何未来的 Redis 版本。对于实际的版本更新和特性变化,建议查阅 Redis 官方文档获取最新信息。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值