php編譯安裝能夠讓組件配置更靈活,但須要你對php的各類配置很是熟悉,具體的編譯參數能夠在php解壓的路徑下執行「./configure --help」進行詳細查看。如下爲大體安裝流程,可供參考。php
安裝依賴包mysql
yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel libzip
下載安裝包並解壓sql
wget http://php.net/distributions/php-7.3.2.tar.gz tar -zxvf php-7.3.2.tar.gz cd php-7.3.2
編譯安裝(./configure --help可查看編譯參數)api
./configure \ --prefix=/usr/local/php\ --enable-fpm\ --with-fpm-user=www\ --with-fpm-group=www\ --with-config-file-path=/usr/local/php/conf\ --disable-rpath\ --enable-soap\ --with-libxml-dir\ --with-xmlrpc\ --with-openssl\ --with-mhash\ --with-pcre-regex\ --with-zlib\ --enable-bcmath\ --with-bz2\ --enable-calendar\ --with-curl\ --enable-exif\ --with-pcre-dir\ --enable-ftp\ --with-gd\ --with-openssl-dir\ --with-jpeg-dir\ --with-png-dir\ --with-zlib-dir\ --with-freetype-dir\ --enable-gd-jis-conv\ --with-gettext\ --with-gmp\ --with-mhash\ --enable-mbstring\ --with-onig\ --with-mysqli=mysqlnd\ --with-pdo-mysql=mysqlnd\ --with-zlib-dir\ --with-readline\ --enable-shmop\ --enable-sockets\ --enable-sysvmsg\ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx\ --with-libxml-dir\ --with-xsl\ --enable-zip\ --with-pear
注意:若是在配置時報libzip版本過低,請卸載從新安裝高版本bash
完成後,再進行編譯及安裝,執行 make && make install 便可安裝。php7
注意:若是編譯時報:php7 configure: error: off_t undefined; check your library configuration錯誤,請執行如下操做:curl
# 添加搜索路徑到配置文件 echo '/usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64'>>/etc/ld.so.conf # 更新配置 ldconfig -v
注意:若是編譯時報:/usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory 錯誤,請執行如下操做:socket
在安裝完新版的 libzip 時可能會出現打不到 zipconf.h,手動複製一下 cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
安裝後配置memcached
執行完安裝命令後php7就已經安裝在到了/usr/local/php目錄下了。php-fpm
/usr/local/php/bin/php -v
查看安裝是否成功。
爲了之後方便,能夠編輯 /etc/profile 添加環境變量 ,添加到最後面
PATH=$PATH:/usr/local/php/bin export PATH
而後更新環境變量。
source /etc/profile
查看環境變量
echo $PATH
查看php版本
php -v
配置php-fpm
cp php.ini-production /usr/local/php/conf/php.ini
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
將php-fpm加入啓動服務
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service
啓動php-fpm
systemctl start php-fpm.service
若是報這種錯誤
Starting php-fpm [2-Feb-2019 21:02:25] ERROR: [pool www] cannot get uid for user 'www'
說明沒有該用戶,直接執行
groupadd www useradd -g www www
而後再啓動php-fpm