CentOS6.x安装php5.6.x

释放双眼,带上耳机,听听看~!

一、系统及安装说明

      系统: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)。

共享链接: https://pan.baidu.com/s/1cg3YiE 密码: 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…

【转自慕课】https://www.imooc.com

PHP

十七章 AJAX学习笔记(一)PHP实例

2022-3-3 7:49:48

PHP

Linux安装配置PHP+Nginx

2022-3-3 7:55:39

搜索