我按照这两篇文章在从源代码编译时安装了多个版本的PHP: http://www.sitepoint.com/run-multiple-versions-php-one-server/ http://www.phpinternalsbook.com/build_system/building_php.html
我试图将PHP 5.6安装到/ opt / php56(我创建的目录)中,但是,当我运行./buildconf然后运行以下命令时,PHP会覆盖自己。
我如何编译PHP:
./buildconf (does its thing)...
./configure \
--prefix-dir=/opt/php56/ \
--disable-opcache \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-gd-native-ttf \
--enable-libxml \
--with-libxml-dir=/opt/xml2/ \
--enable-pdo=shared \
--with-pdo-mysql=shared \
--with-pdo-sqlite=shared \
--enable-sockets \
--prefix=/usr/local \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-curl=/opt/curlssl/ \
--with-freetype-dir=/usr \
--with-gd \
--with-imap=/opt/php_with_imap_client/ \
--with-imap-ssl=/usr \
--with-jpeg-dir=/usr \
--with-kerberos \
--with-libdir=lib64 \
--with-mcrypt=/opt/libmcrypt/ \
--with-mysql=/usr \
--with-mysql-sock=/var/lib/mysql/mysql.sock \
--with-openssl=/usr \
--with-openssl-dir=/usr \
--with-pcre-regex=/opt/pcre \
--with-pic \
--with-png-dir=/usr \
--with-xpm-dir=/usr \
--with-zlib \
--with-zlib-dir=/usr \
--enable-soap \
make
make install (which installs everything to /usr/local/bin, despite the set prefix on ./configure).
当我运行以下内容时会发生什么:
root ~>># which php
/usr/local/bin/php
root ~>># sudo -u foo which php
/usr/bin/php
我对--prefix做错了什么?我做的最后一次安装,我跑了./configure --prefix = / opt / php56 /这也没有。
答案 0 :(得分:1)
问题是我没有告诉编译器我想要我的目录。一个很好的例子:
./configure \
--prefix=/opt/php56 \
--bindir=/opt/php56/bin \
--libdir=/opt/php56/lib \
--sysconfdir=/opt/php56/etc \
--includedir=/opt/php56/include/php \
--mandir=/opt/php56/php/man \
......为了简洁起见,其余的都被搁置了。