gccをCentOS 5.xにインストール

ビルド用ディレクトリとインストール先ディレクトリを作成

$ cd ~
$ mkdir build
$ cd ~
$ mkdir local
$ cd local
$ mkdir gcc

ソースを取得して展開

$ wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.9.3/gcc-4.9.3.tar.gz
$ tar zxvf gcc-4.9.3.tar.gz

ビルドに必要なライブラリを取得

$ cd gcc-4.9.3
$ ./contrib/download_prerequisites

configureとmake、make install

$ cd ~
$ cd build
$ ../gcc-4.9.3/configure --prefix=/home/user/local/gcc --disable-bootstrap --with-system-zlib --disable-multilib --enable-languages=c,c++
$ make
$ make install

参考URL
http://www.mk-mode.com/octopress/2014/09/30/installation-newest-gcc-by-src-on-linux-mint/
https://gcc.gnu.org/ml/gcc-help/2012-07/msg00018.html
http://stackoverflow.com/questions/26808416/gcc-4-9-2-build-error-on-rhel6

node.jsのnpm installでこのgccを使用する例

$ CXX=/home/user/local/gcc/bin/gcc npm install microtime

nodebrew導入

nodebrew
https://github.com/hokaccha/nodebrew

nodebrewを使ってNode.jsをインストール
http://kjwtnb.hatenablog.com/entry/2013/05/20/nodebrew%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6Node.js%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB

Install Python 2.7 to your account
https://my.bluehost.com/cgi/help/python-install

Node.js のバージョンを nodebrew で管理する (with Mac OS X + Homebrew)
http://qiita.com/nilab/items/96e0ea8da919e1cac84b

yumでCentOS6のphp5.3をphp5.4にアップグレード

php5.4があるyumリポジトリをインストール。

$ wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm
$ wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/ius-release-1.0-11.ius.el6.noarch.rpm
$ sudo rpm -ivh epel-release-6-5.noarch.rpm ius-release-1.0-11.ius.el6.noarch.rpm

httpdを停止。

$ sudo /etc/init.d/httpd stop

削除するphp5.3パッケージを確認。

$ rpm -qa | grep php
php-pear-1.9.4-4.el6.noarch
php-phpunit-File-Iterator-1.3.4-1.el6.noarch
php-symfony-yaml-2.3.9-1.el6.noarch
php-phpunit-PHPUnit-MockObject-1.2.3-1.el6.noarch
php-xml-5.3.3-40.el6_6.x86_64
php-ezc-Base-1.8-1.el6.noarch
php-common-5.3.3-40.el6_6.x86_64
php-pecl-memcached-1.0.0-1.el6.x86_64
php-channel-phpunit-1.3-3.el6.noarch
php-pecl-xdebug-2.1.4-2.el6.x86_64
php-phpunit-PHP-TokenStream-1.2.1-1.el6.noarch
php-channel-ezc-1-2.el6.noarch
php-pecl-memcache-3.0.5-4.el6.x86_64
php-cli-5.3.3-40.el6_6.x86_64
php-mysql-5.3.3-40.el6_6.x86_64
php-phpunit-PHP-Timer-1.0.5-1.el6.noarch
php-phpunit-PHP-Invoker-1.1.3-2.el6.noarch
php-soap-5.3.3-40.el6_6.x86_64
php-phpunit-PHP-CodeCoverage-1.2.13-1.el6.noarch
php-phpunit-PHPUnit-3.7.34-2.el6.noarch
php-pdo-5.3.3-40.el6_6.x86_64
php-mbstring-5.3.3-40.el6_6.x86_64
php-ezc-ConsoleTools-1.6.1-1.el6.noarch
php-phpunit-Text-Template-1.1.4-1.el6.noarch
php-symfony-common-2.3.9-1.el6.noarch
php-tidy-5.3.3-40.el6_6.x86_64

上記のうち、パッケージ名に5.3.3が付いているものをアンインストールします。

$ sudo yum erase php-xml php-common php-cli php-mysql php-soap php-pdo php-mbstring php-tidy

php5.4のパッケージを確認。

$ yum search php

php54.x86_64 : PHP scripting language for creating dynamic web sites
php54-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php54-cli.x86_64 : Command-line interface for PHP
php54-common.x86_64 : Common files for PHP
php54-dba.x86_64 : A database abstraction layer module for PHP applications
php54-debuginfo.x86_64 : Debug information for package php54
php54-devel.x86_64 : Files needed for building PHP extensions
php54-embedded.x86_64 : PHP library for embedding in applications
php54-fpm.x86_64 : PHP FastCGI Process Manager
php54-gd.x86_64 : A module for PHP applications for using the gd graphics library
php54-imap.x86_64 : A module for PHP applications that use IMAP
php54-interbase.x86_64 : A module for PHP applications that use Interbase/Firebird databases
php54-intl.x86_64 : Internationalization extension for PHP applications
php54-ioncube-loader.x86_64 : IonCube Loader provides PHP Modules to read IonCube Encoded Files
php54-ioncube-loader-debuginfo.x86_64 : Debug information for package php54-ioncube-loader
php54-ldap.x86_64 : A module for PHP applications that use LDAP
php54-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php54-mcrypt.x86_64 : Standard PHP module provides mcrypt library support
php54-mssql.x86_64 : MSSQL database module for PHP
php54-mysql.x86_64 : A module for PHP applications that use MySQL databases
php54-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
php54-odbc.x86_64 : A module for PHP applications that use ODBC databases
php54-pdo.x86_64 : A database access abstraction module for PHP applications
php54-pear.noarch : PHP Extension and Application Repository framework
php54-pecl-apc.x86_64 : APC caches and optimizes PHP intermediate code
php54-pecl-apc-debuginfo.x86_64 : Debug information for package php54-pecl-apc
php54-pecl-geoip-debuginfo.x86_64 : Debug information for package php54-pecl-geoip
php54-pecl-imagick-debuginfo.x86_64 : Debug information for package php54-pecl-imagick
php54-pecl-lzf-debuginfo.x86_64 : Debug information for package php54-pecl-lzf
php54-pecl-memcache-debuginfo.x86_64 : Debug information for package php54-pecl-memcache
php54-pecl-memcached-debuginfo.x86_64 : Debug information for package php54-pecl-memcached
php54-pecl-mongo.x86_64 : PHP MongoDB database driver
php54-pecl-mongo-debuginfo.x86_64 : Debug information for package php54-pecl-mongo
php54-pecl-mysqlnd-ms-debuginfo.x86_64 : Debug information for package php54-pecl-mysqlnd-ms
php54-pecl-redis-debuginfo.x86_64 : Debug information for package php54-pecl-redis
php54-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts
php54-pecl-xdebug-debuginfo.x86_64 : Debug information for package php54-pecl-xdebug
php54-pecl-zendopcache-debuginfo.x86_64 : Debug information for package php54-pecl-zendopcache
php54-pgsql.x86_64 : A PostgreSQL database module for PHP
php54-pgsql84.x86_64 : A PostgreSQL 8.4 database module for PHP
php54-pgsql84-debuginfo.x86_64 : Debug information for package php54-pgsql84
php54-process.x86_64 : Modules for PHP script using system process interfaces
php54-pspell.x86_64 : A module for PHP applications for using pspell interfaces
php54-recode.x86_64 : A module for PHP applications for using the recode library
php54-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices
php54-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php54-suhosin.x86_64 : Suhosin is an advanced protection system for PHP installations
php54-suhosin-debuginfo.x86_64 : Debug information for package php54-suhosin
php54-tidy.x86_64 : Standard PHP module provides tidy library support
php54-xcache.x86_64 : PHP accelerator, optimizer, encoder and dynamic content cacher
php54-xcache-debuginfo.x86_64 : Debug information for package php54-xcache
php54-xml.x86_64 : A module for PHP applications which use XML
php54-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol

php54-enchant.x86_64 : Human Language and Character Encoding Support
php54-litespeed.x86_64 : API for the Litespeed web server
php54-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places
php54-pecl-imagick.x86_64 : Provides a wrapper to the ImageMagick library
php54-pecl-lzf.x86_64 : Extension to handle LZF de/compression
php54-pecl-memcache.x86_64 : Extension to work with the Memcached caching daemon
php54-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon
php54-pecl-mysqlnd-ms.x86_64 : A replication and load balancing plugin for mysqlnd
php54-pecl-mysqlnd-ms-devel.x86_64 : Mysqlnd_ms developer files (header)
php54-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store
php54-pecl-zendopcache.x86_64 : The Zend OPcache

php5.4のパッケージだけ抜き出すと上記のようになる。

とりあえず全部インストールしようとすると、いくつかのパッケージが衝突するので、
自分の環境で必要なものだけ並べたコマンド。

$ sudo yum install php54 php54-bcmath php54-cli php54-common php54-dba php54-debuginfo php54-devel php54-embedded php54-fpm php54-gd php54-imap php54-interbase php54-intl php54-ioncube-loader php54-ioncube-loader-debuginfo php54-ldap php54-mbstring php54-mcrypt php54-mssql php54-mysql php54-odbc php54-pdo php54-pear php54-pecl-apc php54-pecl-apc-debuginfo php54-pecl-geoip-debuginfo php54-pecl-imagick-debuginfo php54-pecl-lzf-debuginfo php54-pecl-memcache-debuginfo php54-pecl-memcached-debuginfo php54-pecl-mongo php54-pecl-mongo-debuginfo php54-pecl-redis-debuginfo php54-pecl-xdebug php54-pecl-xdebug-debuginfo php54-pecl-zendopcache-debuginfo php54-process php54-pspell php54-recode php54-snmp php54-soap php54-suhosin php54-suhosin-debuginfo php54-tidy php54-xml php54-xmlrpc php54-enchant php54-litespeed php54-pecl-geoip php54-pecl-imagick php54-pecl-lzf php54-pecl-memcache php54-pecl-memcached php54-pecl-redis

参考URL

http://qiita.com/pakiln/items/e3351ade2bb5aeb198dc

phpunitをインストールして動作確認

phpunitと関連するパッケージをインストール。

$ sudo yum install php-xml php-pear php-phpunit-PHPUnit --enablerepo=epel

以下のコマンドが動作するかを確認。

$ phpunit

参考URL

http://d.hatena.ne.jp/yk5656/20140122/1391124017

memcachedをCentOS-6.xにインストールしてphpから使用

memcached関連のパッケージは?

$ yum list | grep memcached
http://ftp.kddilabs.jp/Linux/packages/fedora/epel/6/x86_64/repodata/repomd.xml: [Errno -1] repomd.xml does not match metalink for epel
Trying other mirror.
libmemcached.i686                          0.31-1.1.el6                 base
libmemcached.x86_64                        0.31-1.1.el6                 base
libmemcached-devel.i686                    0.31-1.1.el6                 base
libmemcached-devel.x86_64                  0.31-1.1.el6                 base
memcached.x86_64                           1.4.4-3.el6                  base
memcached-devel.i686                       1.4.4-3.el6                  base
memcached-devel.x86_64                     1.4.4-3.el6                  base
php-ZendFramework-Cache-Backend-Libmemcached.noarch
php-pecl-memcached.x86_64                  1.0.0-1.el6                  epel
python-memcached.noarch                    1.43-6.el6                   base

OSに合ったパッケージを選択してインストール。
memcached本体とdevelopパッケージ、peclパッケージをインストール。

peclでかなり依存関係のあるパッケージがインストールされます。

$ sudo yum install memcached.x86_64
$ sudo yum install memcached-devel.x86_64
$ sudo yum install php-pecl-memcached.x86_64

memcachedを起動。

$ sudo /etc/init.d/memcached start
memcached を起動中:                                        [  OK  ]

状態を確認。

$ sudo /etc/init.d/memcached status
memcached (pid  2032) を実行中...

portをlistenしているかどうか。

$ netstat -tulpn | grep :11211
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      -
udp        0      0 0.0.0.0:11211               0.0.0.0:*                               -

phpとの連携を確認。

$ php -i | grep memcache
/etc/php.d/memcached.ini,
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead in Unknown on line 0
memcached
memcached support => enabled
libmemcached version => 0.31
Registered save handlers => files user memcached

上記のようなtimezoneの警告が出た場合、php.iniに以下のような設定を追加します。

$ sudo vi /etc/php.ini

date.timezone = "Asia/Tokyo"

Memcache::connectを使うためpecl memcacheをインストールしておく。

$ sudo yum install php-pecl-memcache

apacheを再起動。

$ sudo /etc/init.d/httpd restart

参考URL

http://hideprogram.web.fc2.com/linux/linux_memcached.html