Help us understand the problem. What is going on with this article?

Laravel 環境構築 PHP 5.6を利用したいができない! 原因はApacheだった!

More than 3 years have passed since last update.

Laravelを利用したいがPHPのバージョンをアップデートする必要あり。
かなりめんどい

[ec2-user@????????? httpd-2.4.23]$ php -v
PHP 5.6.22 (cli) (built: Jun  1 2016 21:46:41)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
[ec2-user@????????? httpd-2.4.23]$

なんとかできたぜ!

手順
Apache2.4を入れる。
これをいれないと何度PHPをインストールしても古いバージョンのがインストールされる。
そしてLaravelはPHPのバージョンが5.3だとつかえないのだ。

参考 : http://weblabo.oscasierra.net/install-apache24-1/

この記事通りに進んでしてしまうと404のnotfoundになるので、最新のをインストールする。

yum install gcc make pcre pcre-devel wget
# cd /usr/local/src
# wget http://ftp.yz.yamagata-u.ac.jp/pub/network/apache//apr/apr-1.5.2.tar.gz
# tar -xvzf apr-1.5.2.tar.gz
# cd apr-1.5.2
# ./configure --prefix=/opt/apr/apr-1.5.2
# make
# make test
# make install
# cd /usr/local/src
# wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-util-1.5.4.tar.gz
# tar -xvzf apr-util-1.5.4.tar.gz
# cd apr-util-1.5.4
# ./configure --prefix=/opt/apr-util/apr-util-1.5.4 --with-apr=/opt/apr/apr-1.5.2
# make
# make test
# make install
# cd /usr/local/src
# wget http://ftp.jaist.ac.jp/pub/apache//httpd/httpd-2.4.23.tar.gz
# tar -xvzf httpd-2.4.23.tar.gz
# cd /usr/local/src/httpd-2.4.23
# ./configure --prefix=/opt/httpd/httpd-2.4.23 --with-apr=/opt/apr/apr-1.5.2 --with-apr-util=/opt/apr-util/apr-util-1.5.4
# make
# make install
# /opt/httpd/httpd-2.4.9/bin/apachectl start

これで準備OK
PHP 5.6をインストールする
そのご実行

[ec2-user@????? httpd-2.4.23]$ sudo yum install httpd24 php56

参考 : http://we-girls.hatenablog.com/entry/2015/07/23/PHP%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E3%81%A7%E3%82%8F%E3%81%9F%E3%82%8F%E3%81%9F%E3%81%97%E3%81%9F%E8%A9%B1%EF%BC%8ALinux/AWS

だが既存のものと衝突しまくる

--> 依存性解決を終了しました。

エラー: php56-cli conflicts with php-cli-5.3.29-1.8.amzn1.x86_64
エラー: httpd24 conflicts with httpd-2.2.31-1.7.amzn1.x86_64
エラー: php56 conflicts with php-5.3.29-1.8.amzn1.x86_64
エラー: httpd24-tools conflicts with httpd-tools-2.2.31-1.7.amzn1.x86_64
エラー: php56-common conflicts with php-common-5.3.29-1.8.amzn1.x86_64

既存の(衝突した古いバージョン)をひたすらアンインストール

yum remove httpd-tools-2.2.31-1.7.amzn1.x86_64
yum remove php-common-5.3.29-1.8.amzn1.x86_64
yum remove php-cli-5.3.29-1.8.amzn1.x86_64

再度インストールを心見る

$ sudo yum install httpd24 php56
。。。。。。。
PHP 5.6.22 (cli) (built: Jun  1 2016 21:46:41)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
最新版にアップデートできていることを確認する
yum install php56-mbstring

ルードディレクトリで

composer install

vendorの作成は完了
しかしバグ

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/5.6/modules/mcrypt.so' - /usr/lib64/php/5.6/modules/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error:  Class 'PDO' not found in /var/www/html/blog/config/database.php on line 16
Script php artisan optimize handling the post-update-cmd event returned with an error


  [RuntimeException]
  Error Output: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/5.6/modules/mcrypt.so' - /usr/lib64/php/5.6
  /modules/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
  PHP Fatal error:  Class 'PDO' not found in /var/www/html/blog/config/database.php on line 16


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...

ブラウザ画面

スクリーンショット 2016-07-10 19.41.45.png

$yum search mcrypt
$sudo yum install php56-mcrypt

参考記事 :http://qiita.com/MasatoYoshioka@github/items/1b4de4249dc40ff1d902

再度

$ composer install

実行結果

PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> php artisan clear-compiled
PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
PHP Fatal error:  Class 'PDO' not found in /var/www/html/laravel4/app/config/database.php on line 16
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'PDO' not found","file":"\/var\/www\/html\/laravel4\/app\/config\/database.php","line":16}}Script php artisan clear-compiled handling the post-install-cmd event returned with an error


  [RuntimeException]
  Error Output: PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
  PHP Fatal error:  Class 'PDO' not found in /var/www/html/laravel4/app/config/database.php on line 16


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...

ブラウザで表示

Error in exception handler.

権限の問題らしい!

$ chmod -R 777 storage

成功 !(ブラウザ表示)

スクリーンショット 2016-07-10 20.09.09.png

MVCを利用する
サンプルをクローン

$composer install

エラー
Script php artisan clear-compiled handling the post-install-cmd event returned with an error


  [RuntimeException]
  Error Output: PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
  PHP Fatal error:  Class 'PDO' not found in /var/www/html/l4-sample-todo/app/config/database.php on line 16
$ sudo yum install php56-pdo

新たなエラー

Database dose not exist
php artisan migrate

l4-sample-todo]$ php artisan migrate
PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
Migration table created successfully.
Migrated: 2015_01_01_000001_create_sessions_table
Migrated: 2015_01_01_000002_create_todos_table

ブラウザで表示

SQLSTATE[HY000]: General error: 8 attempt to write a readonly database (SQL: insert into "sessions" ("id", "payload", "last_activity") values (776388d5b8a98ba253a9e7df2332096cf836126a, YTo0OntzOjY6Il90b2tlbiI7czo0MDoia1FsMmFYdHlzZlVXcDA3dGNUU25vdVhyZTZhSzFqRDJJVHN4dzhjbiI7czoyMjoiUEhQREVCVUdCQVJfU1RBQ0tfREFUQSI7YTowOnt9czo5OiJfc2YyX21ldGEiO2E6Mzp7czoxOiJ1IjtpOjE0NjgyMTk2NDE7czoxOiJjIjtpOjE0NjgyMTk2NDE7czoxOiJsIjtzOjE6IjAiO31zOjU6ImZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=, 1468219641))

$ php artisan migrate --seed
PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0
Migration table created successfully.
Migrated: 2015_01_01_000001_create_sessions_table
Migrated: 2015_01_01_000002_create_todos_table

解決 注: migrateだけだとよくワカンないエラーが出る

とりあえず画面は表示されたぜ!!

Todoリストは成功

別ファイるエラー
http://promamo.com/?p=3312

参考記事

-原因はapache
http://we-girls.hatenablog.com/entry/2015/07/23/PHP%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%87%E3%83%BC%E3%83%88%E3%81%A7%E3%82%8F%E3%81%9F%E3%82%8F%E3%81%9F%E3%81%97%E3%81%9F%E8%A9%B1%EF%BC%8ALinux/AWS

-apache2.4の利用
http://weblabo.oscasierra.net/install-apache24-1/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away