您的位置:首页 > 运维架构 > Linux

php linux 环境安装配置 及 扩展安装

2017-03-14 19:56 567 查看
在最新的版本5.6.3不仅修改了多个Bug,并且修改了fileinfo模块里存在的安全漏洞。

PHP团队推荐使用PHP5.6系列的用户,升级到最新版本5.6.3以上。

简单介绍一下,如何在CentOS上安装PHP5.6。

配置yum源

追加CentOS 6.5的epel及remi源。

# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm[/code] 
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm[/code] 
以下是CentOS 7.0的源。

# yum install epel-release
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm[/code] 
使用yum list命令查看可安装的包(Packege)。

# yum list --enablerepo=remi --enablerepo=remi-php56 | grep php


安装PHP5.6

yum源配置好了,下一步就安装PHP5.6。

# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof


用PHP命令查看版本。

# php --version
PHP 5.6.0 (cli) (built: Sep  3 2014 19:51:31)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans


在这里安装的版本是PHP5.6.0,细心的用户可能已经发现ZendGuardLoader变成Zend OPcahe了。

对从PHP5.5开始PHP代码缓存从APC变成了Zend OPcache了。

安装mongodb扩展

wgwt http://pecl.php.net/get/mongodb-1.2.5.tgz 
tar zxf mongodb-1.2.5.tgz

cd mongo-1.2.5

/usr/bin/phpize

./configure

make &&make install


#php.ini添加extension=mongodb.so

安装php-fpm

yum --enablerepo=remi,remi-php56 install php-fpm php-common php-mysql php-opcache php-pear php-gd php-devel php-mbstring php-mcrypt php-cli php-pdo php-xml -y


安装

memcache 的工作就是在专门的机器的内存里维护一张巨大的hash表,来存储经常被读写的一些数组与文件,从而极大的提高网站的运行效率,减轻后端数据库的读写压力。

实验环境:centos 6.6 x86_64

1、在安装memcached之前需要安装libevent支持:

# wget http://syslab.comsenz.com/downloads/linux/libevent-1.4.12-stable.tar.gz # tar zxvf libevent-1.4.12-stable.tar.gz
# cd libevent-1.4.12-stable
#./configure --prefix=/usr/local/libevent
#make && make install


2、服务器端 memcached 的编译安装

# wget http://syslab.comsenz.com/downloads/linux/memcached-1.4.5.tar.gz # tar zxvf memcached-1.4.5.tar.gz
# cd memcached-1.4.5
# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/
# make && make install


3、客户端安装memcache步骤:

# wget http://www.lishiming.net/data/attachment/forum/memcache-2.2.3.tgz # tar zxvf memcache-2.2.3.tgz
# cd memcache-2.2.3

# /usr/php/bin/phpize
# ./configure --with-php-config=/usr/bin/php-config --enable-memcache
# make


1)安装libevent库

wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz tar zxvf libevent-2.0.20-stable.tar.gz
cd libevent-2.0.20-stable/
/usr/bin/phpize
./configure --prefix=/usr/local/libevent/
make
make install


(2)安装libevent扩展(http://pecl.php.net/package/libevent)

wget http://pecl.php.net/get/libevent-0.1.0.tgz 
tar -zxvf libevent-0.1.0.tgz

cd libevent-0.1.0
/usr/bin/phpize
./configure --with-php-config=/usr/bin/php-config --with-libevent=/usr/local/libevent/
make && make install


#php.ini添加extension=libevent.so

三 配置php.ini文件

首先通过phpinfo函数,找到php.ini的路径,我的是:/etc/php.ini

在其中添加如下内容:

extension=memcache.so
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192


开机自启

chkconfig php-fpm on


加入服务

chkconfig --add nginx
chkconfig --add php-fpm


开机自启

chkconfig nginx on
chkconfig php-fpm on


CentOS环境中安装SSH2扩展,顺带记录下来,以备后面如果有需要用到的时候参考。

备注说明:如果我们需要在正式环境中直接运行,建议还是先在测试机中调试后再使用或者备份好数据,以免可能造成的问题。

第一、安装支持库文件

yum install  php-devel php-pear libssh2 libssh2-devel -y


直接登录SSH客户端,然后执行命令回车,安装需要的库文件。

第二、安装SSH2扩展

pecl install -f ssh2


最后就能开心的玩耍了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php