このガイドでは、MariaDBをデータベースサーバーとして使用してDebian9VPSにGogsをインストールするプロセスについて説明します。
Gogsは、Goプログラミング言語で記述された無料のオープンソースのセルフホストGitサービスです。インストールが簡単で、クロスプラットフォームで軽量です。これらすべての属性により、Gogsはあらゆる種類のハードウェアで簡単に実行できます。このガイドは他のLinuxVPSシステムでも機能するはずですが、Debian9VPS用にテストおよび作成されています。インストールから始めましょう。
前提条件
- Debian9仮想サーバー
- sudo権限を持つユーザーアカウント、または「root」ユーザー自体へのアクセス
ステップ1:必要なパッケージをインストールする
rootまたはsudoユーザーとしてSSH経由でVPSにログインします:
ssh userame@IP_Address -p Port_Number
「IP_Address」と「Port_Number」をサーバーのそれぞれのIPアドレスとSSHポート番号に置き換えてください。
ログインしたら、次のコマンドを発行して、インストールされているすべてのパッケージを最新の利用可能なバージョンに更新します。
sudo apt-get update sudo apt-get upgrade
その後、次のコマンドを使用してgitパッケージをインストールします。
sudo apt-get install git
ステップ2:MariaDBデータベースを作成する
Gogsは、データベースバックエンドにMySQL / MariaDB、PostgreSQL、MSSQL、TiDB、SQLite3を使用できます。
このチュートリアルでは、MariaDBを使用します。 MySQLまたはMariaDBサーバーがサーバーにインストールされていない場合は、次のコマンドを実行して最新のMariaDBバージョンをインストールできます。
sudo apt-get install mysql-server
MariaDBのインストールが完了したら、mysql_secure_installation
を実行することをお勧めします。 データベースサーバーのセキュリティを向上させるスクリプト:
sudo mysql_secure_installation
次のようにセキュリティの質問に答えます。続行する前にルートMariaDBパスワードの入力を求められた場合は、デフォルトではパスワードが設定されていないため、[Enter]キーを押すだけです。
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
MySQLルートユーザーと以前に設定したパスワードを使用してMySQLシェルにログインします。
mysql -u root -p
Gogs用のMySQLデータベースとユーザーを作成し、次のコマンドを発行してユーザーに権限を付与します。
MariaDB [(none)]> CREATE SCHEMA `gogs` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; MariaDB [(none)]> GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' IDENTIFIED BY 'strongpassword'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> EXIT
必ず「strongpassword」を実際の強力なパスワードに置き換えてください。
ステップ3:ゴグをインストールする
Gogsサーバーを実行する新しいシステムユーザーを作成します。
sudo adduser --home /opt/gogs --shell /bin/bash --gecos 'Gogs application' gogs
次に、「wget」を使用してGogsGithubページからGogsバイナリをダウンロードします。
wget https://github.com/gogs/gogs/releases/download/v0.11.86/linux_amd64.tar.gz
ダウンロードしたアーカイブを/opt/gogs
に抽出します ディレクトリ:
sudo tar xvf linux_amd64.tar.gz --strip-components=1 -C /opt/gogs
ディレクトリの所有権をGogsユーザーに変更します:
sudo chown -R gogs:gogs /opt/gogs/
次に、SystemDユニットファイルをコピーします。これにより、Gogs用のSystemDサービスを作成できます:
sudo cp /opt/gogs/scripts/systemd/gogs.service /etc/systemd/system/
選択したテキストエディタを使用してユニットファイルを開きます。 nanoを使用します。
sudo nano /etc/systemd/system/gogs.service
ファイルを開いたら、次のように編集します。
[Unit] [Unit] Description=Gogs After=syslog.target After=network.target After=mariadb.service mysqld.service postgresql.service memcached.service redis.service [Service] # Modify these two values and uncomment them if you have # repos with lots of files and get an HTTP error 500 because # of that ### #LimitMEMLOCK=infinity #LimitNOFILE=65535 Type=simple User=gogs Group=gogs WorkingDirectory=/opt/gogs ExecStart=/opt/gogs/gogs web Restart=always Environment=USER=gogs HOME=/opt/gogs # Some distributions may not support these hardening directives. If you cannot start the service due # to an unknown option, comment out the ones not supported by your version of systemd. ProtectSystem=full PrivateDevices=yes PrivateTmp=yes NoNewPrivileges=true [Install] WantedBy=multi-user.targetでサポートされていないものをコメントアウトしてください。
ファイルの編集が完了したら、ファイルを保存してから、Gogsサービスを開始して有効にします。
sudo systemctl daemon-reload sudo systemctl start gogs sudo systemctl enable gogs
次のコマンドを実行して、Gogsサービスが正常に開始されていることを確認します。
sudo systemctl status gogs
● gogs.service - Gogs Loaded: loaded (/etc/systemd/system/gogs.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2019-05-13 02:57:32 CDT; 29s ago Main PID: 791 (gogs) CGroup: /system.slice/gogs.service └─791 /opt/gogs/gogs web May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [ WARN] Custom config '/opt/gogs/custom/conf/app.ini' not found, ignore this if you're running first time May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [TRACE] Custom path: /opt/gogs/custom May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [TRACE] Log path: /opt/gogs/log May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [TRACE] Log Mode: Console (Trace) May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [ INFO] Gogs 0.11.86.0130 May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [ INFO] Cache Service Enabled May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [ INFO] Session Service Enabled May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [ INFO] SQLite3 Supported May 13 02:57:32 vps gogs[791]: 2019/05/13 02:57:32 [ INFO] Run Mode: Development May 13 02:57:33 vps gogs[791]: 2019/05/13 02:57:33 [ INFO] Listen: http://0.0.0.0:3000
ステップ4:ゴグを設定する
インストールが完了したら、http://server_ip:3000/install
に移動します 必要なすべてのフィールドに入力します。 「server_ip」をサーバーのパブリックIPアドレスに置き換えることを忘れないでください:
データベース設定
- データベースタイプ:MySQL
- ホスト:
127.0.0.1:3306
- ユーザー:gogs
- パスワード:strongpassword
- データベース名:gogs
ゴグの一般設定
- アプリケーション名:Gogs
- リポジトリルートパス:
/opt/gogs/gogs-repositories
- 実行ユーザー:gogs
- ドメイン:SERVER_IP
- SSHポート:22
- HTTPポート:3000
- アプリケーションURL:http:// SERVER_IP:3000 /
- ログパス:
/opt/gogs/log
完了したら、インストールボタンをクリックすると、準備が整います。
管理アクセスは、最初に登録されたユーザーに自動的に付与されます:
それでおしまい。これで、Debian9VPSにGogsが正常にインストールされました。 Gogsのインストールを管理する方法の詳細については、Gogsの公式ドキュメントを参照してください。
もちろん、Linux VPSホスティングサービスのいずれかを使用している場合は、これを行う必要はありません。その場合は、専門のLinux管理者にすべてをセットアップしてGogsをインストールするよう依頼するだけです。 24時間年中無休でご利用いただけます。リクエストはすぐに処理されます。
PS 。この投稿が気に入った場合、または役に立った場合は、以下の共有ショートカットを使用してソーシャルネットワークで友達と共有するか、コメントセクションにコメントを残してください。ありがとうございます。