我已经安装了 Apache 2.2.14、PHP 5.3.1(使用 mod_fastcgi)和 MySQL 5.1.41 - 运行良好,但我现在正尝试安装 PHP 5.2.6(也使用 mod_fastcgi),以便我可以使用它在其他虚拟主机上进行测试,因为我的主机使用此版本。
我在 CentOS 5 和 Fedora 的早期版本中遵循了相同的步骤,并且运行良好。我已经安装了所需的所有依赖项。“configure”运行良好,这是我的 configure 命令...
./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 来模拟网络主机的环境。
我不确定这是否能帮助你帮助我。
[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)
我是否需要提供更多有帮助的信息?
答案1
简短的回答是旧版 PHP 可能做了一些 GCC 4.4 无法处理的愚蠢事情。
尝试安装 gcc 4.3 然后使用:
CC=gcc-4.3 make
答案2
小心,不要犯和我一样的错误!
对于 PHP 5.2,似乎我还必须使用这些配置选项 [--enable-fastcgi] 和 [--enable-force-cgi-redirect] 才能与 mod_fastcgi 配合使用。如果您在 PHP 5.2 中不使用这些选项,您只会收到服务器 500 错误和 error.log 中无用的错误消息!
由于某种原因,PHP 5.3 没有这些选项,并且我根据 5.3 中使用的选项为 5.2 制定了 ./configure 选项。
感谢 LapTop006 的帮助,当我有时间时我需要将所有这些内容写在教程中。
答案3
确保你运行
phpize
在任何 ./configure 脚本之前(包括 PHP 的其他扩展)。