linux編譯安裝php7

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

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

2.而後解壓mysql

tar -xvf php-7.0.12.tar.bz2linux

3.而後安裝依賴庫nginx

sudo apt-get updatesql

sudo apt-get install libxml2-devvim

sudo apt-get  install  build-essentialphp7

sudo apt-get install opensslcurl

sudo apt-get install libssl-devsocket

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

若是提示configure: error: Cannot find OpenSSL's libraries,請看另外一篇文章:安裝php提示 configure: error: Cannot find OpenSSL's libraries 解決方案

成功後會輸出:

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

相關文章
相關標籤/搜索