コンテンツ
ConoHa VPSへPHPの最新バージョンをインストールする方法
こちらの記事では、
ConoHa VPSサーバーへのPHPの最新バージョンをインストールする方法をまとめています。
※現時点での最新バージョンは、PHP7.0.6です。
PHPをインストール
■PHPをインストール
# cd /usr/local/src/
# wget http://jp2.php.net/distributions/php-7.0.6.tar.gz
# tar xzvf php-7.0.6.tar.gz
# cd php-7.0.6
# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --libdir=/usr/lib64 --with-libdir=lib64 --with-curl --disable-debug --with-pic --disable-rpath --without-pear --with-bz2 --with-freetype-dir --with-png-dir --with-xpm-dir --enable-gd-native-ttf --without-gdbm --with-gettext --with-iconv --with-jpeg-dir --with-openssl --with-pcre-regex --with-zlib --enable-exif --enable-ftp --enable-sockets --enable-calendar --with-libxml-dir --enable-xml --with-mhash --enable-mbstring --enable-mbregex --with-gd --enable-bcmath --with-xmlrpc --with-mysqli --with-curl --with-pdo-mysql --enable-json --enable-zip --without-readline --with-mcrypt
# make
# make install
と順番に実行していけば、
インストールは完了します。
念の為に、
# php -v
として、
=========================================================
PHP 7.0.6 (cli) (built: Apr 28 2016 22:26:18) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
=========================================================
というようにバージョンが表示されれば、
PHP7.0.6がインストールされています。
■ApacheからPHP7を読み込めるようにする
# vi /usr/local/apache2/conf/httpd.conf
として、
Apacheの設定ファイルに以下を追記します。
================================================
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
================================================
※<IfModule mime_module>・・</IfModule>の中に追記して下さい。
これにより、Apacheが.phpという拡張子のファイルをPHPのスクリプトファイルであることを認識できるようになります。
■DirectoryIndexにindex.phpを追加
# vi /usr/local/apache2/conf/httpd.conf
として、
Apacheの設定ファイルの
==========================================
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
==========================================
の部分を
==========================================
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
==========================================
に変更します。
これにより、URLから「index.php」を省略しても、「index.php」をトップページとして認識してくれるようになります。
ここまで来たら、
最後にApacheを再起動します。
# /usr/local/apache2/bin/apachectl restart
この記事へのコメントはありません。