在 CentOS 7 上裸機安裝 Cachet

準備環境,如果是 CentOS 7 的話就乖乖用 remi 的 PHP 7.2 的庫就好了:

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y

然後開始安裝官網上提到的和沒提到的各種依賴:

yum install php-fpm php-mysqlnd php-json php-gd php-zip php-cli php-sqlite3 php-curl php-xml php-redis php-mbstring php-acpu -y

CentOS 7 上的 PHP 默認是 Apache 用戶,需要設置一下,然後 PHP 默認監聽的 `127.0.0.1:9000`,所以爲了省事 Nginx 可以這麼寫:

location / {
add_header Strict-Transport-Security max-age=15768000;
try_files $uri /index.php$is_args$args;
}
location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_index index.php;
            fastcgi_keep_conn on;
            add_header Strict-Transport-Security max-age=15768000;
}

最後把 Cachet 代碼拉下來,如果用了 PHP 7.2 的話就別用 tagged 的版本了,直接用默認分支(2020-06-24 時拉下來就是 2.4)就好了,不然各種問題。

git clone https://github.com/cachethq/Cachet.git
cd Cachet
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
/usr/local/bin/composer install --no-dev -o
php artisan key:generate
php artisan cachet:install

Reference

  • https://github.com/guzzle/guzzle/pull/2038
  • https://github.com/invoiceninja/invoiceninja/issues/1767
  • https://github.com/CachetHQ/Cachet/issues/2077
  • https://github.com/CachetHQ/Cachet/issues/2417
  • https://stackoverflow.com/questions/48001569/phpmyadmin-count-parameter-must-be-an-array-or-an-object-that-implements-co
  • https://github.com/CachetHQ/Cachet/issues/2904
  • https://www.howtoforge.com/how-to-install-cachet-status-page-system-on-centos-7/
  • https://github.com/CachetHQ/Cachet/issues/3492
  • https://github.com/guzzle/guzzle/pull/2038