20. CMS構築 – WordPress/baserCMS [さくらのVPS/CentOS7]

・WordPress のインストール

#-- 変数に必要な値を代入
HTTPS_DOCROOT=/var/www/html/https_root

#-- wordpress のインストール
cd ~/work/src/
curl -L -o wordpress.tar.gz http://wordpress.org/latest.tar.gz
tar xvzf wordpress.tar.gz
mv wordpress ${HTTPS_DOCROOT}/wordpress
chown -R nginx. ${HTTPS_DOCROOT}/wordpress

#-- wordpress database の作成
mysql -e "create database wordpress character set utf8 collate utf8_bin;"
#-- database の password は お好みで
mysql -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost' IDENTIFIED BY 'wppassword' ;"
mysql -e "FLUSH PRIVILEGES;"

#-- wordpress の設定
cp -p ${HTTPS_DOCROOT}/wordpress/wp-config-sample.php ${HTTPS_DOCROOT}/wordpress/wp-config.php

sed -i -e 's/database_name_here/wordpress/' \
       -e 's/username_here/wpuser/' \
       -e 's/password_here/wppassword/' ${HTTPS_DOCROOT}/wordpress/wp-config.php

cat <<'_EOL_' > /etc/nginx/conf.d/https.d/wordpress.conf
  location ^~ /wordpress {
    location /wordpress/wp-content/uploads {
      location ~ \.php$ {
          deny all;
      }
    }

    location /wordpress/ {
      try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
      include fastcgi_params;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
      expires max;
      log_not_found off;
    }
  }
_EOL_

systemctl restart nginx

Web画面からインストールを続ける。管理者アカウントの設定もある為、直ぐに実施すること
https://masdon.life/wordpress/

・baserCMSのインストール

#-- 変数に必要な値を代入
HTTPS_DOCROOT=/var/www/html/https_root

#-- baserCMS の database を作成
mysql -e "create database basercms character set utf8 collate utf8_bin;"
#-- database の password は お好みで
mysql -e "GRANT ALL PRIVILEGES ON basercms.* TO 'basercms'@'localhost' IDENTIFIED BY 'baserpass' ;"
mysql -e "FLUSH PRIVILEGES;"

#-- baserCMS のインストール
cd ~/work/git
git clone https://github.com/baserproject/basercms.git
cp -pr basercms ${HTTPS_DOCROOT}/blog
#-- ******** は admin アカウントのパスワード
${HTTPS_DOCROOT}/blog/app/Console/cake bc_manager install \
  "https://masdon.life/blog" \
  mysql \
  admin \
  ******** \
  admin@masdon.life \
  --host localhost \
  --database "basercms" \
  --port 3306 \
  --login "basercms" \
  --password "baserpass" \
  --data 'bc_sample.default'

chown -R nginx. /var/www/html/https_root/blog

#-- nginx の設定追加
cat <<'_EOL_'> /etc/nginx/conf.d/https.d/blog.conf
    location /blog/theme/ {
        alias /var/www/html/https_root/blog/app/webroot/theme/;
    }

    location =/blog/ {
        rewrite ^ /blog/index.php;
    }
    location /blog {
        if ( !-e $request_filename ) {
            rewrite ^ /blog/index.php last;
        }
    }
_EOL_

systemctl reload nginx

管理ページ: https://masdon.life/blog/admin