LoginSignup
14
15

More than 5 years have passed since last update.

xamppのPHPを最新バージョンに上げる

Last updated at Posted at 2018-05-26

はじめに

Laravelを試さなくてはいけなくなったので、Laravel開発環境を作らなければいけなくなりました。

WindowsPCなので開発環境はxamppで構築しようと考えていますが、以前PHP開発環境を作るためxamppをインストールしており、PHPのバージョンが古いため、PHPのバージョンを上げることでLaravelの開発環境構築の準備を行いました。

PHPの最新バージョンをダウンロード

ダウンロードはこちら から最新のPHPをダウンロードする。

image.png

ダウンロードしたPHPファイルを配置

xamppフォルダの既存のPHPファイルを念のためバックアップで確保し、上記でダウンロードしたファイルと入れ替える。

image.png

Apacheが起動しない・・・

これで起動すればPHPのバージョンが上がっているはず!
と思ったのですが、エラーが発生してApacheが起動しない・・・

エラー1

phpファイル書き換えにより、Apacheが起動できなくなってしまった。。。
エラーメッセージは以下参照。

1:20:13  [Apache]   Error: Apache shutdown unexpectedly.
1:20:13  [Apache]   This may be due to a blocked port, missing dependencies, 
1:20:13  [Apache]   improper privileges, a crash, or a shutdown by another method.
1:20:13  [Apache]   Press the Logs button to view error logs and check
1:20:13  [Apache]   the Windows Event Viewer for more clues
1:20:13  [Apache]   If you need more help, copy and post this
1:20:13  [Apache]   entire log window on the forums

対策

PHPとApacheの設定を変更
xampp\php\php.ini-development ファイルのファイル名を[php.ini]に変更する。

xampp\apache\conf\extra\httpd-xampp.conf ファイル[php5]という記載を[php7]に変更する。
※僕の環境では元のphpバージョンが 5 なので[php5]という記載になっていたので、環境によっては 5 という数字は変わる可能性があります。

Apacheが起動した

Apacheを起動したことを確認し、xamppシェルでphpのバージョンの確認を行った。

# php -v
PHP 7.2.6 (cli) (built: May 23 2018 20:51:04) ( ZTS MSVC15 (Visual C++ 2017) x86 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

PHPのバージョンが 7 になっていることが確認できた。

14
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
15