m_shige1979のときどきITブログ

プログラムの勉強をしながら学習したことや経験したことをぼそぼそと書いていきます

Github(変なおっさんの顔でるので気をつけてね)

https://github.com/mshige1979

CentOS6.xにphp7のインストールテスト

せっかくなのでvmを作成してインストールしてみる(準備)

git clone https://github.com/mshige1979/vagrant-centos-dev-001.git -b test00 test02
cd test02
vagrant up
vagrant ssh
yum
sudo yum -y install gcc gcc-c++ git wget tar m4 autoconf httpd vim
sudo yum -y install httpd-devel gd-devel libxml2-devel mysql-devel t1lib-devel
sudo yum -y install bzip2-devel curl-devel gmp-devel aspell-devel recode-devel
sudo yum -y install icu libicu-devel
sudo yum -y install php-intl
phpをダウンロードしてからビルド
wget https://github.com/php/php-src/archive/php-7.0.0RC1.tar.gz
tar zxf php-7.0.0RC1.tar.gz
cd php-src-php-7.0.0RC1/
./buildconf --force
./configure \
    --prefix=/usr/local/php \
    --with-config-file-path=/usr/local/php/etc \
    --enable-mbstring \
    --enable-zip \
    --enable-bcmath \
    --enable-pcntl \
    --enable-ftp \
    --enable-exif \
    --enable-intl \
    --enable-calendar \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-wddx \
    --with-curl \
    --with-mcrypt \
    --with-iconv \
    --with-gmp \
    --with-pspell \
    --with-gd \
    --with-jpeg-dir=/usr \
    --with-png-dir=/usr \
    --with-zlib-dir=/usr \
    --with-xpm-dir=/usr \
    --with-freetype-dir=/usr \
    --enable-gd-native-ttf \
    --enable-gd-jis-conv \
    --with-openssl \
    --with-pdo-mysql=/usr \
    --with-gettext=/usr \
    --with-zlib=/usr \
    --with-bz2=/usr \
    --with-recode=/usr \
    --with-mysqli=/usr/bin/mysql_config \
    --with-apxs2=/usr/sbin/apxs
make && make test
sudo make insall

$ sudo make install
Installing PHP SAPI module:       apache2handler
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp7.la /usr/lib64/httpd/modules
/usr/lib64/apr-1/build/libtool --mode=install cp libphp7.la /usr/lib64/httpd/modules/
libtool: install: cp .libs/libphp7.so /usr/lib64/httpd/modules/libphp7.so
libtool: install: cp .libs/libphp7.lai /usr/lib64/httpd/modules/libphp7.la
libtool: install: warning: remember to run `libtool --finish /home/vagrant/php-src-php-7.0.0RC1/libs'
chmod 755 /usr/lib64/httpd/modules/libphp7.so
[activating module `php7' in /etc/httpd/conf/httpd.conf]
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20141001/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing phpdbg binary:         /usr/local/php/bin/
Installing phpdbg man page:       /usr/local/php/php/man/man1/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php/lib/php/
--2015-08-23 14:13:15--  https://pear.php.net/~cweiske/1.10.0dev2/install-pear-nozlib.phar
pear.php.net をDNSに問いあわせています... 5.77.39.20
pear.php.net|5.77.39.20|:443 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 3572266 (3.4M) [text/plain]
`pear/install-pear-nozlib.phar' に保存中

100%[==================================================================================================================>] 3,572,266    177K/s 時間 39s

2015-08-23 14:14:01 (89.2 KB/s) - `pear/install-pear-nozlib.phar' へ保存完了 [3572266/3572266]

[PEAR] Archive_Tar    - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.3.0
[PEAR] PEAR           - installed: 1.10.0dev2
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/home/vagrant/php-src-php-7.0.0RC1/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/
$
設定ファイルをコピーして、環境変数に追加
sudo cp -p php.ini-development /usr/local/php/etc/php.ini
echo 'export PATH=$PATH:/usr/local/php/bin' >> ~/.bash_profile
source ~/.bash_profile
実行
$ php -v
PHP 7.0.0RC1 (cli) (built: Aug 23 2015 13:55:47)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
$

phpinfo

info.php
<?php
        phpinfo();
起動
php -S 192.168.33.10:1234
結果

f:id:m_shige1979:20150823233020p:plain

cakephp3

mysql
mysql -u root -e "create database my_app default charset utf8"
mysql -u root -e "create database test_my_app default charset utf8"
mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'my_app'@'localhost' IDENTIFIED BY 'secret' WITH GRANT OPTION;"
install
curl -s https://getcomposer.org/installer | php
php composer.phar create-project --prefer-dist cakephp/app app1
app1/
bin/cake server -H 192.168.33.10 -p 1234

f:id:m_shige1979:20150824002632p:plain

所感

なんとかcakephp3も初期ページまでは動くようです。拡張モジュールなどを利用している場合はうまく有効にしているかを
確認しないと動かせないことがあるのでインストール時などに注意を行うことが必要と思われる。
php7の新機能はまた今度確認する