linux編譯安裝php7

來源:互聯網
上載者:User

標籤:reg   libc   ons   socket   sock   編輯   nat   tar   class   

1.首先下載php7 使用wget命令下載

wget http://cn2.php.net/distributions/php-7.0.12.tar.bz2

2.然後解壓

tar -xvf php-7.0.12.tar.bz2

3.然後安裝依賴庫

sudo apt-get update

sudo apt-get install libxml2-dev

sudo apt-get  install  build-essential

sudo apt-get install openssl

sudo apt-get install libssl-dev

sudo apt-get install curl

sudo apt-get install libcurl4-gnutls-dev

sudo apt-get install libjpeg-dev

sudo apt-get install libpng-dev

sudo apt-get install libmcrypt-dev

sudo apt-get install libreadline6 libreadline6-dev

sudo apt-get install libfreetype6-dev  

4.編譯

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --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 --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

成功後會輸出:

Thank you for using PHP.

make && make install

5.下面是對php-fpm運行使用者進行設定 (一般為nginx使用者)

配置php-fpm

cd /usr/local/php/etc

複製php-fpm檔案

cp php-fpm.conf.default php-fpm.conf

開啟php-fpm檔案

vim php-fpm.conf

編輯php-fpm檔案

找到

;error_log = log/php-fpm.log 

;include=/usr/local/php/etc/php-fpm.d/*.conf

如果有注釋,就去掉前面的注釋    【;】

進入php-fpm.d目錄

cd php-fpm.d

修改 www.conf 檔案:

如果這個檔案不存在,就從default複製一份:

cp www.conf.default www.conf

vim www.conf

將設定檔中的 user 和 group 部分的 nobody 改成 www:

修改

user = www

group = www

如果www使用者不存在,那麼先添加www使用者

groupadd www

useradd -g www www

啟動php-fpm

sudo /usr/local/php/sbin/php-fpm

6.加入系統變數

sudo echo "PATH=$PATH:/usr/local/php/bin">> /etc/profile

sudo echo "export PATH">> /etc/profile

source /etc/profile

php -v

推薦文章,linux下編譯安裝nginx 

http://www.jianshu.com/p/a0abbe0a443f

 

 

linux編譯安裝php7

聯繫我們

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