1.下載
# wget http://php.net/get/php-7.1.4.tar.gz/from/a/mirror
或者# wget http://am1.php.net/distributions/php-7.1.4.tar.gz
前者得到一個mirror文件芯咧,后者得到php-7.1.4.tar.gz,均可以通過tar解壓
2.解壓
# tar zxvf php-7.1.4.tar.gz 或 tar zxvf mirror
# cd php-7.1.4
3.查看安裝幫助,執(zhí)行配置腳本來進(jìn)行編譯預(yù)處理
# ./configure --help
# ./configure --prefix=/usr/local/php \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-iconv-dir \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--enable-fpm \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-gd-native-ttf \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvsem \
--enable-xml \
--enable-zip
4.編譯預(yù)處理可能會出現(xiàn)一些error,一般是缺少依賴包的原因菩暗,根據(jù)提示安裝即可
# apt-get install libxml2 libxml2-dev
# apt-get install openssl
//configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
#apt-get install libssl-dev
#apt-get install libgtk2.0-dev
//configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
// RetHat CentOS or Fedora 使用下面安裝命令
# yum install curl curl-devel
// Debian or Ubuntu使用下面的安裝命令
# apt-get install curl
# apt-get install libcurl4-gnutls-dev
//configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
# apt-get install libxslt-dev
5.預(yù)處理通過之后就可以make編譯了
# make && make install
6.配置php
編譯安裝成功后肴敛,一般可以在usr/local找到安裝的php
//php.ini
# cp php.ini-development /usr/local/php/lib/php.ini
//php-fpm
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm 或cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
需要注意的是php7中www.conf這個配置文件配置phpfpm的端口號等信息璃哟,如果你修改默認(rèn)的9000端口號需在這里改缰猴,再改nginx的配置
7.啟動
//查看php版本
# /usr/local/php/bin/php -v
# /etc/init.d/php-fpm start
或 # service php-fpm start
//php-fpm 可用參數(shù) start|stop|force-quit|restart|reload|status
//若權(quán)限不足需要需要加上執(zhí)行權(quán)限
chmod +x /etc/init.d/php-fpm
//Starting php-fpm [06-May-2017 14:10:49] ERROR: [pool www] cannot get gid for group 'nobody'
[06-May-2017 14:10:49] ERROR: FPM initialization failed
failed
//確定php-fpm配置文件的路徑产艾,執(zhí)行
#ps -aux | grep php-fpm
在安裝目錄的etc下有個php-fpm.d目錄(如/usr/local/php/etc/php-fpm.d),打開這個目錄后滑绒,找到www.conf文件闷堡,修改該文件里:
user = 啟動fpm的用戶名
group = 啟動fpm的用戶所在用戶組
//不推薦用root用戶啟動,應(yīng)當(dāng)新建用戶
#adduser phpq //新建phpq用戶
#passwd phpq //給phpq用戶設(shè)置密碼
#groupadd test //新建test工作組
//The program 'php' can be found in the following packages:
* php7.0-cli
* hhvm
sudo apt install php
sudo apt install hhvm
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者