使用CentOS上的SCL来安装Growi

首先

关于CentOS + Growi的组合,在网络上可以找到很多优质的文章,如果满足您的需求,阅读这些文章是更加细致的选择。我参考了以下的文章。真的非常感谢提供这样优秀的文章。

CentOS7.5にGrowiをインストール – Qiita (@yuki476 2018年11月14日に更新)

CentOS7にGrowi(旧Crowi-Plus)をインストールする方法 – Qiita (@SkyLaptor 2018年04月19日に更新)

有什么不同之处?

如果你想使用软件的官方版或最新版,最好看一下上述的文章。非常易懂。但是,我希望尽可能地使用接近发行版水平的方法来操作。因此,我尝试了使用SCL的方法。在这里,我打算重点简单总结一下它们的区别。

这篇文章中没有说明的事项。

    • Growiって何?

 

    SCLって何? 参考:https://www.softwarecollections.org/en/

步骤

安装CentOS/Redhat软件集合(SCL)

$ sudo yum install centos-release-scl{,-rh}

我每次使用yum命令时都会感到不安,因为它总是参考scl,所以我通过yum-config-manager来禁用它。yum-config-manager包含在yum-utils中。

$ sudo yum install yum-utils
$ sudo yum-config-manager --disable centos-sclo-{sclo,rh} > /dev/null

如果禁用存储库,则每次使用yum命令都需要使用yum –enablerepo=centos-sclo-rh,虽然有些麻烦,但考虑到维护,我认为这样更好。

2. Git安装(可选)

有时候我们也希望使用最新版本(尽可能接近最新版本)对吧?下面命令中的Git版本号需要根据当前的SCL仓库进行更改。此处我们使用的是2.18版本。

$ sudo yum --enablerepo=centos-sclo-rh install rh-git218

3. 安装mongodb

注意事项是在安装git时要注意版本号。

$ sudo yum --enablerepo=centos-sclo-rh install rh-mongodb36

另外,systemd服务是在以下文件中定义的。

/usr/lib/systemd/system/rh-mongodb36-mongod.service

如果要将此mongodb的mongod作为服务启动,则以下是命令。

$ sudo systemctl start rh-mongodb36-mongod

4. 安装Node.js和yarn。

$ sudo yum --enablerepo=centos-sclo-rh install rh-nodejs10
$ sudo scl enable rh-nodejs10 'npm install -g yarn'

补充第二行,使用scl命令添加环境变量,并使用npm全局安装yarn。(可能没有解释清楚,但希望你能感受到这种氛围……)另外,安装后的消息也会显示,使用此方法,yarn将被安装在/opt/rh/rh-nodejs10/root/usr/bin/yarn位置。

如果觉得在scl enable中输入命令很麻烦的话,可以考虑在这里预先输入以下命令。

$ scl enable rh-git218 rh-mongodb36 rh-nodejs10 bash

通过将最后的执行命令部分改为bash,启动已设置环境变量的bash。

5. 安装 Growi

基于个人爱好,我打算将其安装在 /opt/growi 中。

请确保包含`install`命令中的`-ovagrant`和`-gvagrant`分别被替换为适用于相应环境中的用户和组,并不要忘记`git clone`中的最后一个点(表示当前目录)。

$ scl enable rh-git218 bash
$ sudo install -ovagrant -gvagrant -d /opt/growi
$ cd /opt/growi
$ git clone --depth=1 https://github.com/weseek/growi.git .

将其注册为systemd服务。

我将借用@yuki476先生在Qiita上的前述文章。

/etc/sysconfig/growi はそのまま作ればよい

/etc/systemd/system/growi.service はSCLのための手当てが必要.以下のような書き方になる.

[Unit]
Description=Growi
After=network.target rh-mongodb36-mongod.service

[Service]
WorkingDirectory=/opt/growi
EnvironmentFile=/etc/sysconfig/growi
ExecStart=/usr/bin/scl enable rh-git218 rh-mongodb36 rh-nodejs10 'npm start'

[Install]
WantedBy=Multi-user.target

顺便提一下,每次修改growi.service文件后都需要使用以下命令重新加载。

$ systemctl daemon-reload

7. 完成(服务启动)

$ systemctl start rh-mongodb36-mongod growi
bannerAds