Centos7 2 編譯安裝PHP7

2022-07-19 11:15:15 字數 4444 閱讀 2753

php7,編譯安裝:

環境:centos7.2    (注意:因為我用的nginx, 此配置引數沒有考慮到apache,所以不合適需要用apache的朋友照搬過去執行,但是可以參考。

$cd /usr/src/

$wget

#解壓$tar -xzxvf php-7.0.2.tar.gz

$cd php-7.0.2

解壓完後先不要編譯,請檢查是否安裝了gcc,沒有的話執行yum install gcc

檢查是否安裝了libxml2,沒有的話執行yum install libxml2

檢查是否安裝了libxml2-devel,沒有的話執行yum install libxml2-devel

注:因為改為用nginx了,所以編譯引數中的--with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安裝php前,請先安裝apache。

編譯引數配置

'./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'

出現報錯cannot find openssl's

則執行yum install openssl openssl-devel

出現報錯please reinstall the libcurl distribution

則執行yum -y install curl-devel

出現報錯jpeglib.h not found

則執行yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y

和執行yum install libjpeg-devel

checking for bzip2 in default path... not found

configure: error: please reinstall the bzip2 distribution

這是bzip2軟體包沒有安裝

解決辦法

yum install bzip2-devel.x86_64 -y

configure: error: xpm.h not found.

yum install libxpm-devel

error: unable to locate gmp.h

fix: yum install gmp-devel

現象:unable to detect icu prefix or /usr//bin/icu-config failed. please verify icu install

prefix and make sure icu-config works

解決辦法:yum install -y icu libicu libicu-devel

錯誤:mcrypt.h not found. please reinstall libmcrypt.

解決辦法:yum  install  php-mcrypt  libmcrypt  libmcrypt-devel

錯誤:configure: error: cannot find libpq-fe.h. please specify correct postgresql installation path

解決辦法:yum install  postgresql-devel

錯誤 :configure: error: xslt-config not found. please reinstall the libxslt >= 1.1.0 distribution

解決:yum install libxslt-devel

配置的checking 結束後,執行:

make clean && make && make install

安裝完成後,我們要把原始碼包中的配置檔案複製到php安裝目錄下,原始碼包中有兩個配置  php.ini-development  php.ini-production  ,看名字就知道,乙個是開發環境,乙個是生產環境,我們這裡就複製開發環境的

cp php.ini-development /usr/local/php/lib/php.ini

另外還需要設定環境變數 :

修改/etc/profile檔案使其永久性生效,並對所有系統使用者生效,在檔案末尾加上如下兩行**

path=$path:/usr/local/php/bin

export path

然後執行 命令source /etc/profile

php -v 就可以看到php版本資訊了。

此時還需要配置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

啟動php-fpm:

/etc/init.d/php-fpm start

如果出現錯誤:error: [pool www] cannot get uid for user 'www-data'

則新建www-data 使用者組:

groupadd www-data

useradd -g www-data www-data

然後再啟動php-fpm

然後安裝nginx

yum install nginx

CentOS 7 2編譯安裝Tengine

tengine官網上有個非常簡單的教程,中間並未涉及到一些常用的設定,所以僅供參考。一下午為本人的安裝步驟及過程。配置firewalld,iptables,關閉selinux 1 安裝必要的編譯環境好 由於tengine安裝需要使用源 自行編譯,所以在安裝前需要安裝必要的編譯工具 yum y upd...

CentOS 7 2編譯安裝Tengine

tengine官網上有個非常簡單的教程,中間並未涉及到一些常用的設定,所以僅供參考。一下午為本人的安裝步驟及過程。配置firewalld,iptables,關閉selinux 1 安裝必要的編譯環境好 由於tengine安裝需要使用源 自行編譯,所以在安裝前需要安裝必要的編譯工具 yum y upd...

centos 7 2 編譯安裝caffe

yum install git git clone cd caffe cp makefile.config.example makefile.config yum install vim yum install gcc yum y groupinstall development tools yum...