Centos7.2 編譯安裝PHP7.0.2的步驟
環(huán)境
- 系統(tǒng):Centos7.2
- 服務(wù):Nginx
1:下載PHP7.0.2的安裝包解壓,編譯,安裝:
$ cd /usr/src/ $ wget http://cn2.php.net/distributions/php-7.0.2.tar.gz $ tar -xzxvf php-7.0.2.tar.gz $ cd php-7.0.2
1.1編譯前檢查
請(qǐng)檢查是否安裝了gcc ,沒(méi)有的話執(zhí)行yum install gcc
檢查是否安裝了libxml2 ,沒(méi)有的話執(zhí)行yum install libxml2
檢查是否安裝了libxml2-devel,沒(méi)有的話執(zhí)行yum install libxml2-devel
注:因?yàn)楦臑橛胣ginx了,所以編譯參數(shù)中的--with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安裝PHP前,請(qǐng)先安裝apache。*
2:編譯參數(shù)配置
'./configure' '--prefix=/usr/local/php' '--with-pdo-pgsql' '--with-zlib-dir' '--with-freetype-dir' '--enable-mbstring' '--with-libxml-dir=/usr' '--enable-soap' '--enable-calendar' '--with-curl' '--with-mcrypt' '--with-gd' '--with-pgsql' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-zlib' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-pcntl' '--enable-mbregex' '--enable-exif' '--enable-bcmath' '--with-mhash' '--enable-zip' '--with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-openssl' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--with-libdir=/lib/x86_64-linux-gnu/' '--enable-ftp' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm' '--with-iconv' '--with-xpm-dir=/usr'
3:錯(cuò)誤集合
報(bào)錯(cuò) Cannot find OpenSSL's <evp.h> 執(zhí)行 yum install openssl openssl-devel 報(bào)錯(cuò) Please reinstall the libcurl distribution 執(zhí)行 yum -y install curl-devel 錯(cuò)誤 jpeglib.h not found 執(zhí)行 yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y 和執(zhí)行 yum install libjpeg-devel 錯(cuò)誤:checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution 這是bzip2軟件包沒(méi)有安裝 執(zhí)行 yum install bzip2-devel.x86_64 -y 錯(cuò)誤:configure: error: xpm.h not found. 執(zhí)行 yum install libXpm-devel 錯(cuò)誤: Unable to locate gmp.h 執(zhí)行 yum install gmp-devel 錯(cuò)誤:Unable to detect ICU prefix or /usr//bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works 執(zhí)行 yum install -y icu libicu libicu-devel 錯(cuò)誤:mcrypt.h not found. Please reinstall libmcrypt. 執(zhí)行 yum install php-mcrypt libmcrypt libmcrypt-devel 錯(cuò)誤: configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path 執(zhí)行 yum install postgresql-devel 錯(cuò)誤: configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution 執(zhí)行 yum install libxslt-devel
4:編譯
make clean && make && make install
5:PHP配置
5.1安裝完成后,我們要把源碼包中的配置文件復(fù)制到PHP安裝目錄下,源碼包中有兩個(gè)配置 php.ini-development php.ini-production ,看名字就知道,一個(gè)是開(kāi)發(fā)環(huán)境,一個(gè)是生產(chǎn)環(huán)境,我們這里就復(fù)制開(kāi)發(fā)環(huán)境的
cp php.ini-development /usr/local/php/lib/php.ini
5.2另外還需要設(shè)置環(huán)境變量 :修改/etc/profile文件使其永久性生效,并對(duì)所有系統(tǒng)用戶生效,在文件末尾加上如下兩行代碼
PATH=$PATH:/usr/local/php/bin export PATH
5.3 然后執(zhí)行生效命令
source /etc/profile
5.4查看PHP版本信息
php -v
6:配置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 /usr/src/php-7.0.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm
6.1 啟動(dòng)php-fpm:
/etc/init.d/php-fpm start
6.2 如果出現(xiàn)錯(cuò)誤:ERROR: [pool www] cannot get uid for user 'www-data'
則新建www-data 用戶組:
groupadd www-data useradd -g www-data www-data
6.3 重啟php-fpm
/etc/init.d/php-fpm restart
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持本站。
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。