一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

解决CentOS 6.5 x64 编译PHP出错

时间:2014-01-11 编辑:简简单单 来源:一聚教程网

 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 分区,请参阅:http://www.111com.net/sys/CentOS/56848.htm

通过以上步骤,我在 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

 

热门栏目