私が試行錯誤しながら進め記事を書いたので、手順が前後してしまっているかもしれないです。
この記事を書いているときに、EC-CUBEの公式ドキュメントで、対応しているPHPのバージョンが8が含まれました。
そのため、この記事を続けて書いてます。
また、公式ドキュメントをよく読まずに進めたので、余分な作業があります。
この記事の後半では、ちゃんと説明できていると思います。
少なくともUbuntu22.04では、EC-CUBEの開発環境を作るのは、慎重になった方が良いことは、今回のことで分かりました。
その理由も、この記事の後半を読むと理解できます。
下記の記事を見つけたので、実行しました。
sudo wget https://get.symfony.com/cli/installer -O - | bash
最初sudoを付けずに行いましたが、上手く行かなったようです。
私が、パスの設定が出来なかっただけかもしれないですが。
ターミナルのメッセージで、下記が出ました。
‘wget-log’ に出力をリダイレクトします。
Symfony CLI installer
Environment check
[*] cURL is installed
[*] Tar is installed
[*] Git is installed
[*] Your architecture (amd64) is supported
Download
Downloading https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_linux_amd64.tar.gz...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0
100 5232k 100 5232k 0 0 25014 0 0:03:34 0:03:34 --:--:-- 27322
Uncompress binary...
Installing the binary into your home directory...
The binary was saved to: /home/masaru/.symfony5/bin/symfony
The Symfony CLI was installed successfully!
Use it as a local file:
/home/***/.symfony5/bin/symfony
Or add the following line to your shell configuration file:
export PATH="$HOME/.symfony5/bin:$PATH"
Or install it globally on your system:
mv /home/***/.symfony5/bin/symfony /usr/local/bin/symfony
Then start a new shell and run 'symfony'
記事有る通りに、下記のコマンドを実行しました。
symfony composer selfupdate --1
このようなメッセージが、表示されました。
Storing "stable" as default update channel for the next self-update run.
Warning: You forced the install of 1.10.26 via --1, but 2.5.1 is the latest stable version. Updating to it via composer self-update --stable is recommended.
Upgrading to version 1.10.26 (1.x channel).
Use composer self-update --rollback to return to version 2.5.1
私は、PHPをインストールしていませんでした。
phpenvをインストールしてから、PHPをインストールしてください。
phpenvのインストール方法は、この記事の下の方で、ご案内しています。
ネットの記事は色々ありますが、今はgithubでクローンを作る方法がhttpsを使うことが推奨されているようです。
私は、手順を間違えたので、下記のコマンドがないとエラーになりました。
```bash
composer self-update --rollback to return to version 2.5.1
コマンド 'composer' が見つかりません。次の方法でインストールできます:
sudo apt install composer
そのためインストールを実行したら、PHPも8.1がインストールされました。
PHP 8.1.2-1ubuntu2.9 (cli) (built: Oct 19 2022 14:58:09) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.9, Copyright (c), by Zend Technologies
このエラーが、出ました。
symfony composer selfupdate --1
Warning: You forced the install of 1.10.26 via --1, but 2.5.1 is the latest stable version. Updating to it via composer self-update --stable is recommended.
You are already using composer version 1.10.26 (1.x channel).
下記の記事を参考にして、下記のコマンドを実行しました。
symfony composer selfupdate --2
Updating to version 2.5.1 (2.x channel).
Downloading (100%)
Use composer self-update --rollback to return to version 1.10.26
こちらの記事を基に、Composerをインストールしました。
symfony console eccube:install -n
Could not open input file: bin/console
下記の記事が、みつかりました。
このコマンドを実行しました。
composer require symfony/console
下記のコマンドの状態で、インストールが成功したそうです。
下記の記事で、確認しました。
symfony composer install
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating autoload files
8 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
このコマンドでEC-CUBE4がインストールできると私が参考にした記事では説明がありましたが、実際は違うようです。
symfony console eccube:install -n
Could not open input file: bin/console
下記の記事を読みました。
Gitからtestsのフォルダの中身を一括してダウンロードしようとしましたが、設定が上手く行きませんでした。
そのため、こちらの手順で、行いました。
PHPのバージョンが合わず、エラーになりました。
php composer.phar create-project ec-cube/ec-cube ec-cube "4.1.x-dev" --keep-vcs
Creating a "ec-cube/ec-cube" project at "./ec-cube"
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Info from https://repo.packagist.org: #StandWithUkraine
[InvalidArgumentException]
Could not find package ec-cube/ec-cube with version 4.1.x-dev in a version installable using your PHP version 8.1.2.
PHPのバージョンを管理できるように、下記の記事を参考にしてPHP Version Manager (PVM)をインストールしました。
PHPのバージョンが8以上は正常時にビルドできるのに
これ以前のものは、opensslの影響でビルドできない状態です。
OpenSSlの1のバージョンが必要なのですが、Ubuntu22.04には、OpenSSL3のみのため、古いバージョンは、ビルドできない問題が他のプログラム言語でもあることが分かりました。
そのため、Ubuntuのバージョンを20.04より前の古いバージョンなら、EC-CUBEの開発環境を作ることができるのでは?と考えました。
Githubで教えてもらったので
Githubで教えてもらえたので、検索して下記の記事を見つけ実行しました。
でも、改善されませんでした。
OpenSSLのバージョンの古いものが、必要だと思います。
PHPのComposerのインストール方法
下記の記事を見つけました。
Composerを使ったSymfony2.1のインストール方法
こちらの記事が、分かりやすいです。
パスを固定
上記の記事で追加したパスを固定されるように、テキストエディタで下記のように書きました。
vi ~/.profile
PATH=$PATH:home/ユーザー名/bin:$PATH
export PATH
#再読み込み
source ~/.profile
これで、下記のコマンドを実行して、インストールしました。
composer.phar create-project symfony/framework-standard-edition ./Symfony21/ 2.1.3
EC-CUBEの説明で、下記のコマンドを実行します。
でも、そのままでは、エラーになります。
下記のcomposer.jsonというファイルが、必要になります。
私は、下記のコマンドで、対話形式で作りました。
composer init
コマンドラインからインストールを試しました。
下記の記事では、上手くインストールできないため、コマンドラインからインストールを試すことにしました。
こちらが、コマンドラインからインストールの説明のページです。
zipファイルのコマンドが必要
sudo apt-get install zip
下記のコマンドで、EC-CUBE Ver4.2をインストールしましたが、下記のようにエラーになります。
やはりPHPのバージョンを下げないとインストールは、難しいのかもしれません。
composer.phar create-project ec-cube/ec-cube ec-cube "4.2.x-dev" --keep-vcs
このコマンドの後に、下記のコマンドを実行してインストールできました。
symfony composer install
PHPのバージョンが8.1.0の時は、EC-CUBEのインストールのバージョンを4.2に変えるとインストールできます。
古いPHPのバージョン
古いバージョンのPHPをphpenvでインストールするときは、Opensslのオプションを付けると教えて頂きました。
Yes. You need to install OpenSSL 1.1.1 and --with-openssl=/path/to/openssl build option.
詳しくは、こちらのGitHubを読んでください。
Opensslのインストール
こちらの記事を見つけました。
wget https://www.openssl.org/source/openssl-1.1.1s.tar.gz;
tar xvf openssl-1.1.1s.tar.gz;
cd openssl-1.1.1s/;
./Configure --prefix=/opt/build --openssldir=/opt/build -fPIC -shared linux-x86_64;
make -j 8 && make install;
cd ../;
上記のコードで、エラーが出ました。
make depend && make _build_libs
make[1]: Entering directory '/home/masaru/openssl-1.1.1s'
make[1]: Leaving directory '/home/masaru/openssl-1.1.1s'
make[1]: Entering directory '/home/masaru/openssl-1.1.1s'
make[1]: Nothing to be done for '_build_libs'.
make[1]: Leaving directory '/home/masaru/openssl-1.1.1s'
Cannot create directory /opt/build: Permission denied
make: *** [Makefile:436: install_runtime_libs] エラー 2
下記のように、ディレクトリを作り解決しました。
sudo mkdir /opt/build
sudo chmod 777 /opt/build
私は、参考にした記事のようにパスをディフォルトに設定しないで、GitHubで教えてもらったように、直接指定します。
下記のエラーは、PHP1.2.34がopenssl1.1.1に対応していないためのエラーだそうです。
ChatGPTの回答です。
PHP7.3以上からOpenssl1.1.1に対応しているようです。
phpenv install 7.2.34 --with-openssl=/home/***/openssl-1.1.1s/openssl build option
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.2.34 into /home/masaru/.phpenv/versions/7.2.34
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.2.34.tar.bz2
[Preparing]: /tmp/php-build/source/7.2.34
[Compiling]: /tmp/php-build/source/7.2.34
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
| ^~~~~~~~~~~~~~~~~
/tmp/php-build/source/7.2.34/ext/openssl/openssl.c:5826:41: warning: passing argument 4 of ‘RSA_public_decrypt’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
5826 | EVP_PKEY_get0_RSA(pkey),
| ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/php-build/source/7.2.34/ext/openssl/openssl.c:47:
/usr/include/openssl/rsa.h:289:29: note: expected ‘RSA *’ {aka ‘struct rsa_st *’} but argument is of type ‘const struct rsa_st *’
289 | RSA *rsa, int padding);
| ~~~~~^~~
make: *** [Makefile:703: ext/openssl/openssl.lo] エラー 1
make: *** 未完了のジョブを待っています....
-----------------------------------------
The full Log is available at '/tmp/php-build.7.2.34.20230113132541.log'.
[Warn]: Aborting build.
回線速度も重要
下記のコマンドを実行すると、181件ダウンロードが始まります。
私は回線が遅いため、途中でタイムアウトになってしまいました。
続きのダウンロードができない仕組みのようなので、回線速度には気を付けてください。
symfony composer install
パッケージのインストールができない状態
omposer.phar create-project ec-cube/ec-cube ec-cube "4.2.x-dev" --keep-vcs
Creating a "ec-cube/ec-cube" project at "./ec-cube"
Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Info from https://repo.packagist.org: #StandWithUkraine
Installing ec-cube/ec-cube (4.2.x-dev 12cb21a1d501632d58d71653473ed7b3eaf80a46)
- Installing ec-cube/ec-cube (4.2.x-dev 12cb21a): Cloning 12cb21a1d5
Failed to download ec-cube/ec-cube from source: The process "git clone --no-checkout -- 'https://github.com/EC-CUBE/ec-cube.git' '/home/masaru/ドキュメント/EC-CUBE/ec-cube/' && cd '/home/masaru/ドキュメント/EC-CUBE/ec-cube/' && git remote add composer -- 'https://github.com/EC-CUBE/ec-cube.git' && git fetch composer && git remote set-url origin -- 'https://github.com/EC-CUBE/ec-cube.git' && git remote set-url composer -- 'https://github.com/EC-CUBE/ec-cube.git'" exceeded the timeout of 300 seconds.
Now trying to download from dist
- Installing ec-cube/ec-cube (4.2.x-dev 12cb21a): Loading from cache
Created project in /home/masaru/ドキュメント/EC-CUBE/ec-cube
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for doctrine/dbal 3.5.2 -> satisfiable by doctrine/dbal[3.5.2].
- doctrine/dbal 3.5.2 requires composer-runtime-api ^2 -> no matching package found.
Problem 2
- Installation request for doctrine/migrations 3.5.2 -> satisfiable by doctrine/migrations[3.5.2].
- doctrine/migrations 3.5.2 requires composer-runtime-api ^2 -> no matching package found.
Problem 3
- Installation request for doctrine/orm 2.14.0 -> satisfiable by doctrine/orm[2.14.0].
- doctrine/orm 2.14.0 requires composer-runtime-api ^2 -> no matching package found.
Problem 4
- doctrine/dbal 3.5.2 requires composer-runtime-api ^2 -> no matching package found.
- dama/doctrine-test-bundle v6.7.5 requires doctrine/dbal ^2.9.3 || ^3.0 -> satisfiable by doctrine/dbal[3.5.2].
- Installation request for dama/doctrine-test-bundle v6.7.5 -> satisfiable by dama/doctrine-test-bundle[v6.7.5].
Potential causes:
- This package is not installable via Composer 1.x, see <https://blog.packagist.com/deprecating-composer-1-support/>
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
ディレクトリが空でない
ディレクトリを削除してから、インストールしましょう。
[InvalidArgumentException]
Project directory "/home/***/ドキュメント/EC-CUBE/ec-cube" is not empty.
下記のコマンドを実行して、中身があっても削除できます。
rm -r ec-cube
もしphpenvをインストールしてPHPをインストールしたときに、下記のエラーが出たとき
php -vと入力したときに、
.phpenv/libexec/phpenv-global: 行 47: php-config: コマンドが見つかりません
この時は、下記のコマンドを実行すると直ります。
こちらが、元記事です。
export PATH="$HOME/.phpenv/bin:$PATH"
eval "$(phpenv init -)"
結論
この画像の通りで、Ubuntu20.04なら正常にPHP7.4.3など古いPHPのインストールが出来ることが分かりました。
したがって、Ubuntu22.04は、OpenSSLのバージョンの関係で、古いPHPは、インストールが困難だと結論できると思います。
そのためEC-CUBEの開発環境は、Ubuntu20.04で開発環境を作ると良いです。

omposer1は、非推奨のようです。
このエラーというか、警告でます。
Use composer self-update --rollback to return to version 2.5.1
composerは、バージョンが上がっていて2を使うようです。
EC-CUBEがcomposerのバージョン1を使うため、誤ってcomposerのバージョンを上げないように気を付けましょう。

公式のコマンドラインからインストールを試すとエラーが出ます。
#下記のコマンドを実行すると、エラーになります。
php composer.phar create-project ec-cube/ec-cube ec-cube "4.1.x-dev" --keep-vcs
#エラーの内容
[RuntimeException]
Could not read ./composer.json
file_get_contents(./composer.json): failed to open stream: No such file or directory
インストール成功
公式ドキュメントの「ComposerからWebインストーラでインストールする」で、インストールできました。

