CentOS6.x安裝php5.6.x

dav2100發表於2021-09-09

一、系統及安裝說明

      系統:CentOS6.x_x64,php5.6.12版本以及四個擴充套件模組(libmcrypt-2.5.8.tar.gz ;php-redis.tar.gz;jpegsrc.v8d.tar.gz ;zendopcache-7.0.5.tar.gz)。

共享連結: 密碼: dftq


二、安裝指令碼及說明

1、下載完安裝包並解壓

#!/bin/bash

  

src=$(pwd)    #解壓軟體包進入目錄

#安裝依賴環境

yum install -y  gcc gcc-c++ openssl openssl-devel libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel gd bzip2 bzip2-devel curl curl-devel freetype freetype-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel

cd $src

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure

make && make install

cd $src

tar zxvf jpegsrc.v8d.tar.gz

cd jpeg-8d

./configure -enable-shared -enable-static

make && make install clean

cd $src

tar xvf php-5.6.12.tar.gz

cd php-5.6.12

./configure --prefix=/usr/php5.6

--with-libxml-dir=/usr/include/libxml2

--with-mysql --with-mysqli --with-gd

--enable-gd-native-ttf --with-zlib --with-mcrypt

--with-pdo-mysql --enable-shmop --enable-sockets

--enable-zip --enable-fpm --enable-mbstring

--with-zlib-dir --with-bz2 --with-curl --with-jpeg-dir=/usr/local

--with-png-dir=/usr/local --with-freetype-dir=/usr/local/

--with-iconv --enable-xml --enable-bcmath --enable-sysvsem

--with-openssl

--enable-pcntl --with-gettext

--enable-session

--enable-exif

make

make install

##Configure php-fpm

[ -d /data1/log/ ] || mkdir -pv data1/log

echo 'export PATH=/usr/php5.6/bin:$PATH' >/etc/profile.d/php5.6.sh

source /etc/profile.d/php5.6.sh

cd $src

cd php-5.6.12

cp php.ini-production /usr/php5.6/etc/php.ini

rm -rf /etc/php.ini

ln -s /usr/php5.6/etc/php.ini /etc/php.ini

ln -s /usr/php5.6/etc/php.ini /usr/php5.6/lib/php.ini

cp /usr/php5.6/etc/php-fpm.conf.default /usr/php5.6/etc/php-fpm.conf

sed -i "s/^;pid = run/php-fpm.pid/pid = run/php-fpm56.pid/g" /usr/php5.6/etc/php-fpm.conf

if [ -u nginx ]

then

sed -i "s/^user = nobody/user = nginx/g" /usr/php5.6/etc/php-fpm.conf

sed -i "s/^group = nobody/group = nginx/g" /usr/php5.6/etc/php-fpm.conf

fi

sed -i "s/^;error_log = log/php-fpm.log/error_log = /data1/log/php-fpm56.log/g" /usr/php5.6/etc/php-fpm.conf

cp $src_tmp/php-fpm /etc/init.d/php-fpm

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

chkconfig --add php-fpm

chkconfig php-fpm on

service php-fpm start

#Add Zendopcache

cd $src

tar xvf zendopcache-7.0.5.tar.gz

cd zendopcache-7.0.5

phpize

./configure

make

make install

cd $src

tar xvf php-redis.tar.gz

cd php-redis-2.2.7

phpize

./configure

make

make install

sed -i "716s:.*:extension_dir = /usr/php5.6/lib/php/extensions/no-debug-non-zts-20131226/:g" /usr/php5.6/lib/php.ini

sed -i "s/^;date.timezone =/date.timezone = Asia/Shanghai/g" /usr/php5.6/lib/php.ini

sed -i "s/^expose_php = On/expose_php = Off/g" /usr/php5.6/lib/php.ini

sed -i "s/^display_errors = Off/display_errors = On/g" /usr/php5.6/lib/php.ini

sed -i "s/^;error_log = php_errors.log/error_log = /data1/log/php_errors.log/g" /usr/php5.6/lib/php.ini

sed -i "s/^display_startup_errors = Off/display_startup_errors = On/g" /usr/php5.6/lib/php.ini

echo 'zend_extension=/usr/php5.6/lib/php/extensions/no-debug-non-zts-20131226/opcache.so

opcache.memory_consumption=128

opcache.interned_strings_buffer=8

opcache.max_accelerated_files=4000

opcache.revalidate_freq=60

opcache.fast_shutdown=1

opcache.enable_cli=1'>>/usr/php5.6/lib/php.ini

echo "extension=redis.so" >>/usr/php5.6/lib/php.ini


儲存好php_install.sh。   預設設定安裝在/usr/php5.6目錄下。

三、安裝流程

1、解壓並安裝

解壓下載好的壓縮包並進入解壓後的軟體包目錄並執行一鍵安裝指令碼php_install.sh

#tar xvf php5.6.12.tar.gz

#cd php5.6.12

#./php_install.sh


安裝過程隨機器效能需要等待一段時間;

2、驗證

安裝完成後系統登出,再登入執行以下驗證

#php -v

PHP 5.6.12 (cli) (built: Dec  2 2017 00:12:49) 

Copyright (c) 1997-2015 The PHP Group

Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies


#service php-fpm status

php-fpm56 (pid 6276) is running...


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4479/viewspace-2801515/,如需轉載,請註明出處,否則將追究法律責任。

相關文章