phpbrew 安装时,如果有疑难问题装不上,有可能是权限问题造成的。

访问量: 1016

今天公司的一个项目, 模块 imap 装不上。

我试了下, 发现 普通用户 提示无法安装,

phpbrew ext install imap -- --with-imap-ssl --with-kerberos
===> Installing imap extension...
Log stored at: /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap/build.log
Changing directory to /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap
===> Running make clean: make -C /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap --quiet clean
===> Phpize...
===> Configuring...
===> Building...
===> Running make all: make -C /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap  all  >> /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap/build.log 2>&1
===> Installing...
===> Running make install: make -C /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap  install  >> /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap/build.log 2>&1
Exception: Command failed: make -C /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap  install  >> /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap/build.log 2>&1 returns 
Trace:

    0) PhpBrew\Utils::system(['make', '-C', '/home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap', '', 'install', ' >> /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap/build.log 2>&1'], CLIFramework\Logger)
    1) PhpBrew\Tasks\MakeTask->make('/home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap', 'install')
    2) PhpBrew\Tasks\MakeTask->install(PhpBrew\Extension\M4Extension)
    3) PhpBrew\Extension\ExtensionInstaller->install(PhpBrew\Extension\M4Extension, ['--with-imap-ssl', '--with-kerberos'])
    4) PhpBrew\Extension\ExtensionManager->installExtension(PhpBrew\Extension\M4Extension, ['--with-imap-ssl', '--with-kerberos'])
    5) PhpBrew\Command\ExtensionCommand\InstallCommand->execute('imap', '--', '--with-imap-ssl', '--with-kerberos')
    6) call_user_func_array([PhpBrew\Command\ExtensionCommand\InstallCommand, 'execute'], ['imap', '--', '--with-imap-ssl', '--with-kerberos'])
    7) CLIFramework\CommandBase->executeWrapper(['imap', '--', '--with-imap-ssl', '--with-kerberos'])
    8) CLIFramework\Application->run(['/usr/bin/phpbrew', 'ext', 'install', 'imap', '--', '--with-imap-ssl', '--with-kerberos'])
    9) CLIFramework\Application->runWithTry(['/usr/bin/phpbrew', 'ext', 'install', 'imap', '--', '--with-imap-ssl', '--with-kerberos'])
    10) require('phar:///usr/bin/phpbrew/scripts/phpbrew-emb.php')



sudo 模式下发现已经安装好了:

 sudo phpbrew ext install imap -- --with-imap-ssl --with-kerberos
PHP Warning:  Module 'imap' already loaded in Unknown on line 0
Error: PHPBREW_PHP environment variable is not defined.
  This extension command requires you specify a PHP version from your build list.
  And it looks like you haven't switched to a version from the builds that were built with PHPBrew.
Suggestion: Please install at least one PHP with your prefered version and switch to it.

按照文文的提示, 查看php 环境, 发现当前的 环境下( 用户是 普通用户,而不是sudo ) 是看不到imap模块的。 

参考以前的安装步骤, 发现没有问题。 

于是试了下 安装其他的模块, 提示说 “permission denied" 。所以,想到: 上面的普通用户安装时莫名其妙的错误,是不是权限问题。 

于是 找到php的安装目录,查看下对应文件夹的权限,发现果然是 普通用户与超级用户混杂的:

~/.phpbrew/php/php-5.4.38/etc > ubuntu@i-ifbf2wdp [php:5.4.38-phpbrew]
$ ll
total 76
drwxr-xr-x 2 root   root    4096 Sep 14 14:22 ./
drwxr-xr-x 7 ubuntu ubuntu  4096 Aug  4 14:38 ../
-rw-r--r-- 1 root   root    1372 Aug  4 15:57 pear.conf  # 用户是 root
-rw-r--r-- 1 root   root   65531 Sep 14 14:22 php.ini

所以解决办法就简单了, 修改 文件夹所有权。 重新安装即可。 

$ sudo chown ubuntu:ubuntu . -R

$ ll
total 76
drwxr-xr-x 2 ubuntu ubuntu  4096 Sep 14 14:22 ./
drwxr-xr-x 7 ubuntu ubuntu  4096 Aug  4 14:38 ../
-rw-r--r-- 1 ubuntu ubuntu  1372 Aug  4 15:57 pear.conf  # 可以看到用户变成了 普通用户
-rw-r--r-- 1 ubuntu ubuntu 65531 Sep 14 14:22 php.ini

安装, 一次成功. 查看对应的页面, 好了。

$ phpbrew ext install imap -- --with-imap-ssl --with-kerberos
===> Installing imap extension...
Log stored at: /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap/build.log
Changing directory to /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap
===> Running make clean: make -C /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap --quiet clean
===> Phpize...
===> Configuring...
===> Building...
===> Running make all: make -C /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap  all  >> /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap/build.log 2>&1
===> Installing...
===> Running make install: make -C /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap  install  >> /home/ubuntu/.phpbrew/build/php-5.4.38/ext/imap/build.log 2>&1
===> Extension is installed.
===> Creating config file /home/ubuntu/.phpbrew/php/php-5.4.38/var/db/imap.ini.disabled
===> Enabling extension imap
[*] imap extension is enabled.
Done.

订阅/RSS Feed

Subscribe

分类/category