このチュートリアルでは、MariaDB、PHP-FPM、およびNginxを使用してDebian 7(Wheezy)VPSにCachetHQをインストールする方法を説明します。 CachetHQを使用すると、アプリケーション、サービス、またはネットワークのステータスページを簡単に作成でき、Laravel4.2フレームワークに基づいています。このガイドは他のLinuxVPSシステムでも機能するはずですが、Debian7VPS用にテストおよび作成されています。
SSH経由でVPSにログイン
ssh user@myVPS
システムを更新し、必要なパッケージをインストールします
user@myVPS:~# sudo apt-get update && sudo apt-get -y upgrade user@myVPS:~# sudo apt-get install python-software-properties git curl openssl vim build-essential
MariaDB10.0をインストール
user@myVPS:~# sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db user@myVPS:~# sudo add-apt-repository 'deb http://mirror.jmu.edu/pub/mariadb/repo/10.0/debian wheezy main' user@myVPS:~# sudo apt-get update user@myVPS:~# sudo apt-get install mariadb-server
When installation is complete, run the following command to secure your installation:
mysql_secure_installation
次に、CachetHQインスタンスのデータベースを作成する必要があります。
mysql -uroot -p MariaDB [(none)]> CREATE DATABASE cachet; MariaDB [(none)]> GRANT ALL PRIVILEGES ON cachet.* TO 'cachetuser'@'localhost' IDENTIFIED BY 'cachetuser_passwd'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> \q
PHPとNginxをインストールして構成する
最新バージョンのNginx1.6.2およびPHP5.6は、デフォルトのDebianリポジトリでは利用できないため、Dotdebリポジトリを追加します。 /etc/apt/sources.listを開きます ファイルを作成し、次の行を追加します:
user@myVPS:~# sudo vim /etc/apt/sources.list
deb http://packages.dotdeb.org wheezy all deb http://packages.dotdeb.org wheezy-php56 all
次に、GnuPGキーを取得してインストールします:
user@myVPS:~# wget -qO - http://www.dotdeb.org/dotdeb.gpg | sudo apt-key add -
システムを更新し、Nginx、PHP、および必要なすべての拡張機能をインストールします:
user@myVPS:~# sudo apt-get update user@myVPS:~# sudo apt-get install nginx php5-fpm php5-cli php5-mbstring php5-mcrypt php5-apcu
Composerのインストール
Composerは、パッケージをインストールできるPHPの依存関係マネージャーです。 Composerは、プロジェクトに必要なすべてのライブラリと依存関係を取り込みます。
user@myVPS:~# curl -sS https://getcomposer.org/installer | php user@myVPS:~# sudo mv composer.phar /usr/local/bin/composer
Node GulpandBowerをインストールする
user@myVPS:~# sudo curl -sL https://deb.nodesource.com/setup | bash - user@myVPS:~# apt-get install -y nodejs user@myVPS:~# npm install -g bower user@myVPS:~# npm install -g gulp
CachetHQのインストール
アプリケーションのルートディレクトリを作成します。
user@myVPS:~# mkdir -p ~/your_cachet_site
GitHubからプロジェクトリポジトリのクローンを作成します:
user@myVPS:~# git clone https://github.com/cachethq/Cachet.git ~/your_cachet_site user@myVPS:~# cd ~/your_cachet_site
新しい本番環境ファイルを作成します:
user@myVPS:~# vim .env.php <?php return [ 'DB_DRIVER' => 'mysql', 'DB_HOST' => 'localhost', 'DB_DATABASE' => 'cachet', 'DB_USERNAME' => 'cachetuser', 'DB_PASSWORD' => 'cachetuser_passwd', ];
すべての依存関係をインストールします:
user@myVPS:~# export ENV=production
user@myVPS:~# composer install --no-dev -o
データベースの移行を実行し、サンプルデータをデータベースにシードします:
user@myVPS:~# php artisan migrate user@myVPS:~# php artisan db:seed
アセットの構築:
user@myVPS:~# npm install user@myVPS:~# bower install user@myVPS:~# gulp
NginxとPHPを構成する
ユーザー用に新しいPHP-FPMプールを作成します:
user@myVPS:~# sudo nano /etc/php5/fpm/pool.d/your_user.conf
[your_user] user = your_user group = your_user listen = /var/run/php5-fpm-your_user.sock listen.owner = your_user listen.group = your_user listen.mode = 0666 pm = ondemand pm.max_children = 5 pm.process_idle_timeout = 10s; pm.max_requests = 200 chdir = /
your_userを自分のユーザー名に変更することを忘れないでください。
PHP-FPMを再起動します
user@myVPS:~# sudo service php5-fpm restart
SSL証明書を生成します:
user@myVPS:~# sudo mkdir -p /etc/nginx/ssl user@myVPS:~# cd /etc/nginx/ssl user@myVPS:~# sudo openssl genrsa -des3 -passout pass:x -out cachet.pass.key 2048 user@myVPS:~# sudo openssl rsa -passin pass:x -in cachet.pass.key -out cachet.key user@myVPS:~# sudo rm cachet.pass.key user@myVPS:~# sudo openssl req -new -key cachet.key -out cachet.csr user@myVPS:~# sudo openssl x509 -req -days 365 -in cachet.csr -signkey cachet.key -out cachet.crt
次に、新しいNginxサーバーブロックを作成します:
user@myVPS:~# sudo vim /etc/nginx/sites-available/your_cachet_site
server {
listen 443 default;
server_name your_cachet_site;
ssl on;
ssl_certificate /etc/nginx/ssl/cachet.crt;
ssl_certificate_key /etc/nginx/ssl/cachet.key;
ssl_session_timeout 5m;
ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
root /home/your_user/your_cachet_site/public;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/log/nginx/cachet.access.log;
error_log /var/log/nginx/cachet.error.log;
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-your_user.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_param ENV "production";
}
location ~ /\.ht {
deny all;
}
}
server {
listen 80;
server_name your_cachet_site;
add_header Strict-Transport-Security max-age=2592000;
rewrite ^ https://$server_name$request_uri? permanent;
}
your_userを自分のユーザー名に変更することを忘れないでください。
シンボリックリンクを作成してサーバーブロックをアクティブ化し、nginxを再起動します:
user@myVPS:~# sudo ln -s /etc/nginx/sites-available/your_cachet_site /etc/nginx/sites-enabled/your_cachet_site user@myVPS:~# sudo /etc/init.d/nginx restart
それでおしまい。これで、DebianWheezyVPSにCachetHQが正常にインストールされました。 CachetHQの詳細については、CachetHQのWebサイトを参照してください。
もちろん、Linux VPSホスティングサービスのいずれかを使用している場合は、これを行う必要はありません。その場合は、専門のLinux管理者にセットアップを依頼するだけです。 24時間年中無休でご利用いただけます。リクエストはすぐに処理されます。
PS 。この投稿が気に入った場合は、左側のボタンを使用してソーシャルネットワーク上の友達と共有するか、下に返信を残してください。ありがとう。