您的位置:首页 > 数据库 > Memcache

centos7 安装apache+php+memcache

2017-07-11 11:06 267 查看
安装apache
yum install pcre-devel apr apr-devel apr-util apr-util-devel gcc-c++ libxml2-devel libxml2 perl perl-devel

./configure \
--prefix=/usr/local/apache/ \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--enable-static-support

安装php
yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel

./configure \
--prefix=/usr/local/php7/ \
--with-apxs2=/usr/local/apache/bin/apxs \
--enable-mbstring \
--with-curl \
--with-gd \
--enable-fpm \
--enable-mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-config-file-path=/usr/local/php/etc/ \
--with-mysqli=mysqlnd

cp php.ini-development /usr/local/php/etc/php.ini

报错:
Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

解决步骤:
1、根据不能run apxs 。cd 到apache的bin目录下运行./apxs 运行结果
----------------------------------------------------
bash: ./apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory
---------------------------------------------------------
2、vim apxs文件 找“/replace/with/path/to/perl/interpreter”关键字
在第一个行 :#!/replace/with/path/to/perl/interpreter -w
根据perl的安装目录 /usr/bin/perl
修改为:#! /usr/bin/perl -w
3、运行第一步。或者直接 ./configure ^^^^^

安装memecach
第一步:安装libevent
# tar zvxf libevent-2.1.8-stable.tar.gz
# cd libevent-2.1.8-stable
# ./configure --prefix=/usr/local/libevent
# make
# make install
# cd /usr/lib64
# ln -s /usr/local/libevent/lib/libevent-2.1.so.6

第二步:安装memecached
# tar zxvf memcached-1.4.35.tar.gz
# cd memcached-1.4.35
# ./configure --prefix=/usr/local/memcached
# make
# make install

第三步:启动
# cd /usr/local/memcached/bin
# ./memcached -d -u root

第四部:测试
1.查看进程
# ps -ef|grep memcached |grep -v grep

2.查看端口
# lsof -i:11211

3.telnet测试
# telnet 192.168.6.128 11211

输入:stats
返回:

至此memecached安装成功。

配置PHP的memecached扩展
php的memcached扩展是基于libmemcached,所以要先安装libmemcached
安装libmemcached
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
./configure --prefix=/usr/lib/libmemcached
make && make install

安装php-memcached-php7
./configure --enable-memcached --with-php-config=/usr/local/php7/bin/php-config --with-libmemcached-dir=/usr/lib/libmemcached/ --disable-memcached-sasl
make && make install

重启apache
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: