首先准备软件包:
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
下载链接
参考
1、安装gcc
[root@radius ~]# yum install gcc gcc-c++ autoconf automake
2、安装nginx
[root@radius nginx-1.2.7]# yum -y install pcre-devel zlib-devel openssl openssl-devel
[root@radius Package]# tar -zxvf nginx-1.2.7.tar.gz
[root@radius Package]# cd nginx-1.2.7
[root@radius nginx-1.2.7]# ./configure --prefix=/usr/local/nginx
[root@radius nginx-1.2.7]# make
[root@radius nginx-1.2.7]# make install
[root@radius ~]# 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
[root@radius ~]# chmod 755 /etc/init.d/nginx
[root@radius ~]# chkconfig --add nginx
[root@radius ~]# chkconfig nginx on
[root@radius ~]# service nginx start
[root@radius ~]# service nginx stop
3、安装PHP
[root@radius ~]# yum install libxml2-devel bzip2-devel curl-devel
[root@radius Package]# tar -zxvf libmcrypt-2.5.7.tar.gz
[root@radius libmcrypt-2.5.7]# ./configure
[root@radius libmcrypt-2.5.7]# make
[root@radius libmcrypt-2.5.7]# make install
[root@radius ~]# cd Package/
[root@radius Package]# tar -zxvf php-5.4.11.tar.gz
[root@radius Package]# cd php-5.4.11
[root@radius 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
[root@radius php-5.4.11]# make
[root@radius php-5.4.11]# make install
[root@radius php-5.4.11]# cp php.ini-production /usr/local/php/lib/php.ini
[root@radius php-5.4.11]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@radius php-5.4.11]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@radius php-5.4.11]# chmod 755 /etc/rc.d/init.d/php-fpm
[root@radius php-5.4.11]# chkconfig --add php-fpm
[root@radius php-5.4.11]# chkconfig php-fpm on
4、整合nginx和php-fpm
[root@radius ~]# mkdir /web
[root@radius ~]# cd /web
[root@radius web]# mkdir htdocs
[root@radius ~]# 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;
}
测试
[root@radius ~]# vim /web/htdocs/index.php
phpinfo();
?>
[root@radius ~]# service nginx start
[root@radius ~]# service php-fpm start
[root@radius ~]# service nginx stop
[root@radius ~]# service php-fpm stop
5、安装PHP memcach
[root@radius ~]# cd Package/
[root@radius Package]# tar -zxf memcache-2.2.7.tgz
[root@radius Package]# cd memcache-2.2.7
[root@radius memcache-2.2.7]# /usr/local/php/bin/phpize
[root@radius memcache-2.2.7]# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache
[root@radius memcache-2.2.7]# make
[root@radius memcache-2.2.7]# make install
出现如下提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
在[root@radius ~]# vim /usr/local/php/lib/php.ini大约868行左右添加如下一行来载入memcache扩展
6、安装memcached
[root@radius Package]# tar -xf libevent-2.0.21-stable.tar.gz
[root@radius Package]# cd libevent-2.0.21-stable
[root@radius libevent-2.0.21-stable]# ./configure --prefix=/usr/local/libevent-2.0.21
[root@radius libevent-2.0.21-stable]# make
[root@radius libevent-2.0.21-stable]# make install
[root@radius ~]# cd Package/
[root@radius Package]# tar -zxf memcached-1.4.15.tar.gz
[root@radius Package]# cd memcached-1.4.15
[root@radius memcached-1.4.15]# ./configure --prefix=/usr/local/memcached-1.4.15 --with-libevent=/usr/local/libevent-2.0.21
[root@radius memcached-1.4.15]# make
[root@radius memcached-1.4.15]# make install
为memcached建立启动脚本
[root@radius ~]# 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参数配置文件:
[root@radius ~]# echo -e 'PORT="11211" \nUSER="root" \nMAXCONN="1024" \nCACHESIZE="64" \nOPTIONS="" ' > /etc/sysconfig/memcached
添加执行权限,加入到系统服务:
[root@radius ~]# chmod 755 /etc/init.d/memcached
[root@radius ~]# chkconfig --add memcached
[root@radius ~]# chkconfig memcached on
安装memadmin可视化管理界面:
[root@radius Package]# tar -zxf memadmin-1.0.12.tar.gz
[root@radius Package]# cd memadmin
[root@radius memadmin]# mkdir /web/htdocs/memadmin
[root@radius memadmin]# mv * /web/htdocs/memadmin/
测试
[root@radius memadmin]# service memcached start
[root@radius memadmin]# service php-fpm start
[root@radius memadmin]# service nginx start
用户名:admin
密码:admin
参考链接:
——————————————————————————————————————————————————
第一次做没有成功的笔记
2、安装libevent
[root@radius libevent-2.0.19-stable]# ./configure --prefix=/usr/local/libevent
[root@radius libevent-2.0.19-stable]# make && make install
3、安装memcached
[root@radius ~]# tar -zxvf memcached-1.4.13.tar.gz
[root@radius ~]# cd memcached-1.4.13
[root@radius memcached-1.4.13]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
[root@radius memcached-1.4.13]# make && make install
4、安装apache
[root@radius httpd-2.2.15]# ./configure --prefix=/usr/local/apache --enable-so --enable-dav --enable-dav-fs --enable-maintainer-mode --enable-rewrite=shared