CentOS 7解壓安裝PHP7 1 21

2021-09-08 14:14:13 字數 2705 閱讀 4708

yum install -y wget

wget

解壓

tar -zxvf php-7.1.21.tar.gz

cd php-7.1.21

編譯:

# 安裝epel

yum install -y epel-release

wget -o /etc/yum.repos.d/epel.repo

# 安裝編譯依賴

yum install -y 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 gcc

# 建立目錄

mkdir -p /data/service/php/etc

./configure \--prefix=/data/service/php \--with-config-file-

path=/data/service/php/etc \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-inline-optimization \--disable-

debug \--disable-rpath \--enable-shared \--enable-soap \--with-libxml-

dir \--with-xmlrpc \--with-openssl \--with-mcrypt \--with-mhash \--with-pcre-regex \--with-sqlite3 \--with-zlib \--enable-bcmath \--with-iconv \--with-bz2 \--enable-calendar \--with-curl \--with-cdb \--enable-dom \--enable-exif \--enable-fileinfo \--enable-filter \--with-pcre-

dir \--enable-ftp \--with-gd \--with-openssl-

dir \--with-jpeg-

dir \--with-png-

dir \--with-zlib-

dir \--with-freetype-

dir \--enable-gd-native-ttf \--enable-gd-jis-conv \--with-gettext \--with-gmp \--with-mhash \--enable-json \--enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--with-libmbfl \--with-onig \--enable-pdo \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-zlib-

dir \--with-pdo-sqlite \--with-readline \--enable-session \--enable-shmop \--enable-******xml \--enable-sockets \--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-wddx \--with-libxml-

dir \--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear \--enable-opcache

make && make install

增加環境變數

cat export 

path=/data/service/php/bin:\$path

eof# 生效環境變數

. /etc/profile

配置php-fpm

cp php.ini-production /data/service/php/etc/php.ini

cp /data/service/php/etc/php-fpm.conf.default /data/service/php/etc/php-fpm.conf

cp /data/service/php/etc/php-fpm.d/www.conf.default /data/service/php/etc/php-fpm.d/www.conf

配置php-fpm服務

# 注意:這個檔案是根據上面c++編譯配置動態生成的檔案,裡面寫了上面配置的路徑

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

#啟動許可權

chmod +x /etc/init.d/php-fpm

啟動:

#增加開機啟動

systemctl enable php-fpm

systemctl

start php-fpm

注意:php-fpm需要nginx使用者,當然你可以自行增加,也可以直接安裝nginx。

自動化指令碼:

參考:

CentOS 7 編譯安裝 PHP 7

使用編譯的方式來安裝 php 7。輸入yum y install libxml2 libxml2 devel openssl openssl devel curl devel libjpeg devel libpng devel freetype devel libmcrypt devel mhas...

CentOS 7 編譯安裝 PHP 7

使用編譯的方式來安裝 php 7。輸入yum y install libxml2 libxml2 devel openssl openssl devel curl devel libjpeg devel libpng devel freetype devel libmcrypt devel mhas...

Centos7 編譯安裝PHP7

centos7 編譯安裝php7 yum groupinstall development tools 2 安裝依賴包 yum install libxml2 libxml2 devel openssl openssl devel bzip2 bzip2 devel libcurl libcurl ...