さくら VPS Cent OS 7 で nginx PHP7 CAKEPHP3を動かす

基本的な設定から

標準OSにCentOS7があるので楽ちん。

  1. Locale対応
    localectl set-locale LANG=ja_JP.UTF-8
  2. sshd
    /etc/ssh/sshd_config
    port xxxxx
    PermitRootLogin no
    RSAAuthentication yes
    PubkeyAuthentication yes
    PasswordAuthentication no  
  3. Firewall
    sshのポートを変えたのでFirewallに22から変えたよという設定を。
    vi /usr/lib/firewalld/services/ssh.xml
    systemctl reload firewalld
  4. web開発用ユーザ
    useradd -u xxxx -g xxxx -M webuser
    vi /etc/profile
    export PATH=PATH:/usr/local/bin/
    source /etc/profile

 

php 7 インストール

そう、CentOSは7でもyumで入るPHPのバージョンは7じゃない。

yum -y install yum-plugin-priorities

yum -y install epel-release

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

yum -y install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

yum --enablerepo=remi-php70 -y install php php-mbstring php-pear php-fpm php-pdo php-intl php-mysqlnd php-pecl-redis php-xml php-gd php-json

 

Composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php composer-setup.php

php -r "unlink('composer-setup.php');"

mv composer.phar /usr/local/bin/composer

composer

 

nginx インストール

# vi /etc/yum.repos.d/nginx.repo

[nginx]

name=nginx

repo baseurl=http://nginx.org/packages/centos/7/$basearch/

gpgcheck=0

enabled=1

---

yum -y install nginx

nginx -t

systemctl start nginx

systemctl enable nginx

chown -R root:nginx /var/lib/php/*

 

 

Cakephp

Project 作成

composer self-update && composer create-project --prefer-dist cakephp/app