安装memcached+nginx+php+memadmin笔记
首先准备软件包:libevent-2.0.21-stable.tar.gz
libmcrypt-2.5.7.tar.gz
memadmin-1.0.12.tar.gz
memcache-2.2.7.tgz
memcached-1.4.15.tar.gz
nginx-1.2.7.tar.gz
php-5.4.11.tar.gz
下载链接
http://down.运维网.com/data/730444
参考
wget http://nginx.org/download/nginx-1.2.7.tar.gz
wget http://cn2.php.net/get/php-5.4.11.tar.gz/from/this/mirror
wget http://pecl.php.net/get/memcache-2.2.7.tgz
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
wget --no-check-certificate https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
wget http://www.junopen.com/memadmin/memadmin-1.0.12.tar.gz
wget http://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/Production/libmcrypt-2.5.7.tar.gz
1、安装gcc
# yum install gcc gcc-c++ autoconf automake
2、安装nginx
# yum -y install pcre-devel zlib-devel openssl openssl-devel
# tar -zxvf nginx-1.2.7.tar.gz
# cd nginx-1.2.7
# ./configure --prefix=/usr/local/nginx
# make
# make install
# vim /etc/init.d/nginx
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: 345 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /opt/nginx/conf/nginx.conf
# pidfile: /opt/nginx/nginx.pid
# Source function library.
. /etc/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
if [ -f /etc/sysconfig/nginx ];then
. /etc/sysconfig/nginx
fi
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx #-c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t #-c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
test)
configtest
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|test}"
exit 2
esac
# chmod 755 /etc/init.d/nginx
# chkconfig --add nginx
# chkconfig nginx on
# service nginx start
测试:http://192.168.137.35/
# service nginx stop
3、安装PHP
# yum install libxml2-devel bzip2-devel curl-devel
# tar -zxvf libmcrypt-2.5.7.tar.gz
# ./configure
# make
# make install
# cd Package/
# tar -zxvf php-5.4.11.tar.gz
# cd php-5.4.11
# ./configure --prefix=/usr/local/php --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug --enable-pic --disable-rpath --enable-inline-optimization --with-bz2 --with-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex --with-mysql
# 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
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
# chmod 755 /etc/rc.d/init.d/php-fpm
# chkconfig --add php-fpm
# chkconfig php-fpm on
4、整合nginx和php-fpm
# mkdir /web
# cd /web
# mkdir htdocs
# vim /usr/local/nginx/conf/nginx.conf
修改server区段
...
location / {
root /web/htdocs;
index index.php index.html index.htm;
}
...
location ~ \.php$ {
root /web/htdocs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /web/htdocs/$fastcgi_script_name;
include fastcgi_params;
}
测试
# vim /web/htdocs/index.php
# service nginx start
# service php-fpm start
http://192.168.137.35/
# service nginx stop
# service php-fpm stop
5、安装PHP memcach
# cd Package/
# tar -zxf memcache-2.2.7.tgz
# cd memcache-2.2.7
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache
# make
# make install
出现如下提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
在# vim /usr/local/php/lib/php.ini大约868行左右添加如下一行来载入memcache扩展
6、安装memcached
# tar -xf libevent-2.0.21-stable.tar.gz
# cd libevent-2.0.21-stable
# ./configure --prefix=/usr/local/libevent-2.0.21
# make
# make install
# cd Package/
# tar -zxf memcached-1.4.15.tar.gz
# cd memcached-1.4.15
# ./configure --prefix=/usr/local/memcached-1.4.15 --with-libevent=/usr/local/libevent-2.0.21
# make
# make install
为memcached建立启动脚本
# vim /etc/init.d/memcached
#!/bin/bash
#
# Init file for memcached
#
# chkconfig: 345 60 60
# description: The memcached daemon is a network memory cache service.
#
# processname: memcached
# config: /etc/sysconfig/memcached
. /etc/rc.d/init.d/functions
[ -f /etc/sysconfig/memcached ] && . /etc/sysconfig/memcached #将memcached的参数定义设置为独立配置文件
## Default variables
PORT=${PORT:-11211}
USER=${USER:-nobody}
MAXCONN=${MAXCONN:-1024}
CACHESIZE=${CACHESIZE:-64}
OPTIONS=${OPTIONS:-""}
RETVAL=0
prog="/usr/local/memcached-1.4.15/bin/memcached"
desc="network memory cache service"
lockfile="/var/lock/subsys/memcached"
start() {
echo -n $"Starting $desc (memcached): "
daemon $prog -d -p $PORT -u $USER -c $MAXCONN -m $CACHESIZE $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL
}
stop() {
echo -n $"Shutting down $desc (memcached): "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $lockfile
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $desc ($prog): "
killproc $prog -HUP
RETVAL=$?
echo
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
[ -e $lockfile ] && restart
RETVAL=$?
;;
reload)
reload
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac
exit $RETVAL
建立memcached参数配置文件:
# echo -e 'PORT="11211" \nUSER="root" \nMAXCONN="1024" \nCACHESIZE="64" \nOPTIONS="" ' > /etc/sysconfig/memcached
添加执行权限,加入到系统服务:
# chmod 755 /etc/init.d/memcached
# chkconfig --add memcached
# chkconfig memcached on
安装memadmin可视化管理界面:
# tar -zxf memadmin-1.0.12.tar.gz
# cd memadmin
# mkdir /web/htdocs/memadmin
# mv * /web/htdocs/memadmin/
测试
# service memcached start
# service php-fpm start
# service nginx start
http://192.168.137.35/memadmin
用户名:admin
密码:admin
参考链接:
http://tangs90.net/linux-nginx-memcache/
http://www.linuxidc.com/Linux/2012-11/73997p8.htm
http://blog.csdn.net/chaijunkun/article/details/7000600
http://blog.csdn.net/chaijunkun/article/details/6993264
http://www.cnblogs.com/wubaiqing/archive/2011/09/19/2181602.html
http://tech.idv2.com/2008/07/10/memcached-001/
http://blog.csdn.net/ajun_studio/article/details/6745791
http://blog.csdn.net/ajun_studio/article/details/6746877
http://tec110505.diandian.com/post/2012-12-26/40047899151
http://www.51testing.com/?uid-116228-action-spacelist-type-blog-itemtypeid-10023
http://www.networkquestions.org/archives/1662
http://www.sunchis.com/html/db/memcached/2011/0526/333.html
http://junier.iteye.com/blog/1816461
http://junier.iteye.com/blog/1816470
http://junier.iteye.com/blog/1816474
http://junier.iteye.com/blog/1817838
http://junier.iteye.com/blog/1817843
——————————————————————————————————————————————————
第一次做没有成功的笔记
2、安装libevent
# ./configure --prefix=/usr/local/libevent
# make && make install
3、安装memcached
# tar -zxvf memcached-1.4.13.tar.gz
# cd memcached-1.4.13
# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
# make && make install
4、安装apache
# ./configure --prefix=/usr/local/apache --enable-so --enable-dav --enable-dav-fs --enable-maintainer-mode --enable-rewrite=shared
页:
[1]