Apacheのインストールが終わったので、次はPHPにいきたいと思います。
旧設定ファイルのバックアップ
cp -r /etc/php.d/ /root/ cp -r /etc/php.ini /root/
旧バージョンのアンインストール
yum remove php*
php5.6のリポジトリ−を追加して、yumからインストールすると必ず以下のエラーになります。
まぁ、Apache2.4にバージョンアップしたから、必ずそうなるだろうね
別の方法を考えよう
Error: Package: php56-php-5.6.18-1.el6.remi.x86_64 (remi)
Requires: httpd-mmn = 20051115
Installed: httpd-2.4.18-1.x86_64 (installed)
httpd-mmn = 20120211
Available: httpd-2.2.15-45.el6.centos.x86_64 (base)
httpd-mmn = 20051115
Available: httpd-2.2.15-47.el6.centos.x86_64 (updates)
httpd-mmn = 20051115
Available: httpd-2.2.15-47.el6.centos.1.x86_64 (updates)
httpd-mmn = 20051115
Available: httpd-2.2.15-47.el6.centos.2.x86_64 (updates)
httpd-mmn = 20051115
Available: httpd-2.2.15-47.el6.centos.3.x86_64 (updates)
httpd-mmn = 20051115rpmからインストールしよう!
関連依存パッケージインストール
yum install libjpeg-turbo-devel yum --enablerepo=epel install l firebird-devel ibmcrypt-devel yum install bzip2-devel pam-devel libstdc++-devel libedit-devel gcc-c++ libtool-ltdl-devel systemtap-sdt-devel libc-client-devel net-snmp-devel libxslt-devel t1lib-devel libpng-devel freetype-devel libXpm-devel libvpx-devel gmp-devel tokyocabinet-devel libtidy-devel aspell-devel recode-devel libicu-devel enchant-devel
php5.6.4をインストールする
注意:php5.6.4以降のバージョンをインストールするとhttpd-toolsのチェックが必須になります!
(そこは諦めて5.6.4に・・・)
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/SRPMS/php56u-5.6.4-1.ius.centos6.src.rpm
rpmbuild --rebuild --clean php56u-5.6.4-1.ius.centos6.src.rpm
-----
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
The output of /usr/sbin/apxs follows:
./configure: line 8774: /usr/sbin/apxs: No such file or directory
configure: error: Aborting
-----
#このエラーが出たら、下記の方法で直してください
cd /root/rpmbuild/SPECS/
vi php56u.spec
(line52行目付近)
# /usr/sbin/apsx with httpd < 2.4 and defined as /usr/bin/apxs with httpd >= 2.4
%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_sbindir}/apxs}}
↓
%{!?_httpd_apxs: %{expand: %%global _httpd_apxs %%{_bindir}/apxs}}
rpmbuild -bb --clean php56u.spec
cd /root/rpmbuild/RPMS/x86_64
rpm -ivh --nodeps php56u-*php56u-pear
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/SRPMS/php56u-pear-1.10.1-4.ius.centos6.src.rpm rm -rf /var/lib/pear/ rpmbuild --rebuild --clean php56u-pear-1.10.1-4.ius.centos6.src.rpm rpm -ihv /root/rpmbuild/RPMS/noarch/php56u-pear-1.10.1-4.ius.el6.noarch.rpm
php56u-pecl-jsonc
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/SRPMS/php56u-pecl-jsonc-1.3.9-1.ius.centos6.src.rpm rpmbuild --rebuild --clean php56u-pecl-jsonc-1.3.9-1.ius.centos6.src.rpm rpm -ihv /root/rpmbuild/RPMS/x86_64/php56u-pecl-jsonc-*
php56u-pecl-apcu
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/6/SRPMS/php56u-pecl-apcu-4.0.10-1.ius.centos6.src.rpm rpmbuild --rebuild --clean php56u-pecl-apcu-4.0.10-1.ius.centos6.src.rpm
なぜかこのエラーが出る!
APC: Bug #59938 APCIterator fails with large user cache [tests/apc54_018.phpt]
色々調べてみたら、単にメモリ不足でした・・・
メモリを追加します!
もう一度実行して、うまく行きましたw
rpm -ihv /root/rpmbuild/RPMS/x86_64/php56u-pecl-apcu-* rpm -ihv /root/rpmbuild/RPMS/noarch/apcu-panel56u-4.0.10-1.ius.el6.noarch.rpm
Apache設定
/etc/httpd/conf.d/php.confの新規ファイルを作って、下記設定を入れましょう。
# # PHP is an HTML-embedded scripting language which attempts to make it # easy for developers to write dynamically generated webpages. # <IfModule prefork.c> LoadModule php5_module lib64/httpd/modules/libphp5.so </IfModule> <IfModule !prefork.c> LoadModule php5_module lib64/httpd/modules/libphp5-zts.so </IfModule> # # Cause the PHP interpreter to handle files with a .php extension. # AddHandler php5-script .php AddType text/html .php # # Add index.php to the list of files that will be served as directory # indexes. # DirectoryIndex index.php # # Uncomment the following line to allow PHP to pretty-print .phps # files as PHP source code: # AddType application/x-httpd-php-source .phps
最後にApacheを再起動して、サイトを見てみましょう!
/etc/rc.d/init.d/httpd restart