CendOS 6.5 上編譯安裝PHP 5/PHP 7的方法介紹

來源:互聯網
上載者:User

首先安裝一些依賴的軟體包:

yum install libmcrypt.x86_64 libpng.x86_64 libjpeg-turbo.x86_64 \
libxml2.x86_64 readline.x86_64 libxml2-devel.x86_64 openssl.x86_64 \
openssl-devel.x86_64 libcurl-devel.x86_64 libjpeg-turbo-devel.x86_64 \
libwebp-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 \
libmcrypt-devel.x86_64 readline-devel.x86_64
然後是正確的配置 PHP7 的編譯選項

./configure -C \
--prefix=/usr/local/php \
--with-readline \
--with-curl \
--with-gd \
--with-iconv \
--with-gettext \
--with-mcrypt \
--with-mysqli \
--with-openssl \
--enable-pcntl \
--enable-soap \
--enable-mbstring \
--with-zlib \
--enable-fpm \
--with-freetype-dir=/usr \
--with-jpeg-dir=/usr \
--with-webp-dir=/usr \
--with-png-dir=/usr
最後執行編譯指令:

#使用2個核的意思,看CPU多少決定這個參數
make -j 2
make install
編譯完了,要單獨編譯一下 opcache,雖然我覺得這個應該編譯進去到 PHP 解譯器裡面,
但是目前,我只找到了以擴充方式使用的方法。

cd ext/opcode
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make -j 2
make install
然後編輯設定檔,添加:

zend_extension=opcache.so
=====

下面是 PHP 5 的編譯指令碼:

#!/bin/bash
 
yum -yq install libmcrypt.x86_64 libpng.x86_64 libjpeg-turbo.x86_64 \
libxml2.x86_64 readline.x86_64 libxml2-devel.x86_64 openssl.x86_64 \
openssl-devel.x86_64 libcurl-devel.x86_64 libjpeg-turbo-devel.x86_64 \
libwebp-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 \
libmcrypt-devel.x86_64 readline-devel.x86_64 libtool-ltdl-devel.x86_64
 
./configure -C \
--prefix=/usr/local/php-5.5.16 \
--with-readline \
--with-curl \
--with-gd \
--with-iconv \
--with-gettext \
--with-mcrypt \
--with-mysqli \
--with-pdo-mysql \
--with-openssl \
--enable-pcntl \
--enable-soap \
--enable-mbstring \
--with-zlib \
--enable-fpm \
--with-freetype-dir=/usr \
--with-jpeg-dir=/usr \
--with-png-dir=/usr

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.