CentOS 6下编译PHP出错

技术 秋水逸冰 8955浏览 2评论

PHP 官方更新倒是挺勤快的。几天不见,又更新了。于是升级一下 VPS 的 PHP 呗。编译的过程中跑着跑着出现了错误如下:cc: Internal error: Killed (program cc1)
很明显这是编译进程被系统给 kill 掉了,我在测试 LAMP一键安装脚本时,遇到过多次这种情况。原因无非就是内存太小导致的。今天在一个 256MB 内存的 VPS 编译的时候又出现这种错误了。通常情况,在 x64 的系统中小内存的 VPS 里比较常见。

在阿里云 512MB VPS上测试时,也出现过这种情况。解决办法,就是在编译 PHP 时 configure 增加一个选项 –disable-fileinfo,同时关闭一些运行中的进程如mysqld,httpd等等,以节约内存。
还有就是增加 swap 分区(前提是 VPS 不存在 swap 分区的情况下,比如 DigitalOcean 默认就没有 swap 分区),也可以帮助解决小内存编译的问题。如何在 DigitalOcean 的系统中增加 swap 分区,请参阅:https://teddysun.com/321.html
通过以上步骤,我在 256MB 的 buyvm 的 VPS 上顺利编译完 PHP。

附上我的完整的编译 PHP 的 configure 选项(更多具体详情,参阅:LAMP一键安装脚本):

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs  --with-config-file-path=/usr/local/php/etc --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql --with-mysql-sock=/usr/local/mysql/mysql.sock --with-config-file-scan-dir=/usr/local/php/php.d --with-openssl --with-zlib --with-curl --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-xmlrpc --enable-calendar --with-imap --with-kerberos --with-imap-ssl --with-ldap --enable-bcmath --enable-exif --enable-wddx --enable-tokenizer --enable-simplexml --enable-sockets --enable-ctype --enable-gd-native-ttf --enable-mbstring --enable-intl --enable-xml --enable-dom --enable-json --enable-session --enable-soap --with-mcrypt --enable-zip --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --with-icu-dir=/usr --with-mhash=/usr --with-pcre-dir --without-pear --disable-fileinfo

转载请注明:秋水逸冰 » CentOS 6下编译PHP出错

发表我的评论
取消评论

请输入正确答案后提交评论 *超出时限。 请再次填写验证码。

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (2)

  1. 终于更新了哈,是不是看我更新频繁心里不安了,哎~~~在忙不能穷教育啊~~~~
    smartsun10年前(2014-01-11)回复
    • 其实还是懒。半个小时就可以更新一篇了。
      Teddysun10年前(2014-01-11)回复