Centos6.4 + PHP5.5.11 + Mysql5.6.16 + Tnginx2.02 + Memcached1.4.17 + Redis2.2

/**

author: 老炮

date: 2014/5/10

*/

1:准备工作

1.1 配置网卡 - 确保能上网 (dhcp方式或static方式)

1.1.1 配置ifcfg-eth0文件

[[email protected] log]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

UUID=e4b2d65f-c9c7-4f51-bfc1-3d06e9f7122e

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=dhcp

HWADDR=00:0C:29:41:92:54

IPV6INIT=yes

NAME="System eth0"

[[email protected] log]# vi /etc/sysconfig/network-scripts/ifcfg-lo

DEVICE=lo

IPADDR=127.0.0.1

NETMASK=255.0.0.0

NETWORK=127.0.0.0

# If you‘re having problems with gated making 127.0.0.0/8 a martian,

# you can change this to something else (255.255.255.255, for example)

BROADCAST=127.255.255.255

ONBOOT=yes

NAME=loopback

1.1.2 up eth0网卡

[[email protected] log]# ifconfig eth0 up

1.1.3 重启network服务

[[email protected] log]# service network restart

1.1.4 检查是否ping通过

[[email protected] ~]# ping g.cn

1.1.2 配置ifcfg-eth0文件

step1:Configure eth0 or em1

[[email protected] yum.repos.d]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

HWADDR=00:1C:42:81:B8:CA

TYPE=Ethernet

UUID=1ada7958-46f9-4b3c-8171-ca6cd4a5e9ca

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=none

IPV6INIT=no

USERCTL=no

PEERDNS=yes

IPADDR=192.168.1.141

NETMASK=255.255.255.0

step2: Configure Default Gateway

[[email protected] yum.repos.d]# vim /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=141server

GATEWAY=192.168.1.1

step3:Configure DNS Server

[[email protected] yum.repos.d]# vim /etc/resolv.conf

; generated by /sbin/dhclient-script

nameserver 8.8.8.8

nameserver 192.168.1.1

step4: Restart Network Interface

[[email protected] yum.repos.d]# service network restart

[[email protected] yum.repos.d]# ping centos.org

[[email protected] yum.repos.d]# nslookup centos.org

1.2 CentOS下为yum加入rpmForge源

http://pkgs.repoforge.org/rpmforge-release/

[[email protected] src]# wget -c http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

[[email protected] src]# rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

安装好后,到/etc/yum.repos.d目录下可以看到多了两个源文件:mirrors-rpmforge  rpmforge.repo

[[email protected] src]# cd /etc/yum.repos.d

[[email protected] yum.repos.d]# ls

CentOS-Base.repo       CentOS-Media.repo  mirrors-rpmforge         mirrors-rpmforge-testing

CentOS-Debuginfo.repo  CentOS-Vault.repo  mirrors-rpmforge-extras  rpmforge.repo

1.3 升级系统和安装相关的程序库

yum -y install yum-fastestmirror

yum -y update

yum -y install patch make gcc gcc-c++ gcc-g77 flex bison

yum -y install libtool libtool-libs kernel-devel autoconf

yum -y install libjpeg libjpeg-devel libpng libpng-devel

yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel

yum -y install glib2 glib2-devel bzip2 diff*

yum -y install bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs

yum -y install e2fsprogs-devel krb5 krb5-devel libidn libidn-devel

yum -y install openssl openssl-devel vim-minimal

yum -y install fonts-chinese scim-chewing scim-pinyin scim-tables-chinese

yum -y install libcurl-devel openldap-devel

yum -y groupinstall "Development tools"

1.4 PHP需要的库程序

[[email protected] src]# wget -c https://catlnmp.googlecode.com/files/libiconv-1.14.tar.gz

[[email protected] src]# tar xvzf libiconv-1.14.tar.gz

[[email protected] src]# cd libiconv-1.14

[[email protected] src]# ./configure --prefix=/usr/local --libdir=/usr/local/lib64

[[email protected] libiconv-1.14]# make

[[email protected] libiconv-1.14]# make install

[[email protected] src]# wget -c https://catlnmp.googlecode.com/files/libmcrypt-2.5.8.tar.gz

[[email protected] src]# tar xvzf libmcrypt-2.5.8.tar.gz

[[email protected] src]# cd libmcrypt-2.5.8

[[email protected] libmcrypt-2.5.8]# ./configure --prefix=/usr/local --libdir=/usr/local/lib64

[[email protected] libmcrypt-2.5.8]# make && make install

[[email protected] libmcrypt-2.5.8]# /sbin/ldconfig

[[email protected] libmcrypt-2.5.8]# cd libltdl/

[[email protected] libltdl]# ./configure --enable-ltdl-install --libdir=/usr/local/lib64

[[email protected] libltdl]# make && make install

[[email protected] libltdl]# cd ../../

[[email protected] src]# wget -c http://catlnmp.googlecode.com/files/mhash-0.9.9.9.tar.gz

[[email protected] src]# tar xvzf mhash-0.9.9.9.tar.gz

[[email protected] src]# cd mhash-0.9.9.9

[[email protected] mhash-0.9.9.9]# ./configure --prefix=/usr/local --libdir=/usr/local/lib64

[[email protected] mhash-0.9.9.9]# make && make install

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8

ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a

ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la

ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so

ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

[[email protected] src]# wget -c wget http://catlnmp.googlecode.com/files/mcrypt-2.6.8.tar.gz

[[email protected] src]# tar xvzf mcrypt-2.6.8.tar.gz

[[email protected] src]# cd mcrypt-2.6.8

[[email protected] mcrypt-2.6.8]# /sbin/ldconfig

[[email protected] mcrypt-2.6.8]# LD_LIBRARY_PATH=/usr/local/lib64 ./configure --prefix=/usr/local --libdir=/usr/local/lib64

[[email protected] mcrypt-2.6.8]# make && make install

2:开始安装MySQL

2.1 去除系统自带的MySQL

[[email protected] ~]# yum erase mysql-libs

2.2 安装依赖包

[[email protected] ~]# yum install cmake.x86_64

[[email protected] ~]# yum install ncurses-devel.x86_64

[[email protected] src]# tar zxvf mysql-5.6.16.tar.gz

[[email protected] src]# cd mysql-5.6.16

2.3 编译

[[email protected] mysql-5.6.16]#

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_EXTRA_CHARSETS=all

[[email protected] mysql-5.6.16]# make

[[email protected] mysql-5.6.16]# make install

2.4 配置环境

[[email protected] mysql-5.6.16]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

[[email protected] mysql-5.6.16]# vim /etc/my.cnf

[mysqld]

basedir = /usr/local/mysql

datadir = /usr/local/mysql/data

port = 3306

server_id = 1

socket = /tmp/mysql.sock

explicit_defaults_for_timestamp=true

2.5 添加用户并安装DB

[[email protected] mysql-5.6.16]# groupadd mysql

[[email protected] mysql-5.6.16]# useradd -r -g mysql mysql

[[email protected] ~]# cd /usr/local/

[[email protected] local]# chown -R mysql:mysql mysql

[[email protected] local]# cd mysql/

[[email protected] local]#

scripts/mysql_install_db \

--user=mysql \

--datadir=/usr/local/mysql/data \

--basedir=/usr/local/mysql

2.6 生成MySQL启动脚本并运行,以及mysql做软连接到环境变量

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[[email protected] mysql]# chmod 755 /etc/init.d/mysqld

[[email protected] mysql]# /etc/init.d/mysqld start

[[email protected] mysql]# echo $PATH

/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[[email protected] mysql]# cd /usr/bin

[[email protected] bin]# ll | grep mysql

[[email protected] bin]# ln -s /usr/local/mysql/bin/mysql ./

[[email protected] bin]# ll | grep mysql

lrwxrwxrwx. 1 root root         26 5月  27 20:26 mysql -> /usr/local/mysql/bin/mysql

2.7 设置root密码以及其他安全相关设置

[[email protected] mysql]# /usr/local/mysql/bin/mysql_secure_installation

root:root

2.8 设置系统启动自行启动MySQL

[[email protected] mysql]# chkconfig --add mysqld

[[email protected] mysql]# chkconfig mysqld on

[[email protected] ~]# chkconfig --list | grep mysql

2.9 开始触碰MySQL

[[email protected] init.d]# /usr/local/mysql/bin/mysql -uroot -p

Enter password: ****

mysql> status

--------------

/usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.6.16, for Linux (x86_64) using  EditLine wrapper

Connection id: 12

Current database:

Current user: [email protected]

SSL: Not in use

Current pager: stdout

Using outfile: ‘‘

Using delimiter: ;

Server version: 5.6.16 Source distribution

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: utf8

Db     characterset: utf8

Client characterset: utf8

Conn.  characterset: utf8

UNIX socket: /tmp/mysql.sock

Uptime: 9 min 6 sec

Threads: 1  Questions: 35  Slow queries: 0  Opens: 70  Flush tables: 1  Open tables: 63  Queries per second avg: 0.064

--------------

mysql> exit;

[[email protected] init.d]#

3:开始安装PHP

3.1 解压等基本操作

[[email protected] src]# tar xvzf php-5.5.11.tar.gz

[[email protected] src]# cd php-5.5.11

3.2 mysql/lib做软连接,识别成64位

[[email protected] php-5.5.11]# ln -s /usr/local/mysql/lib /usr/local/mysql/lib64

3.3 编译开始

[[email protected] php-5.5.11]#

./configure --prefix=/usr/local/php \

--with-libdir=lib64 \

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

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-pear=/usr/share/php \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--enable-maintainer-zts \

--enable-opcache \

--with-curl \

--with-iconv-dir=/usr/local/lib64 \

--enable-fpm \

--enable-mbstring \

--with-mcrypt \

--with-gd \

--enable-gd-native-ttf \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-zip \

--enable-soap \

--with-bz2 \

--enable-static \

--enable-exif \

--with-pdo-mysql=/usr/local/mysql

3.3.1 error出现解决方法

错误1 : configure: error: Don’t know how to define struct flock on this system, set –enable-opcache=no

解决方法1

[[email protected] lib]# vim /etc/ld.so.conf.d/local.conf

[[email protected] lib]# cat /etc/ld.so.conf.d/local.conf

/usr/local/lib64

[[email protected] lib]# ldconfig -v

解决方法2

[[email protected] lib]# yum groupinstall "Development tools"

解决方法3

ln -s /usr/local/mysql/lib64/libmysqlclient.so /usr/lib/

ln -s /usr/local/mysql/lib64/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

3.4 make

[[email protected] php-5.5.11]# make

3.4.1 error出现解决方法

错误1 :/usr/local/src/php-5.5.11/ext/xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open‘

/usr/local/src/php-5.5.11/ext/xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv‘

/usr/local/src/php-5.5.11/ext/xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close‘

collect2: ld returned 1 exit status

make: *** [sapi/cli/php] 错误 1

解决方法1:

[[email protected] php-5.5.11]# make clean

[[email protected] php-5.5.11]# vim Makefile

/EXTRA_LIBS

EXTRA_LIBS = ..... -lcrypt -liconv

:wq

解决方法2:

#make ZEND_EXTRA_LIBS=‘-liconv‘

3.5 make install

[[email protected] php-5.5.11]# make install

3.6 拷贝php.ini及修改文件

[[email protected] php-5.5.11]# cp -f php.ini-production /usr/local/php/etc/php.ini

[[email protected] php-5.5.11]# cp /usr/local/php/etc/php.ini /usr/local/php/etc/php.ini.bak

[[email protected] php-5.5.11]# vim /usr/local/php/etc/php.ini

202: short_open_tag = Off (看老代码风格开启或关闭)

452行: error_reporting = E_ALL & ~E_STRICT

470行: display_errors = On

720行: extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20121212/"

917: date.timezone = PRC

最后一行: [opcache]

zend_extension=opcache.so

3.7 php-fpm测试及开始启动

[[email protected] php-5.5.11]# cd /usr/local/php/etc

[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf

[[email protected] etc]# vim php-fpm.conf

33 error_log = /var/log/php/php-fpm.log

[[email protected] etc]# /usr/local/php/sbin/php-fpm -t

[[email protected] etc]# /usr/local/php/sbin/php-fpm

3.8 php-fpm软重启

[[email protected] etc]# killall -USR2 /usr/local/php/sbin/php-fpm

3.9 执行文件放到环境变量,做软连接

[[email protected] bin]# cd /usr/bin

[[email protected] bin]# ln -s /usr/local/php/bin/php ./

[[email protected] bin]# ln -s /usr/local/php/bin/php-config ./

[[email protected] bin]# ln -s /usr/local/php/bin/phpize ./

[[email protected] bin]# ln /usr/local/php/sbin/php-fpm ./

lrwxrwxrwx.   1 root root          22 5月  28 13:03 php -> /usr/local/php/bin/php

lrwxrwxrwx.   1 root root          29 5月  28 13:04 php-config -> /usr/local/php/bin/php-config

-rwxr-xr-x.   2 root root    32835686 5月  28 00:30 php-fpm

lrwxrwxrwx.   1 root root          25 5月  28 13:05 phpize -> /usr/local/php/bin/phpize

3.10 自动启动PHP服务

[[email protected] fpm]# pwd

/usr/local/src/php-5.5.11/sapi/fpm

[[email protected] fpm]# cat init.d.php-fpm.in | less

[[email protected] fpm]# cp init.d.php-fpm.in /etc/init.d/php-fpm

[[email protected] fpm]# vim /etc/init.d/php-fpm

prefix=/usr/local/php

exec_prefix=${prefix}

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

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

php_fpm_PID=/var/run/php-fpm.pid

[[email protected] init.d]# vim /usr/local/php/etc/php-fpm.conf

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

[[email protected] fpm]# chmod 755 /etc/init.d/php-fpm

[[email protected] fpm]# /etc/init.d/php-fpm stop

[[email protected] fpm]# /etc/init.d/php-fpm start

[[email protected] fpm]# chkconfig --add php-fpm

[[email protected] fpm]# chkconfig php-fpm on

[[email protected] fpm]# service php-fpm restart

4:开始安装TNginx

4.1 指定web目录

[[email protected] src]# groupadd www

[[email protected] src]# useradd -g www www

[[email protected] src]# mkdir -p /www/141.com/

[[email protected] src]# chmod +w /www/141.com/

[[email protected] src]# chown -R www:www /www/141.com/

4.2 安装PCRE

[[email protected] src]# rpm -qa |grep pcre

pcre-7.8-6.el6.x86_64

[[email protected] src]# cp /lib64/libpcre.so.0 /

[[email protected] src]# rpm -e --nodeps pcre-7.8-6.el6.x86_64

[[email protected] src]# cp /libpcre.so.0 /lib64/

[[email protected] src]# wget -c http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.bz2

[[email protected] src]# tar jxvf pcre-8.35.tar.bz2

[[email protected] src]# cd pcre-8.35

[[email protected] pcre-8.35]# ./configure --prefix=/usr/local --libdir=/usr/local/lib64

[[email protected] pcre-8.35]# make && make install

[[email protected] pcre-8.35]# ln -s /usr/local/lib64/libpcre.so.1 /lib64/

4.3 安装TNginx

4.3.1 解压

[[email protected] src]# tar zxvf tengine-2.0.1.tar.gz

[[email protected] src]# cd tengine-2.0.1

4.3.2 编译及安装

[[email protected] tengine-2.0.1]# ./configure --user=www --group=www --prefix=/usr/local/nginx

[[email protected] tengine-2.0.1]# make && make install

4.3.3 配置nginx文件

[[email protected] tengine-2.0.1]# cd /usr/local/nginx/conf/

[[email protected] conf]# vim nginx.conf

user  www www;

worker_processes  4;

error_log  /var/log/nginx/error.log;

pid        /var/log/nginx/nginx.pid;

gzip  on;

include vhosts/*;

4.3.4 编辑vhost下的conf文件

[[email protected] conf]# mkdir vhosts

[[email protected] conf]# cd vhosts

[[email protected] vhosts]# vim www.141.com.conf

server {

listen       80;

server_name www.141.com;

root    /www/141.com/www/app/;

index  index.php index.html index.htm;

access_log /var/log/nginx/www.141.com/access.log;

error_page  404              /index.php;

error_page   500 502 503 504  /50x.html;

charset utf-8;

location ~* ^.+.(jpg|jpeg|gif|css|png|js|html|htm)$ {

expires           1d;

break;

}

location ~* ^/(images|javascript|js|css|flash|media|static)/ {

expires 1d;

}

location / {

if (!-e $request_filename){

rewrite ^/(.*) /index.php last;

}

}

location ~* ^.+.(php|php5)$ {

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  /www/141.com/www/app/$fastcgi_script_name;

include        fastcgi_params;

}

}

4.3.5 开启nginx

[[email protected] app]# /usr/local/nginx/sbin/nginx

4.3.6 做nginx软连接

[[email protected] nginx]# cd /usr/bin/

[[email protected] bin]# ln -s /usr/local/nginx/sbin/nginx ./

4.3.7 检查是否Nginx+MySQL+PHP联动成功

[[email protected] vhosts]# cd /www/141.com/www/app/

[[email protected] app]# echo "<?php phpinfo()" > index.php

[[email protected] app]# curl localhost

4.3.8 浏览上测试联动

客户端机器绑定域名 :192.168.1.141 www.141.com

浏览器无法访问解决方案1

修改服务器防火墙配置-开放80和3306

[[email protected] app]# /etc/init.d/iptables status

[[email protected] app]# vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

[[email protected] app]# service iptables restart

4.3.9 自动启动Nginx服务

[[email protected] tmp]# vim nginx

参考lnmp_source_files

[[email protected] tmp]# cp nginx /etc/init.d/nginx

[[email protected] tmp]# chmod 755 /etc/init.d/nginx

[[email protected] tmp]# chkconfig --add nginx

[[email protected] tmp]# chkconfig nginx on

[[email protected] tmp]# service nginx stop

[[email protected] tmp]# service nginx start

5:开始安装Memcached

5.1 安装Memcached Server端

5.1.1 先安装libevent,Memcached需要libevent库的支持

[[email protected] src]# wget -c https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

[[email protected] src]# tar vxzf libevent-2.0.21-stable.tar.gz

[[email protected] src]# cd libevent-2.0.21-stable

[[email protected] libevent-2.0.21-stable]# ./configure --prefix=/usr/local --libdir=/usr/local/lib64

[[email protected] libevent-2.0.21-stable]# make

[[email protected] libevent-2.0.21-stable]# make install

5.1.2 Memcached Server端

[[email protected] src]# tar vxzf memcached-1.4.17.tar.gz

[[email protected] src]# cd memcached-1.4.17

[[email protected] memcached-1.4.17]# ./configure --prefix=/usr/local/memcached --libdir=/usr/local/lib64

[[email protected] memcached-1.4.17]# make && make install

[[email protected] memcached-1.4.17]# /usr/local/memcached/bin/memcached -d -p 11211 -u root -l 127.0.0.1 -m 64 -c 1024 -P /var/run/memcached.pid

停止memcached:kill -9 pid

5.1.2.1 error出现解决方法

[[email protected] memcached-1.4.17]# find / -name libevent-2.0.so.5

[[email protected] memcached-1.4.17]# LD_DEBUG=libs   memcached -v

[[email protected] memcached-1.4.17]# ln -s /usr/local/lib64/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

5.2 安装Memcached Client端

5.2.1 安装libmemcached,客户端基于libmemcached,需要libmemcached的支持

[[email protected] src]# tar zxvf libmemcached-1.0.18.tar.gz

[[email protected] src]# cd libmemcached-1.0.18

[[email protected] libmemcached-1.0.18]# ./configure --prefix=/usr/local/libmemcached/ --with-libmemcached-dir=/usr/local/libmemcached/

[[email protected] libmemcached-1.0.18]# make && make install

5.2.2 PHP Memcached客户端

[[email protected] src]# tar zxvf memcached-php-ext-2.2.0.tgz

[[email protected] src]# cd memcached-2.2.0/

[[email protected] memcached-2.2.0]# yum install libmemcache-devel

[[email protected] memcached-2.2.0]# yum install php-devel

[[email protected] memcached-2.2.0]# phpize

[[email protected] memcached-2.2.0]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/

[[email protected] memcached-2.2.0]# make && make install

[[email protected] memcached-2.2.0]# vim /usr/local/php/etc/php.ini

最后行增加

[memcached]

extension = memcached.so

[[email protected] memcached-2.2.0]# killall -USR2 php-fpm

[[email protected] memcached-2.2.0]# nginx -s reload

5.3 测试Memcached

测试方法1

[[email protected] src]# ps aux | grep memcached

root      1987  0.0  0.1 331120  1220 ?        Ssl  08:36   0:00 /usr/local/memcached/bin/memcached -d -p 11211 -u root -l 127.0.0.1 -m 64 -c 1024 -P /var/run/memcached.pid

root      2076  0.0  0.0 103248   880 pts/3    S+   08:40   0:00 grep memcached

测试方法2 如果不能连接"允许防火墙访问11211端口"

~  telnet 192.168.1.141 11211

stats

quit

检测方法2

[[email protected] run]# /usr/local/memcached/bin/memcached -u root -vv

5.4 自动启动Memcached服务

[[email protected] scripts]# pwd

/usr/local/src/memcached-1.4.17/scripts

[[email protected] scripts]# cat memcached.sysv

[[email protected] scripts]# cp memcached.sysv /etc/init.d/memcached

[[email protected] scripts]# chmod 755 /etc/init.d/memcached

[[email protected] scripts]# vim /etc/init.d/memcached

[[email protected] scripts]# chkconfig --add memcached

[[email protected] scripts]# chkconfig memcached on

[[email protected] scripts]# service memcached start

6: 开始安装Redis

6.1 编译安装redis

[[email protected] src]# tar xvzf redis-2.8.8.tar.gz

[[email protected] src]# cd redis-2.8.8

[[email protected] redis-2.8.8]# make

[[email protected] redis-2.8.8]# make test

6.1.1 出现tcl error

make[1]: Entering directory `/usr/local/src/redis-2.8.8/src‘

You need tcl 8.5 or newer in order to run the Redis test

make[1]: *** [test] 错误 1

make[1]: Leaving directory `/usr/local/src/redis-2.8.8/src‘

make: *** [test] 错误 2

[[email protected] ~]# yum install tcl

[[email protected] redis-2.8.8]# make test

[[email protected] redis-2.8.8]# make PREFIX=/usr/local install

6.2 配置 Redis

[[email protected] redis-2.8.8]# mkdir /etc/redis

[[email protected] redis-2.8.8]# cp redis.conf /etc/redis/redis.conf

daemonize yes

pidfile /var/run/redis.pid

timeout 300

dir /var/lib/redis/

slowlog-max-len 1024

[[email protected] redis-2.8.8]# mkdir /var/lib/redis

6.3 调整系统内核参数

如果内存情况比较紧张的话,需要设定内核参数:

[[email protected] /]# echo 1 > /proc/sys/vm/overcommit_memory

6.4 运行 Redis

[[email protected] /]# redis-server /etc/redis/redis.conf

[[email protected] /]# redis-cli

127.0.0.1:6379> set foo bar

OK

127.0.0.1:6379> get foo

"bar"

127.0.0.1:6379> quit

[[email protected] /]# redis-benchmark (执行redis-benchmark命令时也会将内存数据写入硬盘。)

6.5 关闭redis服务

[[email protected] /]# redis-cli shutdown

如果端口变化可以指定端口:

[[email protected] /]# redis-cli -p 6380 shutdown

6.6 保存/备份

[[email protected] run]# redis-cli save

OK

[[email protected] run]# redis-cli -p 6379 save

OK

6.7 自动启动Redis服务

[[email protected] /]# which redis-server

/usr/local/bin/redis-server

[[email protected] tmp]# vim redis-server

参考lnmp_source_files

[[email protected] tmp]# cp redis-server /etc/init.d/redis

[[email protected] tmp]# chmod 755 /etc/init.d/redis

[[email protected] tmp]# chkconfig --add redis

[[email protected] tmp]# chkconfig --level 345 redis on

[[email protected] tmp]# service redis stop

[[email protected] tmp]# service redis start

6.8 PHP Redis客户端

[[email protected] src]# tar zxvf redis-php-ext-2.2.5.tgz

[[email protected] src]# cd redis-2.2.5/

[[email protected] redis-2.2.5]# ./configure --with-php-config=/usr/local/php/bin/php-config

[[email protected] redis-2.2.5]# make && make install

[[email protected] redis-2.2.5]# vim /usr/local/php/etc/php.ini

最后行增加

[redis]

extension = redis.so

时间: 2024-08-06 17:36:51

Centos6.4 + PHP5.5.11 + Mysql5.6.16 + Tnginx2.02 + Memcached1.4.17 + Redis2.2的相关文章

nginx1.4.6+php5.5.11+mysql5.6.17+mecache+opcache

要用到的软件:libiconv-1.13.tar.gz libmcrypt-2.5.8.tar.gz mcrypt-2.6.8.tar.gz mhash-0.9.9.9.tar.gz memcache-2.2.5.tgz PDO_MYSQL-1.0.2.tgz imagick-3.1.2.tgz pcre-8.21.tar.gz mysql-5.6.17.tar.gz ImageMagick.tar.gz php-5.4.21.tar.gz nginx-1.4.6.tar.gz 系统安装需求:c

CentOS6.5编译安装Nginx1.70 +PHP5.59+MySQL5.6.16

下载软件工具包: 1.下载nginx http://nginx.org/download/nginx-1.7.0.tar.gz 2.下载pcre (支持nginx伪静态) http://jaist.dl.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz 4.下载MySQL5.6.16 http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.16.tar.gz 5.下载php-5.5.9 ht

CentOS6.9编译安装MySQL5.7.16

部署环境: 系统CentOS6.9,mysql5.7.16,boost库 系统为2G内存 1.安装依赖包,使用yum安装cmake,6.9默认yum源自带 yum -y install gcc-c++ cmake bison-devel ncurses-devel 2.创建mysql的用户: useradd  -U -s /sbin/nologin mysql 3.创建必要的文件夹,并修改其目录用户所有者: mkdir -pv /usr/local/mysql/etc mkdir -pv /da

CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境

准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2.安装iptables防火墙 yum install iptables-services #安装 vi /etc/sysconfig/iptables #编辑

CentOS6.8编译安装Nginx1.10.2+MySQL5.7.16+PHP7.0.12

1.    下载 #MySQL下载地址 http://dev.mysql.com/downloads/mysql/ #Nginx下载地址 http://nginx.org/en/download.html #PHP下载地址 http://php.net/downloads.php 使用WinSCP把下载好的压缩包上传到/usr/local/src目录 mysql-5.7.16.tar.gz nginx-1.10.2.tar.gz php-7.0.12.tar.gz 2.    安装 2.1   

Centos6.7安装Apache2.4+Mysql5.5+Apache2.4

首先说下思路,因为一开始系统上已经跑了一套完成的 PHP 环境,那时候都是快速自动安装的,如果是跑一些5.3以下版本的话,很简单,几个指令,10分钟搞定了. 但现在要升级,彻底一点的话,唯有推倒重来了.所以步骤有: 1. 卸载掉当前的 Apache.php.mysql: 2. 清除残留的一些配置文件: 3. 一步步安装 Apache .mysql.php,当然在过程当中需要注意每个软件的依赖控件不可少. 下面是整体的步骤,从卸载后开始(同理适合刚刚安装好的全新系统): 1. 准备工作 ,工欲善其

使用mysql5.7.16头文件库文件编译安装atlas

最近mysql数据库升级到5.7.16,而中间件atlas之前是基于mysql5.6编译的,打算重新编译下atlas并使用mysql5.7.16的库文件头文件.这里主要介绍下编译过程遇到问题及解决方法. 由于需要glib版本要大于2.32以上,centos6.6系统自带的glib版本为2.28,因此需要重新编译安装2.32以上的glib,这里安装2.34版本的glib需要依赖pcre大于8.31 一.编译安装pcre8.35 # ./configure --prefix=/usr/local/g

mysql5.7下载与安装,php5.6与mysql5.7整合

Part1 mysql5.7下载 百度“mysql下载”,打开官网    2. 在页面右上角点击,注册/登录 3. 登录后显示下载页面,选择windows 4. 然后选择MySQL Installer 5. 选择你需要的版本,点击download 6. 第一次注册的用户可能会出现这个,填完提交就可以 7. 提交之后出现下载页面,下载即可 我的下载结果是这样的 Part2 mysql5.7安装 声明:因为这是第二次安装,跟第一次有一丢丢不同 双击下载好的msi文件 2. 选择custom自定义安装

centos7编译php-5.6.11

[安装依赖] yum -y install epel-releaseyum groupinstall "development tools"yum -y install mhash mhash-devel mcryptyum -y install zlib zlib-devel libjpeg libjpeg-devel freetype freetype-devel gd gd-devel curl curl-devel libxml2 libxml2-devel libxslt l