centos6.5 安装php5.6

安装php

安装依赖包

yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel –y

安装epel源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

yum -y install libmcrypt-devel mcytpt mhash libxslt-devel

安装libiconv

tar -zxvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure –prefix=/usr/lcoal/libiconv

Make && make install

解压安装包

tar -zxvf php-5.6.20.tar.gz

配置编译安装

cd php-5.6.20

./configure  \

–prefix=/usr/local/php-5.6.20 \

–with-config-file-path=/usr/local/php-5.6.20/etc \

–with-fpm-user=nginx \

–with-fpm-group=nginx \

–with-bz2 \

–with-curl \

–with-gd \

–with-mcrypt \

–with-openssl \

–with-mhash \

–with-jpeg-dir \

–with-png-dir \

–with-freetype-dir \

–with-iconv-dir=/usr/local/libiconv \

–with-gettext \

–with-libxml-dir=/usr/local \

–with-zlib \

–with-xsl \

–with-pdo-mysql=mysqlnd \

–with-mysql=mysqlnd \

–with-mysqli=mysqlnd \

–with-libdir=lib64 \

–enable-dom \

–enable-xml \

–enable-fpm \

–enable-bcmath \

–enable-ftp \

–enable-sockets \

–disable-ipv6 \

–enable-mbregex \

–enable-mbstring \

–enable-calendar \

–enable-gd-native-ttf \

–enable-static \

make

make install

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

cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf

cd /usr/local/php/

mkdir log

编辑配置文件

pid = /var/log/php-fpm.pid

error_log = log/php-fpm.log

log_level = error

rlimit_files = 32768

events.mechanism = epoll

[www]

user = nginx

group = nginx

listen = 127.0.0.1:9000

pm = dynamic

pm.max_children = 1024

pm.start_servers = 16

pm.min_spare_servers = 5

pm.max_spare_servers = 20

pm.process_idle_timeout = 15s;

pm.max_requests = 2048

slowlog = log/$pool.log.slow

request_slowlog_timeout = 10

创建启动停止脚本:

vim /etc/init.d/php-fpm

#! /bin/sh

### BEGIN INIT INFO

# Provides:          php-fpm

# Required-Start:    $remote_fs $network

# Required-Stop:     $remote_fs $network

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: starts php-fpm

# Description:       starts the PHP FastCGI Process Manager daemon

### END INIT INFO

prefix=/usr/local/php

exec_prefix=${prefix}

php_fpm_BIN=${exec_prefix}/sbin/php-fpm

php_fpm_CONF=${prefix}/etc/php-fpm.conf

php_fpm_PID=${prefix}/var/run/php-fpm.pid

php_opts=”–fpm-config $php_fpm_CONF –pid $php_fpm_PID”

wait_for_pid () {

try=0

while test $try -lt 35 ; do

case “$1” in

‘created’)

if [ -f “$2” ] ; then

try=”

break

fi

;;

‘removed’)

if [ ! -f “$2” ] ; then

try=”

break

fi

;;

esac

echo -n .

try=`expr $try + 1`

sleep 1

done

}

case “$1” in

start)

echo -n “Starting php-fpm “

$php_fpm_BIN –daemonize $php_opts

if [ “$?” != 0 ] ; then

echo ” failed”

exit 1

fi

wait_for_pid created $php_fpm_PID

if [ -n “$try” ] ; then

echo ” failed”

exit 1

else

echo ” done”

fi

;;

stop)

echo -n “Gracefully shutting down php-fpm “

if [ ! -r $php_fpm_PID ] ; then

echo “warning, no pid file found – php-fpm is not running ?”

exit 1

fi

kill -QUIT `cat $php_fpm_PID`

wait_for_pid removed $php_fpm_PID

if [ -n “$try” ] ; then

echo ” failed. Use force-quit”

exit 1

else

echo ” done”

fi

;;

status)

if [ ! -r $php_fpm_PID ] ; then

echo “php-fpm is stopped”

exit 0

fi

PID=`cat $php_fpm_PID`

if ps -p $PID | grep -q $PID; then

echo “php-fpm (pid $PID) is running…”

else

echo “php-fpm dead but pid file exists”

fi

;;

force-quit)

echo -n “Terminating php-fpm “

if [ ! -r $php_fpm_PID ] ; then

echo “warning, no pid file found – php-fpm is not running ?”

exit 1

fi

kill -TERM `cat $php_fpm_PID`

wait_for_pid removed $php_fpm_PID

if [ -n “$try” ] ; then

echo ” failed”

exit 1

else

echo ” done”

fi

;;

restart)

$0 stop

$0 start

;;

reload)

echo -n “Reload service php-fpm “

if [ ! -r $php_fpm_PID ] ; then

echo “warning, no pid file found – php-fpm is not running ?”

exit 1

fi

kill -USR2 `cat $php_fpm_PID`

echo ” done”

;;

configtest)

$php_fpm_BIN -t

;;

*)

echo “Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}”

exit 1

;;

esac

赋予权限

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

启动

[[email protected] php-5.6.20]# service php-fpm start

Starting php-fpm  done

[[email protected] php-5.6.20]# netstat -anpt |grep php-fpm

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      16070/php-fpm

配置nginx 支持php

打开配置文件在server区块加入下面内容(这里是虚拟主机,网站根目录也在cj下面)

server {

listen       80;

server_name  www.cj.com cj.com;

charset utf-8;

#access_log        logs/access_cj.log main;

access_log  logs/access_cj.log;

location / {

root   html/cj;

index  index.html index.htm;

}

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

location ~ \.php$ {

            root           html;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param         SCRIPT_FILENAME   /usr/local/nginx/html/cj$fastcgi_script_name;

            include        fastcgi_params;

        }

}

时间: 2024-10-18 06:47:06

centos6.5 安装php5.6的相关文章

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)    #解压软件包进入目录 #安装依赖环境

centos6.6安装php5.3.3(2015/3/4)

问题:centos6.6因要升级mysql5.5所以yum重新更新了源,导致按照原来lamp环境安装步骤,安装php时一直找webtitic源,php5.3.24 而且一直无法安装下去 利用yum repolist 查到除了centos的源外,还有webtitic 的源 执行 yum clean all yum repolist 系统自动更新源,再查yum info php 版本为5.3.3 和原来一样,按照原安装文档安装.

centos6.5 安装php-5.6.31

1 从PHP官网下载所需要的PHP版本 下载地址:  http://php.net/get/php-5.6.31.tar.gz/from/a/mirror  把下载好的文件上传到服务器 2 安装PHP所需要的扩展 yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype

CentOS6.6安装PHP5.2.17(20150123)

第一步:安装所需的包 yum install wget make gcc gcc-c++ bison autoconf patch pcre-devel zlib-devel openssl-devel net-snmp-devel ncurses-devel libxml2-devel bzip2-devel gd-devel libcurl-devel mysql-devel memcached libtool-ltdl-devel 第二步:安装libmcrypt wget http://d

Centos6.8安装php5.6

检查当前安装的PHP包 yum list installed | grep php 如果有安装的PHP包,先删除他们, 如: yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 配置安装包源: # Centos 5.X rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm # CentOs 6.x rpm -Uvh http://mirror.webtatic.com/yum/el6

CentOS6.3 编译安装LAMP(4):编译安装 PHP5.2.17

所需源码包: /usr/local/src/PHP-5.2.17/libmcrypt-2.5.8.tar.gz /usr/local/src/PHP-5.2.17/mhash-0.9.9.9.tar.gz /usr/local/src/PHP-5.2.17/mcrypt-2.6.8.tar.gz /usr/local/src/PHP-5.2.17/libiconv-1.14.tar.gz /usr/local/src/PHP-5.2.17/php-5.2.17.tar.gz 在编译PHP之前,先

4、CentOS6.5下安装php5.3

操作系统:CentOS6.5 环境:Apache2.2安装成功.可查看:http://www.centoscn.com/image-text/install/2014/0505/2910.html Mysql5.5已经安装成功.可查看:http://www.centoscn.com/image-text/install/2014/0505/2911.html 1.下载php源码   http://www.php.net/downloads.php2.选择: php-5.3.28.tar.gz 3

CentOS6.x/6.5/6.4/6.3/6.2/7.x 64位安装php5.2(使用YUM自动安装)

默认情况下,CentOS6 64 bit 已经早已不支持php5.2.x ,但是某些php程序还需要zend optimizer支持,怎么办呢?目前大部分的yum repos 都已经不支持直接安装php5.2了,怎么在CentOS6.x/6.5/6.4/6.3/6.2/7.x 64位安装php5.2(使用YUM自动安装) wget -qq -O - http://www.atomicorp.com/installers/atomic | /bin/bash 备份[ !!! Take php.in

基于CentOS6.5环境之下的LNMP之编译安装PHP5.5.30

LNMP之编译安装PHP5.5.30 1.编译前操作: 1.1.netstat -tulnp | egrep "80|3306" tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      25392/nginx          tcp        0      0 :::3306                     :::*