Ubuntu update
package name | Version |
---|---|
Ubuntu | 21.10 |
OS in PHP | 8.+ |
openlitespeed | 1.7.+ |
LiteSpeedServerにGitlabを導入する方法についてのメモ。
1. 依存パッケージのインストールと設定
sudo apt-get update sudo apt-get install -y curl openssh-server ca-certificates
2. GitLabパッケージのリポジトリへの追加とインストール
GitLabパッケージをリポジトリに追加します。
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
マニュアル追加方法
wget https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh
vim script.deb.sh
script.deb.sh
#!/bin/bash
unknown_os ()
{
echo "Unfortunately, your operating system distribution and version are not supported by this script."
echo
echo "You can override the OS detection by setting os= and dist= prior to running this script."
echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
echo
echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
echo
echo "Please email support@packagecloud.io and let us know if you run into any issues."
exit 1
}
gpg_check ()
{
echo "Checking for gpg..."
if command -v gpg > /dev/null; then
echo "Detected gpg..."
else
echo "Installing gnupg for GPG verification..."
apt-get install -y gnupg
if [ "$?" -ne "0" ]; then
echo "Unable to install GPG! Your base system has a problem; please check your default OS's package repositories because GPG should work."
echo "Repository installation aborted."
exit 1
fi
fi
}
curl_check ()
{
echo "Checking for curl..."
if command -v curl > /dev/null; then
echo "Detected curl..."
else
echo "Installing curl..."
apt-get install -q -y curl
if [ "$?" -ne "0" ]; then
echo "Unable to install curl! Your base system has a problem; please check your default OS's package repositories because curl should work."
echo "Repository installation aborted."
exit 1
fi
fi
}
install_debian_keyring ()
{
if [ "${os}" = "debian" ]; then
echo "Installing debian-archive-keyring which is needed for installing "
echo "apt-transport-https on many Debian systems."
apt-get install -y debian-archive-keyring &> /dev/null
fi
}
detect_os ()
{
if [[ ( -z "${os}" ) && ( -z "${dist}" ) ]]; then
# some systems dont have lsb-release yet have the lsb_release binary and
# vice-versa
if [ -e /etc/lsb-release ]; then
. /etc/lsb-release
if [ "${ID}" = "raspbian" ]; then
os=${ID}
dist=`cut --delimiter='.' -f1 /etc/debian_version`
else
os=${DISTRIB_ID}
dist=${DISTRIB_CODENAME}
if [ -z "$dist" ]; then
dist=${DISTRIB_RELEASE}
fi
fi
elif [ `which lsb_release 2>/dev/null` ]; then
dist=`lsb_release -c | cut -f2`
os=`lsb_release -i | cut -f2 | awk '{ print tolower($1) }'`
elif [ -e /etc/debian_version ]; then
# some Debians have jessie/sid in their /etc/debian_version
# while others have '6.0.7'
os=`cat /etc/issue | head -1 | awk '{ print tolower($1) }'`
if grep -q '/' /etc/debian_version; then
dist=`cut --delimiter='/' -f1 /etc/debian_version`
else
dist=`cut --delimiter='.' -f1 /etc/debian_version`
fi
else
unknown_os
fi
fi
if [ -z "$dist" ]; then
unknown_os
fi
# remove whitespace from OS and dist name
os="${os// /}"
dist="${dist// /}"
echo "Detected operating system as $os/$dist."
}
main ()
{
detect_os
curl_check
gpg_check
# Need to first run apt-get update so that apt-transport-https can be
# installed
echo -n "Running apt-get update... "
apt-get update &> /dev/null
echo "done."
# Install the debian-archive-keyring package on debian systems so that
# apt-transport-https can be installed next
install_debian_keyring
echo -n "Installing apt-transport-https... "
apt-get install -y apt-transport-https &> /dev/null
echo "done."
gpg_key_url="https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey"
apt_config_url="https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/config_file.list?os=ubuntu&dist=focal&source=script"
apt_source_path="/etc/apt/sources.list.d/gitlab_gitlab-ce.list"
echo -n "Installing $apt_source_path..."
# create an apt config file for this repository
curl -sSf "${apt_config_url}" > $apt_source_path
curl_exit_code=$?
if [ "$curl_exit_code" = "22" ]; then
echo
echo
echo -n "Unable to download repo config from: "
echo "${apt_config_url}"
echo
echo "This usually happens if your operating system is not supported by "
echo "packagecloud.io, or this script's OS detection failed."
echo
echo "You can override the OS detection by setting os= and dist= prior to running this script."
echo "You can find a list of supported OSes and distributions on our website: https://packages.gitlab.com/docs#os_distro_version"
echo
echo "For example, to force Ubuntu Trusty: os=ubuntu dist=trusty ./script.sh"
echo
echo "If you are running a supported OS, please email support@packagecloud.io and report this."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" = "35" -o "$curl_exit_code" = "60" ]; then
echo "curl is unable to connect to packagecloud.io over TLS when running: "
echo " curl ${apt_config_url}"
echo "This is usually due to one of two things:"
echo
echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
echo
echo "Contact support@packagecloud.io with information about your system for help."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" -gt "0" ]; then
echo
echo "Unable to run: "
echo " curl ${apt_config_url}"
echo
echo "Double check your curl installation and try again."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
else
echo "done."
fi
echo -n "Importing packagecloud gpg key... "
# import the gpg key
curl -L "${gpg_key_url}" 2> /dev/null | apt-key add - &>/dev/null
echo "done."
echo -n "Running apt-get update... "
# update apt on this system
apt-get update &> /dev/null
echo "done."
echo
echo "The repository is setup! You can now install packages."
}
main
Gitlabの初期設定
/etc/gitlab/gitlab.rb
add this code
external_url 'http://gitlab.domain'
gitlab_rails['time_zone'] = 'Asia/Tokyo' #JSTにする
postgresql['shared_buffers'] = "1024MB" #使用メモリ スペックがどうしても足りない時
gitlab_workhorse['listen_network'] = "tcp" #デフォルトはSocket接続だがリバプロできないのでTCPに変更
gitlab_workhorse['listen_umask'] = 000
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181" #指定するのでメモ
gitlab_workhorse['auth_backend'] = "http://localhost:8080"
alertmanager['enable'] = false
prometheus['monitor_kubernetes'] = false
nginx['enable'] = false #Apacheを使うので Nginx はOFF
#Git データを外付けに移動させる
git_data_dirs({
"default" => {
"pathName" => "{mount point}/gitlab/git-data" #マウントしたUSBの場所を指定
}
})
gitlab_rails['manage_backup_path'] = true
gitlab_rails['backup_path'] = "/Datas/gitlab/gitlab-backup"
gitlab_rails['backup_archive_permissions'] = 0644
gitlab_rails['backup_keep_time'] = 604800
LiteSpeed コンソールから以下の設定にする
基本
バーチャルホスト名 | Gitlab |
Virtual Host Root | Gitlab/ |
設定ファイル | conf/vhosts/Gitlab/vhconf.conf |
ノート | 未設定 |
コネクション
最大キープアライブ要求 | 未設定 |
セキュリティ
シンボリックリンクを許可する | はい |
スクリプト/外部アプリを有効にする | はい |
抑制された | はい |
外部アプリのUIDモードの設定 | 未設定 |
suEXEC User | 未設定 |
suEXEC Group | 未設定 |
クライアントスロットル毎
静的リクエスト/秒 | 未設定 |
動的 リクエスト/秒 | 未設定 |
送信帯域幅(バイト/秒) | 未設定 |
受信帯域幅(バイト/秒) | 未設定 |
一般
Document Root | /opt/gitlab/embedded/service/gitlab-rails/public |
ドメイン名 | 未設定 |
ドメインエイリアス | 未設定 |
管理者Eメール | 未設定 |
GZIP圧縮を有効にする | 未設定 |
Enable Brotli Compression | 未設定 |
IPジオロケーションを有効にする | 未設定 |
cgroups | 未設定 |
インデクスファイル
サーバーインデックスファイルを使用する | 未設定 |
インデクスファイル | 未設定 |
自動インデックス | 未設定 |
自動インデックスURI | 未設定 |
カスタマイズエラーページ
エラーコード | URL | アクション |
---|
有効期限の設定
有効期限を有効にする | 未設定 |
デフォルトの期限 | 未設定 |
タイプ別の期限 | 未設定 |
ファイルアップロード
一時ファイルのパス | 未設定 |
一時ファイルのアクセス許可 | 未設定 |
ファイルのパスでアップロードデータを渡します | 未設定 |
php.ini Override
外部アプリケーション
タイプ | 名前 | アドレス |
---|---|---|
Webサーバー | gitlab.ドメイン | https://gitlab.ドメイン:8181 |
Webサーバー | 127.0.0.1:8181 | 127.0.0.1:8181 |
スクリプトハンドラの定義
サフィックス | ハンドラタイプ | ハンドラ名 |
---|---|---|
php | LiteSpeed SAPI | [サーバーレベル]: lsphp |
PHPのバージョンによる対応。LiteSpeed SAPIの設定方法は別になります。
Rewrite 制御
Rewriteを有効にする | はい |
Auto Load from .htaccess | はい |
ログレベル | 未設定 |
Rewrite Map
名前 | 場所 | アクション |
---|
Rewrite ルール
RewriteFile .htaccess RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_URI} ^/uploads/.* RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE] |
コンテキストリスト
タイプ | URI | アクセス可能 |
---|---|---|
Static | / | はい |
静的コンテキストの定義
URI | / |
場所 | $DOC_ROOT/ |
アクセス可能 | はい |
ノート | 未設定 |
有効期限を有効にする | 未設定 |
デフォルトの期限 | 未設定 |
タイプ別の期限 | 未設定 |
Header Operations | unset Cache-control set Cache-control public, max-age=15552000 Referrer-Policy: no-referrer-when-downgrade Strict-Transport-Security: max-age=31536000; includeSubDomains Access-Control-Allow-Origin *.{ドメイン} Access-Control-Allow-Methods GET, POST, OPTIONS, DELETE X-Content-Type-Options “nosniff” always X-Frame-Options: SAMEORIGIN Permissions-Policy: geolocation=(self “”), |
MIMEタイプ | 未設定 |
強制MIMEタイプ | 未設定 |
デフォルトのMIMEタイプ | 未設定 |
インデクスファイル | 未設定 |
自動インデックス | 未設定 |
レルム | 未設定 |
認証名 | 未設定 |
必要 (ユーザー/グループ許可) | 未設定 |
アクセスが許可されました | 未設定 |
アクセスが拒否されました | 未設定 |
承認者 | 未設定 |
Rewriteを有効にする | 未設定 |
Rewrite Inherit | 未設定 |
Rewrite Base | 未設定 |
Rewrite ルール | RewriteFile .htaccess |
デフォルトの文字セットを追加 | Off |
デフォルトの文字セットをカスタマイズする | 未設定 |
IPジオロケーションを有効にする | 未設定 |
php.ini Override |
Web Socket Proxy 設定
SSL
SSL有効化する
Let’s Encrypt : Get and Set SSL
apt -y install snapd
snap install core; sudo snap refresh core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
certbot certonly --standalone
snap set certbot trust-plugin-with-root=ok #setting worldcord domain.
certbot certonly --webroot -w /var/www/html/ -d [Domain] -m [MailAddress] --agree-tos -n
Gitlab-Ctl
基本的な管理コマンド
起動、停止、再起動
gitlab-ctl start
gitlab-ctl stop
gitlab-ctl restart
設定の再構築
gitlab-ctl reconfigure
ログ確認
gitlab-ctl tail
全プロセスの最新ログを監視する。
ログ自体は下記に出力されるので、ログを特定したら対象ログで原因を分析する。
/var/log/gitlab
バックアップ
gitlab-rake gitlab:backup:create
下記のディレクトリに作成される。
/var/opt/gitlab/backups
リストア
gitlab-ctl stop unicorn
gitlab-ctl stop sidekiq
gitlab-ctl status
gitlab-rake gitlab:backup:restore BACKUP={対象ファイルの日付/時間部分まで}
gitlab-ctl start
gitlab-rake gitlab:check SANITIZE=true
コメント