---
title: "ECCUBE3構築 Compute Engine | grasys blog"
url: "https://blog.grasys.io/post/yusukeh/gce_eccube3/"
description: "こんにちはgrasys長谷川です。 今回はECCUBE3を構築してみました。 システム要件 - ECCUBE3 php7系ががががが！！！！ 内容は基本セットアップして入れて起動しただけです。 OSの設定の話やMiddlewareの設定の話も必要になってきますが、長くなりすぎちゃうのでどんどん省略します！ｗ 環境 E…"
---

# ECCUBE3構築 Compute Engine

-   ![](/_astro/noicon.CTHOhNiB_1HMs6A.webp)[yusukeh](/authors/yusukeh/)
-   公開日：2016年10月25日
-   カテゴリー：[Tech](/categories/tech/)
-   タグ：[#eccube3](/tags/eccube3/)[#Compute Engine](/tags/compute-engine/)

![ECCUBE3構築 Compute Engine](/_astro/ogp.ByE5zKjq_Z1ySPxP.webp)

こんにちはgrasys長谷川です。

今回は[ECCUBE3](https://www.ec-cube.net/)を構築してみました。

[システム要件 - ECCUBE3](https://www.ec-cube.net/product/system.php)

php7系ががががが！！！！

内容は基本セットアップして入れて起動しただけです。

OSの設定の話やMiddlewareの設定の話も必要になってきますが、長くなりすぎちゃうのでどんどん省略します！ｗ

## 環境

| Envronment | Description |
| --- | --- |
| Compute Engine Image | centos-7-v20160921 |
| OS | CentOS7 CentOS Linux release 7.2.1511 (Core) |
| Web Server | nginx-1.10.1 |
| PHP | phpenv 7.0.11 |
| Database | Percona-Server 5.6.33 |

## Install Database

今回は何でも良かったんだけど・・・

Percona-Serverで入れてみる

### yumのrepo

Plain textcontent\_copy

```
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
```

### Install Percona Server

Plain textcontent\_copy

```
yum install \
  Percona-Server-shared-56 \
  Percona-Server-devel-56 \
  Percona-Server-client-56 \
  Percona-Server-server-56
```

これだけで完了！

気になる人は適当にして下さい。

-   `/etc/yum.repos.d/percona-release.repo`を`enable=0`にしたり
-   `datadir`の位置変更して`mysql_install_db`したり
-   `/etc/my.cnf`書き換えてチューニングしたり

自分はしてますが、ここでは省略！

### user nginx

nginxもphp-fpmも一旦nginx userで動かす想定なので作っとく！

Plain textcontent\_copy

```
username=nginx
group=nginx
uid=80
gid=80
home=/usr/local/nginx
shell=/sbin/nologin
groupadd -g $gid $group
useradd -M -d $home -g $group -u $uid $username
```

### Disable SELinux

めんどいんで一旦disableにしちゃいましょう

Plain textcontent\_copy

```
setenforce 0
getenforce
sed -i -e "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
```

ここで一度rebootしときましょう！

Plain textcontent\_copy

```
shutdown -r now

or

reboot
```

## Setup phpenv

### Install build tools

build toolsをまずInstall

Plain textcontent\_copy

```
yum -y groupinstall "Development Tools"
```

あといろいろphpをbuildするときに適当に言われるLibやらheaderをInstall

Plain textcontent\_copy

```
yum -y install \
  openssl-devel \
  pcre-devel \
  libxml2-devel \
  libcurl-devel \
  zlib-devel \
  libzip-devel \
  bzip2-devel \
  gd-devel \
  readline-devel \
  libxslt-devel
```

re2cも入れとく

Plain textcontent\_copy

```
curl -L -o /tmp/re2c-0.16.tar.gz https://github.com/skvadrik/re2c/releases/download/0.16/re2c-0.16.tar.gz
test -f /tmp/re2c-0.16.tar.gz && cd /tmp/ && tar -xvzf re2c-0.16.tar.gz
cd re2c-0.16
./configure \
    --prefix=/usr/local/`basename $PWD`
make
make install

test -d /usr/local/re2c-0.16 && ln -s /usr/local/re2c-0.16 /usr/local/re2c

export PATH=$PATH:/usr/local/re2c/bin

cat << EOL > /etc/profile.d/re2c.sh
export PATH=\$PATH:/usr/local/re2c/bin
EOL
```

### Install phpenv

[phpenv](https://github.com/CHH/phpenv)を使ってます。

Plain textcontent\_copy

```
export PHPENV_ROOT=/usr/local/phpenv

cat << EOL > /etc/profile.d/phpenv.sh
export PHPENV_ROOT=/usr/local/phpenv
if [ -d \$PHPENV_ROOT -a -x \$PHPENV_ROOT/bin/phpenv ]; then
  export PATH=\$PATH:/usr/local/phpenv/bin
  eval "\$(phpenv init -)"
fi
EOL

test ! -d /tmp/phpenv && \
  git clone --depth 1 https://github.com/CHH/phpenv.git /tmp/phpenv
test -x /tmp/phpenv/bin/phpenv-install.sh && /tmp/phpenv/bin/phpenv-install.sh
test ! -d /usr/local/phpenv/plugins/php-build && \
  git clone --depth 1 https://github.com/php-build/php-build.git /usr/local/phpenv/plugins/php-build
```

bashの環境変数周りいじってるので1度、logoutしてloginし直して下さいね〜〜

### Install php 7.0.11

phpenvのphp-buildには`definitions`というbuild parameterがありまして  
こいつがけっこうめんどいので自分は書き換えちゃったりしてますｗｗｗ

-   `/usr/local/phpenv/plugins/php-build/share/php-build/default_configure_options`
-   `/usr/local/phpenv/plugins/php-build/share/php-build/definitions/[version]`

Plain textcontent\_copy

```
cp -p /usr/local/phpenv/plugins/php-build/share/php-build/default_configure_options /usr/local/phpenv/plugins/php-build/share/php-build/default_configure_options.org
vi /usr/local/phpenv/plugins/php-build/share/php-build/default_configure_options
```

なんか今回とくにあれなんで適当にやってます。  
mcrypt入れてないので消しちゃったりとかして・・・

自分はconfig系をgitで管理していたりするので  
`--with-config-file-path`や`--with-config-file-scan-dir`を設定してます。

### phpenv install

phpenvでphp-buildを利用して今回の対象の`7.0.11`をInstallします。

以下でInstall可能なVersion一覧が確認できます。

Plain textcontent\_copy

```
phpenv install -l
```

InstallしたいVersionがなかったら  
php-buildをpullしてみればあるかも？

Plain textcontent\_copy

```
cd /usr/local/phpenv/plugins/php-build && git pull origin master
```

それじゃbuild！！！

Plain textcontent\_copy

```
phpenv install 7.0.11
```

しばし待つ・・・

待つ・・・

待つ・・・

たぶん入ると思います！  
mcryptくらいじゃないかなBuildErrorしちゃう理由（さっきいろんなLibとheaderも入れてるし・・・）  
mcryptでコケたら`/usr/local/phpenv/plugins/php-build/share/php-build/default_configure_options`これいじって貰えれば！

コケたらTerminalに出力されるので！  
たぶん`/tmp/php-build.7.0.11.NNNNNNNNNNNNNNN.log`みたいな感じで吐かれてるので末尾20行くらい眺めれば理由がわかるかと！

### Install確認

Plain textcontent\_copy

```
ls /usr/local/phpenv/versions/
7.0.11

ls /usr/local/phpenv/versions/7.0.11/
bin  etc  include  lib  libexec  php  sbin  share  var
```

入ってるので

### phpenv global

PHPだし思いっきりSystem標準としてｗ

Plain textcontent\_copy

```
phpenv global 7.0.11
phpenv rehash

which php
/usr/local/phpenv/shims/php

php -v
PHP 7.0.11 (cli) (built: Oct 18 2016 08:00:10) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.11, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans

php -i

phpinfo()
PHP Version => 7.0.11

System => Linux dev01 3.10.0-327.36.1.el7.x86_64 #1 SMP Sun Sep 18 13:04:29 UTC 2016 x86_64
...
...
しょーりゃく！
...
...
```

-   apcu
-   opcache

ここでは書きませんが自分は入れてるしちょっと設定いじったりしてます。

### setup php-fpm

| config file/dir | PATH |
| --- | --- |
| etc | /usr/local/phpenv/versions/7.0.11/etc |
| php.ini | /usr/local/phpenv/versions/7.0.11/etc/php.ini |
| conf.d | /usr/local/phpenv/versions/7.0.11/etc/conf.d |
| php-fpm.conf | 存在せず /usr/local/phpenv/versions/7.0.11/etc/php-fpm.conf.default これを元に作る！ |
| php-fpm.d | /usr/local/phpenv/versions/7.0.11/etc/php-fpm.d |

### php-fpm.conf

Plain textcontent\_copy

```
cp -p /usr/local/phpenv/versions/7.0.11/etc/php-fpm.conf.default /usr/local/phpenv/versions/7.0.11/etc/php-fpm.conf
```

Plain textcontent\_copy

```
tail /usr/local/phpenv/versions/7.0.11/etc/php-fpm.conf
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr/local/phpenv/versions/7.0.11 otherwise
include=/usr/local/phpenv/versions/7.0.11/etc/php-fpm.d/*.conf
```

`/usr/local/phpenv/versions/7.0.11/etc/php-fpm.conf`の末尾に  
includeがあるのでわかると思いますが poolの設定を入れます。

Plain textcontent\_copy

```
cd php-fpm.d

vi eccube3.conf
```

Plain textcontent\_copy

```
[eccube3]
listen = /tmp/$pool.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
user = nginx
group = nginx
request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm/slowlog-$pool.log
listen.allowed_clients = 127.0.0.1
pm = static
pm.max_children = 10
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 30
pm.max_requests = 5000
listen.backlog = -1
pm.status_path = /system/php_fpm_status
request_terminate_timeout = 60s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
```

`request_slowlog_timeout`はちょっと厳しすぎるかもしれない・・・汗  
Machine-SizeとRequest数次第だと思うけどｗ

`pm`.xxxxあたりは適当にどうぞ

おもむろに起動！

Plain textcontent\_copy

```
mkdir -p /var/log/php-fpm
chown -R nginx.nginx /var/log/php-fpm

/usr/local/phpenv/versions/7.0.11/sbin/php-fpm \
  --daemonize \
  -c /usr/local/phpenv/versions/7.0.11/etc/php.ini \
  --fpm-config /usr/local/phpenv/versions/7.0.11/etc/php-fpm.conf
```

systemdのserviceは適当に作って下さい

## Install nginx

[nginx](https://nginx.org/en/)

configure paramは適当にどっかのサーバから持ってきたんで適当ですｗ

Plain textcontent\_copy

```
curl -L -o /tmp/nginx-1.10.2.tar.gz https://nginx.org/download/nginx-1.10.2.tar.gz
test -f /tmp/nginx-1.10.2.tar.gz && cd /tmp/ && tar -xvzf nginx-1.10.2.tar.gz
cd nginx-1.10.2
./configure \
  --prefix=/usr/local/`basename $PWD` \
  --user=nginx \
  --group=nginx \
  --with-poll_module \
  --with-file-aio \
  --with-http_ssl_module \
  --with-http_addition_module \
  --with-http_sub_module \
  --with-http_realip_module \
  --with-http_stub_status_module \
  --with-http_dav_module \
  --with-http_flv_module \
  --with-http_random_index_module \
  --with-http_secure_link_module \
  --with-http_gunzip_module \
  --with-http_gzip_static_module \
  --with-http_degradation_module \
  --without-mail_pop3_module \
  --without-mail_imap_module \
  --without-mail_smtp_module 
make
make install

test -d /usr/local/nginx-1.10.2 && ln -s /usr/local/nginx-1.10.2 /usr/local/nginx

cat << EOL > /etc/profile.d/nginx.sh
export PATH=\$PATH:/usr/local/nginx/sbin
EOL
```

もーさっきからめんどくさくて`/etc/profile.d`にいろいろ追加しちゃうｗｗ

> あんまよくないと思いますｗ

### setting nginx

nginxのconfigは  
Installしたprefixの中にあります。

`/usr/local/nginx/conf`

### nginx.conf

server sectionの中にphpの記載がコメントアウトされてますが  
先程php-fpmの設定でsocketを指定してたりするので無視して下さいｗ

Plain textcontent\_copy

```
    root /opt/eccube/html;
    location / {
      index index.html index.htm index.php;
      try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php {
      include       /usr/local/etc/nginx/conf/fastcgi_params;
      fastcgi_pass  unix:/tmp/eccube3.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
    }
```

こんなの追加すれば**多分**動きます！

実際に自分が構成したnginxのconfig treeは可用性を高めるためincludeを多様していて  
nginxがよくわからないと触りにくいと思うので公開するのやめてますｗ

起動してみる

> defaultのnginx.confはerror\_logもaccess\_logもコメントアウトされてるというｗ`nginx.conf`のpathをよくみて！directory permissionも確認してね！

config test

Plain textcontent\_copy

```
nginx -c /usr/local/nginx/conf/nginx.conf -t
```

Plain textcontent\_copy

```
nginx -c /usr/local/nginx/conf/nginx.conf
```

## ECCUBE3

以下のLinkでUser登録をするとDownloadできます。 [ECサイト構築・リニューアルは「ECオープンプラットフォームEC-CUBE」](http://www.ec-cube.net/)

zipをDownloadしたらサーバにUploadして  
展開して下さい。

### eccube\_install.sh

このInstaller Shellの中身をみるとわかるのですが

Plain textcontent\_copy

```
export DBSERVER=${DBSERVER-"127.0.0.1"}
export DBNAME=${DBNAME:-"cube3_dev"}
export DBUSER=${DBUSER:-"cube3_dev_user"}
export DBPASS=${DBPASS:-"password"}
```

こんな感じになっていて環境変数で渡せます。

Plain textcontent\_copy

```
DBSERVER=xxxxxxxxx \
DBNAME=xxxxx \
DBUSER=xxxxxx \
DBPASS=xxxxx ./eccube_install.sh mysql
```

Installでエラーでるかもしれない・・・  
もしかしたらCREATE DATABASEをしたかもしれない・・・（記憶がない・・・ｗ

## とりあえず動作しました。

php7系で動いた！

後半、blog書くのに力尽きた感が強いｗ

## この記事を書いた人

[![](/_astro/yusukeh.BvUd2yKE_1mQ6Fp.webp)](/authors/yusukeh/)

### [yusukeh](/authors/yusukeh/)

Fly high. Think deep. Move fast. Go far.🦅

-   [X](https://x.com/yusukeh "X")
-   [GitHub](https://github.com/yusukeh "GitHub")
-   [Medium](https://medium.com/@yusukeh "Medium")
-   [Facebook](https://www.facebook.com/yusuke.exzm "Facebook")
-   [Instagram](https://www.instagram.com/yusukehasegawa/ "Instagram")
-   [LinkedIn](https://www.linkedin.com/in/hasegawa-yusuke-091b4164/ "LinkedIn")

[プロフィールと記事一覧](/authors/yusukeh/)
