12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PhalconPHPのインストール時にハマった時のメモ(CentOS6)

Posted at

概要

結論からいうと、予めPHP5.4にしておけばハマりません。
自分のようにPHP5.3のままで横着しようとするとこうなります。
という作業履歴です。

エラー解消のお役に立てればと思い・・・

##インストール

$ sudo yum -y install php-devel

$ cd
$ git clone https://github.com/phalcon/cphalcon.git
$ cd cphalcon/build
$ sudo ./install

##ini追加

$ sudo vim /etc/php.d/phalcon.ini
$ sudo cat /etc/php.d/phalcon.ini
extension=phalcon.so

##確認

$ php -i |grep Phalcon
Phalcon Framework => enabled
Phalcon Version => 1.2.6

$ php -r "print_r(get_loaded_extensions());" |grep phalcon
    [37] => phalcon

ここまではOK

phalcon devtoolsのインストール

準備

$ mkdir phalcon
$ cd phalcon
$ curl -s http://getcomposer.org/installer | php

$ vim composer.json
$ cat composer.json 
{
    "require": {
        "phalcon/devtools": "dev-master"
    }
}

インストール

$ php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phalcon/devtools dev-master -> satisfiable by phalcon/devtools[dev-master].
    - phalcon/devtools dev-master requires php >=5.3.6 -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems

おうふ!

$ php -v
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

なるほど、yumでつっこんだPHPのバージョンが5.3.3なのでダメらしい。

PHP5.3 -> PHP5.4に上げる

現状確認

$ rpm -qa | grep php
php-mysql-5.3.3-27.el6_5.x86_64
php-devel-5.3.3-27.el6_5.x86_64
php-pdo-5.3.3-27.el6_5.x86_64
php-mbstring-5.3.3-27.el6_5.x86_64
php-5.3.3-27.el6_5.x86_64
php-common-5.3.3-27.el6_5.x86_64
php-cli-5.3.3-27.el6_5.x86_64

削除

$ sudo yum erase php-mysql php-devel php-pdo php-mbstring php php-common php-cli

PHP5.4のインストール
こちらを参考に進めます。

epel / remiを追加

$ wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
$ sudo rpm --import RPM-GPG-KEY-EPEL-6
$ sudo touch /etc/yum.repos.d/epel.repo
$ sudo vim /etc/yum.repos.d/epel.repo
$ sudo cat /etc/yum.repos.d/epel.repo
・・・
[epel]
name=EPEL RPM Repository for Red Hat Enterprise Linux
baseurl=http://ftp.riken.jp/Linux/fedora/epel/6/$basearch/
gpgcheck=1
enabled=0

$ wget http://rpms.famillecollet.com/RPM-GPG-KEY-remi
$ sudo rpm --import RPM-GPG-KEY-remi
$ sudo vim /etc/yum.repos.d/remi.repo
$ sudo cat /etc/yum.repos.d/remi.repo
[remi]
name=Les RPM de remi pour Enterprise Linux 5 - $basearch
baseurl=http://rpms.famillecollet.com/el5.$basearch/
http://iut-info.univ-reims.fr/remirpms/el5.$basearch/
enabled=0
priority=1

インストール可能なパッケージを確認

$ yum --enablerepo=epel,remi,rpmforge info php
Loaded plugins: fastestmirror, security
Determining fastest mirrors
epel/metalink                                                      | 4.5 kB     00:00     
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
remi                                                               | 2.5 kB     00:00     
remi/primary_db                                                    | 604 kB     00:02     
Available Packages
Name        : php
Arch        : x86_64
Version     : 5.4.24
Release     : 1.el5.remi
Size        : 3.1 M
Repo        : remi
Summary     : PHP scripting language for creating dynamic web sites
URL         : http://www.php.net/
License     : PHP and Zend and BSD
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it
            : easy for developers to write dynamically generated web pages. PHP also
            : offers built-in database integration for several commercial and
            : non-commercial database management systems, so writing a
            : database-enabled webpage with PHP is fairly simple. The most common
            : use of PHP coding is probably as a replacement for CGI scripts.
            : 
            : The php package contains the module (often referred to as mod_php)
            : which adds support for the PHP language to Apache HTTP Server.

remiリポジトリを使用してインストール

$ sudo yum --enablerepo=remi install php-mysql php-devel php-pdo php-mbstring php php-common php-cli
・・・
Dependencies Resolved

==========================================================================================
 Package                Arch           Version                         Repository    Size
==========================================================================================
Installing:
 php                    x86_64         5.4.24-1.el5.remi               remi         3.1 M
 php-cli                x86_64         5.4.24-1.el5.remi               remi         2.9 M
 php-common             x86_64         5.4.24-1.el5.remi               remi         1.1 M
 php-devel              x86_64         5.4.24-1.el5.remi               remi         3.0 M
 php-mbstring           x86_64         5.4.24-1.el5.remi               remi         1.2 M
 php-mysql              x86_64         5.4.24-1.el5.remi               remi         185 k
 php-pdo                x86_64         5.4.24-1.el5.remi               remi         131 k
Installing for dependencies:
 compat-mysql51         x86_64         5.1.54-1.el5.remi               remi         1.8 M
 openssl098e            x86_64         0.9.8e-17.el6.centos.2          base         761 k
Updating for dependencies:
 mysql                  x86_64         5.5.35-1.el5.remi               remi         7.5 M
 mysql-libs             x86_64         5.5.35-1.el5.remi               remi         1.1 M
 mysql-server           x86_64         5.5.35-1.el5.remi               remi          13 M

Transaction Summary
==========================================================================================
・・・

バージョン確認。

$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/phalcon.so' - /usr/lib64/php/modules/phalcon.so: undefined symbol: output_globals in Unknown on line 0
PHP 5.4.24 (cli) (built: Jan  9 2014 07:43:34) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

警告出ちゃってるけど、ひとまずバージョンアップ完了。

##リトライ

$ cd phalcon
$ php composer.phar install
・・・
Writing lock file
Generating autoload files

きたくせぇ。

$ cd
$ sudo mv phalcon /usr/local/
$ ln -s /usr/local/phalcon/vendor/phalcon/devtools/phalcon.php /usr/bin/phalcon
$ chmod ugo+x /usr/bin/phalcon

んで、先ほどの警告を解消する。
まさにこちらの症状なので参考にさせていただきます。

$ cd cphalcon/build/64bits
$ sudo make clean

$ sudo find / -name phpize
$ /usr/bin/phpize

$ sudo find / -name php-config
$ ./configure --with-php-config=/usr/bin/php-config

$ sudo make
$ sudo make install

確認

$ phalcon

Phalcon DevTools (1.2.6)

Available commands:
  commands (alias of: list, enumerate)
  controller (alias of: create-controller)
  model (alias of: create-model)
  all-models (alias of: create-all-models)
  project (alias of: create-project)
  scaffold
  migration
  webtools

やっと確認できた!

##プロジェクトの作成

$ cd
$ phalcon project sample

Phalcon DevTools (1.2.6)

                                                         
  Success: Controller "index" was successfully created.  
                                                         
                                                       
  Success: Project 'sample' was successfully created.  
                                                       

疲れたのでとりあえず今日はここまで。

最初にPHP5.4にバージョンアップしておけばこんな苦労はしなかったでしょうね・・・

12
10
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
12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?