centos php5.6 yum,centos7安装yum

阿里云上的centos 7.2怎么yum安装php 5.6

因之前通过网易的 centos镜像,将阿里云的 centos升级到最新版了,乘自己的项目尚未开始正式开发,遂将所有的相应环境都升级到最高。

查看 centos版本:

[root@iZ23d~]# cat/etc/centos-release

CentOS Linux release 7.2.1511(Core)

1、删除之前的 php版本:

[root@iZ23d~]# yum remove php* php-common

Loaded plugins: langpacks

Repository base is listed more than once in the configuration

Repository updates is listed more than once in the configuration

Repository extras is listed more than once in the configuration

Repository centosplus is listed more than once in the configuration

No Match for argument: php-5.4.16

No Match for argument: php-5.4.16.tar.gz

No Match for argument: php-7.0.1RC1

No Match for argument: php-7.0.1RC1.tar.gz

No Match for argument: phpMyAdmin-4.4.0.tar.gz

No Match for argument: php-common

No Packages marked for removal

2、rpm安装 Php7相应的 yum源:

[root@iZ23d~]# rpm-Uvh

Retrieving

warning:/var/tmp/rpm-tmp.LhJKKR: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY

Preparing...################################# [100%]

package webtatic-release-7-3.noarch is already installed

3、直接yum安装php7:

[root@iZ23d~]# yum install php70w

Loaded plugins: langpacks

Repository base is listed more than once in the configuration

Repository updates is listed more than once in the configuration

Repository extras is listed more than once in the configuration

Repository centosplus is listed more than once in the configuration

Resolving Dependencies

--> Running transaction check

。。。【省略】

Warning: RPMDB altered outside of yum.

Installing: php70w-common-7.0.0-1.w7.x86_64 1/3

Installing: php70w-cli-7.0.0-1.w7.x86_64 2/3

Installing: php70w-7.0.0-1.w7.x86_64 3/3

Verifying: php70w-7.0.0-1.w7.x86_64 1/3

Verifying: php70w-common-7.0.0-1.w7.x86_64 2/3

Verifying: php70w-cli-7.0.0-1.w7.x86_64 3/3

Installed:

php70w.x86_64 0:7.0.0-1.w7

Dependency Installed:

php70w-cli.x86_64 0:7.0.0-1.w7 php70w-common.x86_64 0:7.0.0-1.w7

Complete!

4、检查 php版本:

[root@iZ23d~]# php-v

PHP 7.0.0(cli)(built: Dec 2 2015 20:42:32)( NTS)

Copyright(c) 1997-2015 The PHP Group

Zend Engine v3.0.0, Copyright(c) 1998-2015 Zend Technologies

[root@iZ23d2e6hoqZ~]#

以上显示安装成功!

5、重启 Apache,查看 phpinfo:

[root@iZ23d~]# systemctl restart httpd.service

检查phpinfo:

PHP Version 7.0.0

SystemLinux iZ23d 3.10.0-229.11.1.el7.x86_64#1 SMP Thu Aug 6 01:06:18 UTC 2015 x86_64

Build DateDec 2 2015 20:43:38

Server APIApache 2.0 Handler

Virtual Directory Supportdisabled

Configuration File(php.ini) Path/etc

Loaded Configuration File/etc/php.ini

Scan this dir for additional.ini files/etc/php.d

Additional.ini files parsed/etc/php.d/bz2.ini,/etc/php.d/calendar.ini,/etc/php.d/ctype.ini,/etc/php.d/curl.ini,/etc/php.d/exif.ini,/etc/php.d/fileinfo.ini,/etc/php.d/ftp.ini,/etc/php.d/gettext.ini,/etc/php.d/gmp.ini,/etc/php.d/iconv.ini,/etc/php.d/json.ini,/etc/php.d/phar.ini,/etc/php.d/shmop.ini,/etc/php.d/simplexml.ini,/etc/php.d/sockets.ini,/etc/php.d/tokenizer.ini,/etc/php.d/xml.ini,/etc/php.d/zip.ini

PHP API20151012

PHP Extension20151012

Zend Extension320151012

Zend Extension BuildAPI320151012,NTS

PHP Extension BuildAPI20151012,NTS

Debug Buildno

Thread Safetydisabled

Zend Signal Handlingdisabled

Zend Memory Managerenabled

Zend Multibyte Supportdisabled

IPv6 Supportenabled

DTrace Supportenabled

Registered PHP Streamshttps, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip

Registered Stream Socket Transportstcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2

Registered Stream Filterszlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*

This program makes use of the Zend Scripting Language Engine:

Zend Engine v3.0.0, Copyright(c) 1998-2015 Zend Technologies

Configuration

apache2handler

Apache VersionApache/2.4.6(CentOS)

Apache API Version20120211

Server Administratorxxxxxx@xxxxxx.com

Hostname:Portxxxx.xxxxx.xxx:0

User/Groupapache(48)/48

Max RequestsPer Child: 0- Keep Alive: on- Max Per Connection: 100

TimeoutsConnection: 60- Keep-Alive: 15

Virtual ServerYes

Server Root/etc/httpd

Loaded Modulescore mod_so http_core mod_access_compat mod_actions mod_alias mod_allowmethods mod_auth_basic mod_auth_digest mod_authn_anon mod_authn_core mod_authn_dbd mod_authn_dbm mod_authn_file mod_authn_socache mod_authz_core mod_authz_dbd mod_authz_dbm mod_authz_groupfile mod_authz_host mod_authz_owner mod_authz_user mod_autoindex mod_cache mod_cache_disk mod_data mod_dbd mod_deflate mod_dir mod_dumpio mod_echo mod_env mod_expires mod_ext_filter mod_filter mod_headers mod_include mod_info mod_log_config mod_logio mod_mime_magic mod_mime mod_negotiation mod_remoteip mod_reqtimeout mod_rewrite mod_setenvif mod_slotmem_plain mod_slotmem_shm mod_socache_dbm mod_socache_memcache mod_socache_shmcb mod_status mod_substitute mod_suexec mod_unique_id mod_unixd mod_userdir mod_version mod_vhost_alias mod_dav mod_dav_fs mod_dav_lock mod_lua prefork mod_proxy mod_lbmethod_bybusyness mod_lbmethod_byrequests mod_lbmethod_bytraffic mod_lbmethod_heartbeat mod_proxy_ajp mod_proxy_balancer mod_proxy_connect mod_proxy_express mod_proxy_fcgi mod_proxy_fdpass mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_wstunnel mod_ssl mod_systemd mod_cgi mod_perl mod_php7

以上显示 php7安装成功!

如何在linux上安装php5.6,谢谢,

不知道你问的linux,是哪个发行版本,常用的如 ubntu,centos,debian等。

我列一个centos7(服务器常用这个版本)的安装方法吧

centos7默认使用yum install来安装程序,但默认源安装的php是5.4的,版本比较低,

要安装高版本的,要么下载源代码手动编译安装,但对不熟悉的,万一出点错误,会越搞越乱。我一般使用epel源安装php,里面各个版本都有,最新的php7.3

首先安装epel

rpm-ivh

这里面的url是目前我用的,如果提示出错,就是换url了,可以在电脑上手动打开epel源列表去检查 epel-release是哪个版本,换上对应的名字

按版本安装php

rpm-Uvh

yuminstallphp56wphp56w-mysqlphp56w-pdophp56w-gdphp56w-sslphp56w-mbstringphp56w-cliphp56w-xmlphp56w-bcmath

我这里列的是一些常用的php扩展,如果需要其它的,手动加上即可

如果需要安装php其它版本,把包名里的56改成对应版本即可,如

yuminstallphp71wphp71w-mysqlphp71w-pdophp71w-gdphp71w-sslphp71w-mbstringphp71w-cliphp71w-xmlphp71w-bcmath

yuminstallphp72wphp72w-mysqlphp72w-pdophp72w-gdphp72w-sslphp72w-mbstringphp72w-cliphp72w-xmlphp72w-bcmath

可对应安装php7.1和php7.2,这种安装方法,会默认配置好对应的设置,php.ini在/etc/中查找,命令行也默认启用了(php-cli)

centos下coreseek安装及使用方法

Coreseek中文全文检索引擎

Coreseek是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等应用场景,用户可以免费下载使用

一,coreseek简介

官方

Coreseek是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等应用场景。商业使用(例如,嵌入到其他程序中)需要获得商业授权。

Coreseek是一个支持中文的全文搜索引擎,意图为其他应用提供高速、低空间占用、高相关度结果的中文全文搜索能力。CoreSeek可以非常容易的与SQL数据库和脚本语言集成。

在Sphinx发行版本中提供的原生搜索API支持PHP、Python、Perl、Rudy和Java。搜索API非常轻量化,可以在几个小时之内移植到新的语言上。第三方API接口和插件提供了对Perl、C#、Haskell、Ruby-on-Rails支持,以及对其他可能的语言或者框架的支持。

版本介绍

Coreseek 3.2稳定版

Coreseek 4.1测式版

Coreseek 5最新版

二,安装Coreseek

注:本文是以centos+mysql做为数据源支持为基础的coreseek安装教程.mysql安装略过.

1,下载coreseek 3.2稳定版,下载其他版本请去官网自行下载

cd/usr/local/src/

wget

tar xzvf coreseek-3.2.14.tar.gz

cd coreseek-3.2.14

安装coreseek之前需要先安装需要预装的软件:yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel(注:这是centos 64位

其他系统请参考

2,安装mmseg

$ cd mmseg-3.2.14

$./bootstrap#输出的warning信息可以忽略,如果出现error则需要解决

$./configure--prefix=/usr/local/mmseg3

$ make make install

$ cd..

##如果提示libtool: unrecognized option `--tag=CC',请查看libtool问题解决方案

##安装完成后,mmseg使用的词典和配置文件,将自动安装到/usr/local/mmseg3/etc中

##中文分词测试,如果显示不正常,请检查当前环境下的locale和UTF-8中文字符显示设置

$/usr/local/mmseg3/bin/mmseg-d/usr/local/mmseg3/etc src/t1.txt

中文/x分/x词/x测试/x

中国人/x上海市/x

Word Splite took: 1 ms.

3,安装coreseek

$ cd csft-3.2.14

##执行configure,进行编译配置:

$ sh buildconf.sh

$./configure--prefix=/usr/local/coreseek--without-unixodbc--with-mmseg--with-mmseg-includes=/usr/local/mmseg3/include/mmseg/--with-mmseg-libs=/usr/local/mmseg3/lib/--with-mysql

如查提示找不到mysql includes file则使用下面的编译命令

./configure--prefix=/usr/local/coreseek--without-unixodbc--with-mmseg--with-mmseg-includes=/usr/local/mmseg3/include/mmseg/--with-mmseg-libs=/usr/local/mmseg3/lib/--with-mysql-includes=/alidata/server/mysql/include/--with-mysql-libs=/alidata/server/mysql/bin/

make make install

4,测式coreseek

cd../testpack

$/usr/local/coreseek/bin/indexer-c etc/csft.conf

##以下为正常情况下的提示信息:

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]

Copyright(c) 2007-2010,

Beijing Choice Software Technologies Inc()

using config file'etc/csft.conf'...

total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg

total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg

##

##csft-4.0版显示:ERROR: nothing to do.

##

$/usr/local/coreseek/bin/indexer-c etc/csft.conf--all

##以下为正常索引全部数据时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]

Copyright(c) 2007-2010,

Beijing Choice Software Technologies Inc()

using config file'etc/csft.conf'...

indexing index'xml'...

collected 3 docs, 0.0 MB

sorted 0.0 Mhits, 100.0% done

total 3 docs, 7585 bytes

total 0.075 sec, 101043 bytes/sec, 39.96 docs/sec

total 2 reads, 0.000 sec, 5.6 kb/call avg, 0.0 msec/call avg

total 7 writes, 0.000 sec, 3.9 kb/call avg, 0.0 msec/call avg

$/usr/local/coreseek/bin/indexer-c etc/csft.conf xml

##以下为正常索引指定数据时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]

Copyright(c) 2007-2010,

Beijing Choice Software Technologies Inc()

using config file'etc/csft.conf'...

indexing index'xml'...

collected 3 docs, 0.0 MB

sorted 0.0 Mhits, 100.0% done

total 3 docs, 7585 bytes

total 0.069 sec, 109614 bytes/sec, 43.35 docs/sec

total 2 reads, 0.000 sec, 5.6 kb/call avg, 0.0 msec/call avg

total 7 writes, 0.000 sec, 3.9 kb/call avg, 0.0 msec/call avg

$/usr/local/coreseek/bin/search-c etc/csft.conf

##以下为正常测试搜索时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]

Copyright(c) 2007-2010,

Beijing Choice Software Technologies Inc()

using config file'etc/csft.conf'...

index'xml': query'': returned 3 matches of 3 total in 0.093 sec

displaying matches:

1. document=1, weight=1, published=Thu Apr 1 22:20:07 2010, author_id=1

2. document=2, weight=1, published=Thu Apr 1 23:25:48 2010, author_id=1

3. document=3, weight=1, published=Thu Apr 1 12:01:00 2010, author_id=2

words:

$/usr/local/coreseek/bin/search-c etc/csft.conf-a Twittter和Opera都提供了搜索服务

##以下为正常测试搜索关键词时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]

Copyright(c) 2007-2010,

Beijing Choice Software Technologies Inc()

using config file'etc/csft.conf'...

index'xml': query'Twittter和Opera都提供了搜索服务': returned 3 matches of 3 total in 0.038 sec

displaying matches:

1. document=3, weight=24, published=Thu Apr 1 12:01:00 2010, author_id=2

2. document=1, weight=4, published=Thu Apr 1 22:20:07 2010, author_id=1

3. document=2, weight=3, published=Thu Apr 1 23:25:48 2010, author_id=1

words:

1.'twittter': 1 documents, 3 hits

2.'和': 3 documents, 15 hits

3.'opera': 1 documents, 25 hits

4.'都': 2 documents, 4 hits

5.'提供': 0 documents, 0 hits

6.'了': 3 documents, 18 hits

7.'搜索': 2 documents, 5 hits

8.'服务': 1 documents, 1 hits

$/usr/local/coreseek/bin/searchd-c etc/csft.conf

##以下为正常开启搜索服务时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release(r2117)]

Copyright(c) 2007-2010,

Beijing Choice Software Technologies Inc()

using config file'etc/csft.conf'...

listening on all interfaces, port=9312

三,配置coreseek支持mysql数据源

1,配置csft_mysql.conf文件

复制mysql配置文件到coreseek安装目录etc/下(比如/usr/local/coreseek/etc/)

cp/usr/local/src/coreseek-3.2.14/testpack/etc/csft_mysql.conf/usr/local/coreseek/etc/

cd/usr/local/coreseek/etc/

vi csft_mysql.conf

下面加红部分是需要你自己配置的

官方参考文档:数据源配置:mysql数据源

其他数据源请参考官方

==============================================================

#源定义

sourcephperz

{

type= mysql

sql_host=localhost

sql_user=root

sql_pass=xxxx

sql_db=phperz

sql_port= 3306

sql_query_pre= SET NAMES utf8

sql_query=SELECT id,title,descs,status from article

#sql_query第一列id需为整数

#title、content作为字符串/文本字段,被全文索引

sql_attr_uint=status#从SQL读取到的值必须为整数

#sql_attr_timestamp= date_added#从SQL读取到的值必须为整数,作为时间属性

sql_query_info_pre= SET NAMES utf8#命令行查询时,设置正确的字符集

sql_query_info=SELECT* FROM article WHERE id=$id#命令行查询时,从数据库读取原始数据信息

}

#index定义

indexphperz

{

source=phperz#对应的source名称

path=/usr/local/coreseek/var/data/phperz#请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...

docinfo= extern

mlock= 0

morphology= none

min_word_len= 1

html_strip= 0

#中文分词配置,详情请查看:

charset_dictpath=/usr/local/mmseg3/etc/#BSD、Linux环境下设置,/符号结尾

#charset_dictpath= etc/#Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...

charset_type= zh_cn.utf-8

}

#全局index定义

indexer

{

mem_limit= 128M

}

#searchd服务定义

searchd

{

listen= 9312

read_timeout= 5

max_children= 30

max_matches= 1000

seamless_rotate= 0

preopen_indexes= 0

unlink_old= 1

pid_file=/usr/local/coreseek/var/log/searchd_mysql.pid#请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...

log=/usr/local/coreseek/var/log/searchd_mysql.log#请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...

query_log=/usr/local/coreseek/var/log/query_mysql.log#请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...

}

==============================================================

2,建立索引

路经部分需要改成你自己的地址

/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_mysql.conf--all

可能出现的错误

ERROR: index'phperz': sql_connect: Can't connect to local MySQL server through socket'/var/lib/mysql/mysql.sock'(2)(DSN=mysql://root:***@localhost:3306/phperz).

这是因为mysql的sock文件路经不正确导致的.

确认一下你的mysql.sock路经,建立一个软连接,比如

ln-s/tmp/mysql.sock/var/lib/mysql/mysql.sock

四,coreseek+php使用方式

复制安装止录下的/usr/local/src/coreseek-3.2.14/testpack/api/sphinxapi.php文件到你的项目里

你的程序里include sphinxapi.php

php使用方法见/usr/local/src/coreseek-3.2.14/testpack/api/test.php

另附我的使用方法:

===============================================================

$wd= trim($_GET['wd']);

include_once(JF_PATH./config/sph_cfg.php);

include_once(JF_PATH./include/sphinxapi.php);

$cl= new SphinxClient();

$cl-SetServer(SPH_SERVER_HOST, SPH_SERVER_POST);

$cl-SetConnectTimeout(3);

$cl-SetArrayResult(true);

$cl-SetMatchMode(1);

$cl-SetFilter(status, array(1));

$cl-SetLimits(0, 10);

$res=$cl-Query($wd, phperz_www);

if($res['matches']){

$rownum=$res['total'];

foreach($res['matches'] as$k=$v){

$re=$this-db-get_one(select* from article where id=.$v['id']);

if(!empty($re)){

$list[]=$re;

}

}

}

print_r($list);

===============================================================

五,coreseek日常维护

启动

/usr/local/coreseek/bin/searchd-c/usr/local/coreseek/etc/csft_mysql.conf

停止

/usr/local/coreseek/bin/searchd-c/usr/local/coreseek/etc/csft_mysql.conf--stop

建立索引

/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_mysql.conf--all

重建索引

/usr/local/coreseek/bin/indexer-c/usr/local/coreseek/etc/csft_mysql.conf--all--rotate

你需要把启动命令加到开机自启动里

把重建索引命令加到计划任务里每天执行

本文为phperz原创,转载请注明出处.

阅读剩余
THE END