Php

從原始碼編譯 PHP 5.2.6 時出錯 (Fedora 12)

  • April 9, 2013

我已經安裝了 Apache 2.2.14、PHP 5.3.1(使用 mod_fastcgi)和 MySQL 5.1.41 - 這很好用,但我現在正在嘗試安裝 PHP 5.2.6(也使用 mod_fastcgi),所以我可以將它用於在我的主機使用此版本時在其他虛擬主機上進行測試。

我在 CentOS 5 和早期版本的 Fedora 中遵循了相同的程序,並且執行良好。我已經安裝了我需要的所有依賴項。“配置”工作正常,這是我的配置命令…

./configure \
--prefix=/usr/local/php-5.2.6 \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-curlwrappers \
--enable-exif \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-imagick \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--with-ldap \
--enable-libxml \
--enable-mbstring \
--with-mcrypt \
--with-mhash \
--with-mysql \
--with-mysqli \
--with-openssl \
--enable-pdo \
--with-pdo-mysql \
--enable-soap \
--enable-sockets \
--with-tidy \
--with-xmlrpc \
--with-xsl \
--enable-zip \
--with-zlib

但是在執行“make”時我似乎遇到了錯誤……有很多錯誤,所以我展示了第一個和最後一個位(必須將它記錄到一個太長的文本文件中)。我假設我需要一些編譯標誌/選項才能讓它工作。

/bin/sh /home/luke/Downloads/php-5.2.6/libtool --silent --preserve-dup-deps --mode=compile gcc  -Iext/libxml/ -I/home/luke/Downloads/php-5.2.6/ext/libxml/ -DPHP_ATOM_INC -I/home/luke/Downloads/php-5.2.6/include -I/home/luke/Downloads/php-5.2.6/main -I/home/luke/Downloads/php-5.2.6 -I/usr/include/libxml2 -I/home/luke/Downloads/php-5.2.6/ext/date/lib -I/usr/include/ImageMagick -I/usr/include/imap -I/home/luke/Downloads/php-5.2.6/ext/mbstring/oniguruma -I/home/luke/Downloads/php-5.2.6/ext/mbstring/libmbfl -I/home/luke/Downloads/php-5.2.6/ext/mbstring/libmbfl/mbfl -I/usr/include/mysql -I/home/luke/Downloads/php-5.2.6/TSRM -I/home/luke/Downloads/php-5.2.6/Zend    -I/usr/include -g -O2  -c /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c -o ext/libxml/libxml.lo 
In file included from /home/luke/Downloads/php-5.2.6/Zend/zend.h:236,
from /home/luke/Downloads/php-5.2.6/main/php.h:34,
from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/Zend/zend_alloc.h:34: error: expected specifier-qualifier-list before 'uint'
/home/luke/Downloads/php-5.2.6/Zend/zend_alloc.h:41: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char'
/home/luke/Downloads/php-5.2.6/Zend/zend_alloc.h:43: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/luke/Downloads/php-5.2.6/Zend/zend_alloc.h:44: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'[/code]

/home/luke/Downloads/php-5.2.6/Zend/zend_hash.h:339: note: previous implicit declaration of 'strtol' was here
In file included from /home/luke/Downloads/php-5.2.6/main/php.h:234,
from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/main/snprintf.h:82: error: expected declaration specifiers or '...' before 'va_list'
/home/luke/Downloads/php-5.2.6/main/snprintf.h:84: error: expected declaration specifiers or '...' before 'va_list'
In file included from /home/luke/Downloads/php-5.2.6/main/php.h:236,
from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/main/spprintf.h:42: error: expected declaration specifiers or '...' before 'va_list'
In file included from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/main/php.h:293: error: expected declaration specifiers or '...' before 'va_list'
In file included from /home/luke/Downloads/php-5.2.6/main/php.h:383,
from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/main/php_output.h:100: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'extern'
In file included from /home/luke/Downloads/php-5.2.6/main/fopen_wrappers.h:25,
from /home/luke/Downloads/php-5.2.6/main/php.h:401,
from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/main/php_globals.h:33: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'struct'
In file included from /home/luke/Downloads/php-5.2.6/main/php.h:405,
from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/TSRM/tsrm_virtual_cwd.h:162: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
In file included from /home/luke/Downloads/php-5.2.6/main/php.h:407,
from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/Zend/zend_constants.h:58: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/luke/Downloads/php-5.2.6/Zend/zend_constants.h:59: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
/home/luke/Downloads/php-5.2.6/Zend/zend_constants.h:60: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/luke/Downloads/php-5.2.6/Zend/zend_constants.h:61: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/luke/Downloads/php-5.2.6/Zend/zend_constants.h:62: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/luke/Downloads/php-5.2.6/Zend/zend_constants.h:63: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
/home/luke/Downloads/php-5.2.6/Zend/zend_constants.h:64: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
In file included from /home/luke/Downloads/php-5.2.6/main/php.h:414,
from /home/luke/Downloads/php-5.2.6/ext/libxml/libxml.c:28:
/home/luke/Downloads/php-5.2.6/main/php_reentrancy.h:57: error: expected ')' before '*' token
make: *** [ext/libxml/libxml.lo] Error 1

我現在已經嘗試了幾次,刪除文件夾和文件並從頭開始重新下載,仍然是相同的****。我確定我以前見過這個錯誤,但我只是不記得我做了什麼,因為我總是忘記把事情寫下來——我通常會發現幾個小時的挫敗感被一些愚蠢的事情解決了。我讓 PHP 5.2.12 編譯得很好,但理想情況下我想使用 PHP 5.2.6 來模擬 Web 主機的環境。

我不確定這是否會幫助你幫助我。

[root@localhost php-5.2.6]# gcc -v
Using built-in specs.
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux
Thread model: posix
gcc version 4.4.2 20091222 (Red Hat 4.4.2-20) (GCC)

我是否需要提供更多可以提供幫助的資訊?

簡短的回答是,較舊的 PHP 版本可能會做一些 GCC 4.4 無法處理的蠢事。

嘗試安裝 gcc 4.3,然後使用:

CC=gcc-4.3 make

小心,不要犯和我一樣的錯誤!

使用 PHP 5.2 似乎我還必須使用這些配置選項

$$ –enable-fastcgi $$和$$ –enable-force-cgi-redirect $$讓它與 mod_fastcgi 一起工作。如果您在 PHP 5.2 中不使用這些選項,您只會在 error.log 中收到伺服器 500 錯誤和無用的錯誤消息! 出於某種原因,PHP 5.3 沒有這些選項,我將 5.2 的 ./configure 選項基於我用於 5.3 的選項。

感謝您的幫助 LapTop006,當我有時間我需要在教程中寫下所有這些。

引用自:https://serverfault.com/questions/98231