os version:centos 6.5 x86_64
nginx version:1.6
mysql version:5.5.38
php version:5.4.31
memcached version:1.4.20
前文已经介绍过,这里不再阐述
下载免安装版的mysql,格式为 MYSQL-VERSION-OS.tar.gz
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.38-linux2.6-x86_64.tar.gz
tar xf mysql-5.5.38-linux2.6-x86_64.tar.gz -C /usr/local/
安装依赖,建立用户和仓库文件
yum install gcc gcc-c++ cmake ncurses-devel openssl-devel bison-devel libaio -y
useradd -r mysql
groupadd -r mysql
mkdir -p /mydata/data/
chown -R mysql.mysql /mydata/data/
初始化库,拷贝配置文件
cd /usr/local/
ln -s mysql-5.5.38-linux2.6-x86_64/ mysql
cd mysql
chown -R root.mysql ./*
./scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
/bin/cp support-files/my-large.cnf /etc/my.cnf
vim /etc/my.cnf
在[mysql]中加入
datadir = /mydata/data
innodb_file_per_table = 1
拷贝启动文件
/bin/cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start
chkconfig --level 35 mysqld on
官方站点:http://cn2.php.net/downloads.php
下载源码包
wget http://cn2.php.net/get/php-5.4.31.tar.bz2/from/this/mirror
#wget http://cn2.php.net/get/php-5.5.15.tar.bz2/from/this/mirror
为php支持扩展
yum install libmcrypt-devel mhash-devel mcrypt bzip2-devel libxml2-devel libcurl-devel -y
编译安装
tar xf php-5.4.31.tar.bz2
cd php-5.4.31
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl
make && make install && echo $?
为php提供配置文件
cp php.ini-production /etc/php.ini
为php-fpm提供Sysv init脚本,并将其添加至服务列表
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
chkconfig --level 35 php-fpm on
为php-fpm提供配置文件:
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
接下来就可以启动php-fpm了,php-fpm监听9000端口
service php-fpm start
Nginx连接fastcgi的方式有2种:TCP和unix domain socket
Unix domain socket 或者 IPC socket是一种终端,可以使同一台操作系统上的两个或多个进程进行数据通信。与管道相比,Unix domain sockets 既可以使用字节流和数据队列,而管道通信则只能通过字节流。Unix domain sockets的接口和Internet socket很像,但它不使用网络底层协议来通信。Unix domain socket 的功能是POSIX操作系统里的一种组件。
Unix domain sockets 使用系统文件的地址来作为自己的身份。它可以被系统进程引用。所以两个进程可以同时打开一个Unix domain sockets来进行通信。不过这种通信方式是发生在系统内核里而不会在网络里传播。
TCP是使用TCP端口连接127.0.0.1:9000
Socket是使用unix domain socket连接套接字php-cgi.sock
vim /etc/nginx/nginx.conf
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000; #这里就是采用了tcp来进行连接
#fastcgi_pass unix:/dev/shm/php-cgi.sock; #这里就是采用了unix socket进行连接,之所以采用/dev/shm下是这个文件是tmpfs,比磁盘快
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #默认参数
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location / {
root html;
index index.php index.html index.htm;
}
修改fastcgi参数
vim /etc/nginx/fastcgi_params.default
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
service nginx restart
service php-fpm restart
测试页
新建php页面即可
cat > /usr/local/nginx/html/index.php << EOF
<?
php phpinfo();
?>
官方站点:http://www.memcached.org/
wget http://www.memcached.org/files/memcached-1.4.20.tar.gz
yum --enablerepo=epel install libevent-devel -y
tar xf memcached-1.4.20.tar.gz
cd memcached-1.4.20
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make && make install && echo $?
提供system V风格启动脚本
#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memory cache service.
# processname: memcached
# config: /etc/sysconfig/memcached
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
PORT=11211
USER=root
#max connect
MAXCONN=1024
#max memory
CACHESIZE=128
OPTIONS=""
MEMCACHED="/usr/local/memcached/bin/memcached"
if [ -f /etc/sysconfig/memcached ];
then
. /etc/sysconfig/memcached
fi
# Check that networking is up
if [ "$NETWORKING" = "no" ]
then
exit 0
fi
RETVAL=0
prog="memcached"
start () {
echo -n $"Starting $prog: "
# insure that /usr/local/memcached has proper permissions
chown $USER /usr/local/memcached
daemon $MEMCACHED -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -P /usr/local/memcached/memcached.pid $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
}
stop () {
echo -n $"Stopping $prog: "
killproc memcached
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f /var/lock/subsys/memcached
rm -f /usr/local/memcached/memcached.pid
fi
}
restart () {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status memcached
;;
restart|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/memcached ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $?
官方站点:http://www.phpmyadmin.net/home_page/index.php
安装页:http://docs.phpmyadmin.net/en/latest/setup.html#setup
配置页:http://docs.phpmyadmin.net/en/latest/config.html
wget http://jaist.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.2.7/phpMyAdmin-4.2.7-all-languages.zip
unzip phpMyAdmin-4.2.7-all-languages.zip
cp -a phpMyAdmin-4.2.7-all-languages /usr/local/nginx/html/phpMyAdmin
直接访问http://x.x.x.x/phpMyAdmin 即可
http://pecl.php.net/package/memcache
wget http://pecl.php.net/get/memcache-3.0.8.tgz
tar xf memcache-3.0.8.tgz
cd memcache-3.0.8
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache
make && make install && echo $?
# 编辑/etc/php.ini,在“动态模块”相关的位置添加如下一行来载入memcache扩展
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so
后面php的一些扩展程序这里并未一一列举