CentOS 下編譯PHP 7

來源:互聯網
上載者:User

前言

PHP 7也發布好久了,截至目前PHP 7版本為PHP 7.0.1,本文版本跟隨官方採用最新版本編譯,如果沒有太大變動也同樣適用於PHP 7.0.1以後版本。

本次編譯在百度雲(CentOS 6)下完成。

編譯PHP

在編譯之前我們需要搞定一些依賴程式。

yum install gcc make libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel  pcre-devel libcurl-devel libmcrypt libmcrypt-devel

添加一個www使用者用於運行PHP

groupadd wwwuseradd-s /sbin/nologin -g www www

然後下載PHP的安裝包並解壓

wget http://cn2.php.net/distributions/php-7.0.1.tar.gz && tar -zxvf php-7.0.1.tar.gz && cd php-7.0.1

編譯

./configure --prefix=/opt/software/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcachemake && make install

執行上面代碼後PHP將會被編譯到 /opt/software/php目錄下。

複製php.ini

cp php.ini-production /opt/software/php/etc/php.ini

然後把php-fpm.conf.default 搞一份出來

cd /opt/software/php/etccp php-fpm.conf.default php-fpm.conf

然後把php-fpm.d 裡面 www.conf.default 搞一份出來

cd php-fpm.d && cp www.conf.default www.conf

然後檢查看看有沒有錯誤,沒有就啟動php-fpm

/opt/software/php/sbin/php-fpm -t

如果提示successfully字樣

/opt/software/php/sbin/php-fpm
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.