一.依赖环境安装
yum install gcc-c++  gcc ncurses-devel bison
tar zxvf cmake-2.8.9.tar.gz
cd cmake-2.8.9
./configure
make;make install
二.mysql安装与配置
groupadd mysql
useradd -g mysql mysql
tar zxvf mysql-5.5.27.tar.gz
cd mysql-5.5.27
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.27 \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_DEBUG=0
make;make install
=======================mysql配置=================================
cd /usr/local/mysql-5.5.27/
cp ./support-files/my-huge.cnf /etc/my.cnf
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
mkdir -p /data/mysql
mkdir -p /data/mysql/3306/logs/binlog/
chown -R mysql:mysql /data/mysql
/usr/local/mysql-5.5.27/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.5.27 --datadir=/data/mysql/3306/data
mv /etc/my.cnf /data/mysql/3306/
ln -s /data/mysql/3306/my.cnf /etc/my.cnf

service mysqld start
cp -rf /usr/local/mysql-5.5.27/bin/* /usr/bin/
mysqladmin -uroot password 'pinla2012'
======================主从配置============================
【master1】
====主数据库设置====
vim /etc/my.cnf
在mysqld中追加
#********master1*********
server-id=1
log-bin=mysql-bin
read-only=0
innodb_flush_log_at_trx_commit=1
sync_binlog=1
#binlog-do-db=pinladb
binlog_ignore_db=mysql
binlog_ignore_db=test
binlog_ignore_db=information_schema
replicate-ignore-db=test
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
log-slave-updates
slave-skip-errors=all
auto_increment_increment=2
auto_increment_offset=1

service mysqld restart
mysql -uroot -p
GRANT FILE,REPLICATION SLAVE,REPLICATION CLIENT,SUPER,RELOAD ON *.* TO pinla_backup@'%'IDENTIFIED by 'pinla2012';
==pinla_backup账号测试==
mysql -h192.168.10.240 -upinla_backup -p

change master to master_host='192.168.10.245',master_user='pinla_backup',master_password='pinla2012';
flush privileges;
slave start;
show slave status\G

【master2】
#********master2*********
server-id=2
log-bin=mysql-bin
read-only=0
innodb_flush_log_at_trx_commit=1
sync_binlog=1
#binlog-do-db=pinladb
binlog_ignore_db=mysql
binlog_ignore_db=test
binlog_ignore_db=information_schema
replicate-ignore-db=test
#replicate-ignore-db=mysql
#replicate-ignore-db=information_schema
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=2

service mysqld restart
mysql -uroot -p
GRANT FILE,REPLICATION SLAVE,REPLICATION CLIENT,SUPER,RELOAD ON *.* TO pinla_backup@'%'IDENTIFIED by 'pinla2012';
==pinla_backup账号测试==
mysql -h192.168.10.245 -upinla_backup -p

change master to master_host='192.168.10.240',master_user='pinla_backup',master_password='pinla2012';
flush privileges;
slave start;
show slave status\G

show processlist \G;

【slave】
===从数据库设置====
#****slave******
server-id=11
log-bin=mysql-bin
binlog_format=mixed
replicate-ignore-db=test
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
relay-log=db-server-2-relay-bin
log-slave-updates
===设置备份点===
mysql -uroot -p
slave stop;
change master to master_host='192.168.10.243',master_user='pinla_backup',master_password='pinla2012';
slave start;
show slave status\G
==================heartbeat配置===========================
vip:192.168.10.244
master1-eth3:192.168.10.240
#master1-eth2:10.10.10.100
master1-eth2:192.168.10.242
#master2-eth0:10.10.10.200
master2-eth0:192.168.10.243
master2-eth1:192.168.10.245

1.双master服务器网卡设置
使用网线直接连接两个master,并且配置两个服务器的IP
2.安装HA与HA依赖包
yum install libnet heartbeat* heartbeat-devel heartbeat-pils heartbeat-stonith heartbeat-ldirectord ipvsadm
cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/
==配置心跳加密方式:authkeys==
vim /etc/ha.d/authkeys
auth 1
1 crc

chmod 600 /etc/ha.d/authkeys
==配置心跳的监控:haresources==
vim /etc/ha.d/haresources
追加
PL100 IPaddr::192.168.10.245/16/eth0 ipvsadm mysqld
#PL100 为主主机名(可以使用uname -n获得) ipvsadm mysqld为启动心跳同时启动该服务。
#IPaddr:: 为VIP
mkdir -p /var/log/ha_log
chmod 777 /var/log/ha_log
==配置心跳的配置文件:ha.cf==
vi /etc/ha.d/ha.cf
#ha的日志文件记录位置
logfile /var/log/ha_log/ha-log.log
#使用eth3做心跳监测
bcast eth3
#设定心跳(监测)时间时间为2秒
keepalive 2
warntime 10
deadtime 30
initdead 120
hopfudge 1
#使用udp端口694进行心跳监测
udpport 694
#开启为主节点恢复后自动强占资源(该模式很有可能出现脑裂)
auto_failback off
#节点1,必须要与 uname -n 指令得到的结果一致。
node PL100
#节点2
node PL102
ping 192.168.10.1 #通过ping网关来监测心跳是否正常
#respawn hacluster /usr/lib/heartbeat/ipfail
#apiauth ipfail gid=root uid=root
debugfile /var/log/ha_log/ha-debug.log

#创建日志文件
touch /var/log/ha_log/ha-log.log
==设置ipvsadm的巡回监测==
ipvsadm -A -t 192.168.10.244:3306 -s rr
ipvsadm -a -t 192.168.10.244:3306 -r 10.10.10.100:3306 -m
ipvsadm -a -t 192.168.10.244:3306 -r 10.10.10.200:3306 -m
ipvsadm --save
执行后则开始进行监测
ipvsadm --list
service heartbeat start
chkconfig --add heartbeat
==防火墙设置==
iptables -I INPUT -p udp --dport 694 -j ACCEPT
=======到此为止以上为mysql+hearbeat配置========
三.nginx+php
1.php配置
#PHP 5.3.3开始已经集成了PHP-FPM
==依赖环境安装==
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make
make install
cd ..
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make;make install
cd ./libltdl
./configure --enable-ltdl-install 
make;make install
cd ../..
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure
make;make install
yum install libxml2 libxml2-devel openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel mysql-devel
==php安装==
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/
ln -s /usr/local/mysql-5.5.27/lib/libmysqlclient.so.18  /usr/lib64/
chmod 755 /usr/lib64/
tar zxvf php-5.3.16.tar.gz
cd php-5.3.16
./configure --prefix=/usr/local/php-5.3.16 --with-config-file-path=/usr/local/php-5.3.16/etc  --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath  --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex  --enable-fpm  --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-pdo_mysql --with-mysql=/usr/local/mysql-5.5.27/ --with-mysqli
make ZEND_EXTRA_LIBS='-liconv'
make install
#make时若报错make: *** [sapi/fpm/php-fpm] Error 1
#找到Makefile文件,在EXTRA_LIBS最后添加-lresolv
EXTRA_LIBS = -lcrypt -lcrypt -lrt -lmysqlclient -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lresolv

cp php.ini-production /usr/local/php-5.3.16/etc/php.ini
#因为php5.3开始自带fpm,使用自带的管理脚本
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
#设置开机自启动
chkconfig php-fpm on
cp /usr/local/php-5.3.16/etc/php-fpm.conf.default /usr/local/php-5.3.16/etc/php-fpm.conf
vim /usr/local/php-5.3.16/etc/php-fpm.conf
追加
pid = run/php-fpm.pid
修改
user = nobody
group = nobody

user = www
group = www

==安装eAccelerator==
#如需要安装则进行安装,其起到php程序的加速
tar zxvf eaccelerator-eaccelerator-42067ac.tar.gz
cd eaccelerator-eaccelerator-42067ac
/usr/local/php-5.3.16/bin/phpize
#若报错
Cannot find autoconf.需安装autoconf
yum install autoconf
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php-5.3.16/bin/php-config
make;make install
vim /usr/local/php-5.3.16/etc/php.ini
追加
extension_dir = "/usr/local/php-5.3.16/lib/php/extensions/no-debug-non-zts-20090626/"
cgi.fix_pathinfo=0

mkdir -p /usr/local/eaccelerator_cache
vi /usr/local/php-5.3.16/etc/php.ini
追加
[eaccelerator]
zend_extension="/usr/local/php-5.3.16/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

==安装APC==
tar zxvf APC-3.1.9.tgz
cd APC-3.1.9
/usr/local/php-5.3.16/bin/phpize
./configure --with-php-config=/usr/local/php-5.3.16/bin/php-config
make;make install
2.nginx安装
yum install pcre-devel
groupadd www
useradd -s /sbin/nologin -g www www
mkdir -p /data/wwwroot
chmod +w /data/wwwroot
mkdir -p /data/nginxlogs
chmod 755 /data/nginxlogs
chown -R www:www /data/wwwroot
tar zxvf nginx-1.2.3.tar.gz
cd nginx-1.2.3
./configure --user=www --group=www --prefix=/usr/local/nginx-1.2.3 --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module  --with-pcre
make;make install
mkdir /usr/local/nginx-1.2.3/conf/vhost/
rm -f /usr/local/nginx-1.2.3/conf/nginx.conf
==基本的nginx配置==
vim /usr/local/nginx-1.2.3/conf/nginx.conf
参照nginx.conf
==vhost设置===
cd /usr/local/nginx-1.2.3/conf/vhost
vim www.pinla.com.conf
参照nginx_vhost_www.pinla.com.conf
==为不同的vhost创建目录==
mkdir -p /data/wwwroot/www.pinla.com/
==创建管理脚本==
vim /etc/init.d/nginx
内容详见nginx_管理脚本.sh中
chmod +x /etc/init.d/nginx
chkconfig nginx on

==========================环境说明=================================
直接输入以下命令,会得到相应的结果
service nginx restart #重启nginx
service mysqld restart #重启mysql
service php-fpm restart #重启php-fpm
service php-fpm stop #停止php-fpm
service php-fpm start #启动php-fpm
 
各站点的根目录是 /data/wwwroot/
应用的目录是 /usr/local/
各配置文件的存放位置是:
php: /usr/local/php-5.3.16/etc/
mysql: /etc/
nginx: /usr/local/nginx-1.2.3/conf/
==安装zend扩展==
tar zxvf ZendFramework-1.12.0.tar.gz
mkdir /usr/local/nginx-1.2.3/Library
mv ZendFramework-1.12.0/library/ /usr/local/nginx-1.2.3/Library/
vim /usr/local/php-5.3.16/etc/php.ini
修改为
include_path = ".:/php/includes:/usr/local/nginx-1.2.3/Library:/data/wwwroot/www.pinla.com/Library"


==redis安装配置==
tar zxvf redis-2.4.16.tar.gz
cd redis-2.4.16
make;make install
cp redis.conf /etc/
vim /etc/redis.conf
修改daemonize no为daemonize yes
#开启
redis-server /etc/redis.conf
echo "redis-server /etc/redis.conf ">>/etc/rc.local
echo "vm.overcommit_memory = 1" >>/etc/sysctl.conf
sysctl -p
#测试
redis-benchmark
#登陆
redis-cli
==安装和配置redis-php的扩展==
unzip  nicolasff-phpredis-2.2.2-38-g6f7087f.zip
cd nicolasff-phpredis-6f7087f/
/usr/local/php-5.3.16/bin/phpize
./configure --with-php-config=/usr/local/php-5.3.16/bin/php-config
make;make install
#安装完成后会输出类似下边的
#/usr/local/php-5.3.16/lib/php/extensions/no-debug-non-zts-20090626/
#若extension_dir = "/usr/local/php-5.3.16/lib/php/extensions/no-debug-non-zts-20090626/"已在PHP目录中则无需添加,若无需添加
vim /usr/local/php-5.3.16/etc/php.ini
在PHP扩展目录中追加
extension = redis.so

==安装配置sphinx==
yum install  automake libtool
【mmseg】
tar zxvf coreseek-4.1-beta.tar.gz
cd coreseek-4.1-beta/mmseg-3.2.14 
./configure --prefix=/usr/local/mmseg3
make;make install
提示config.status: error: cannot find input file: src/Makefile.in
执行以下命令:
aclocal
libtoolize --force
automake --add-missing
autoconf
autoheader
make clean
【csft】
cd coreseek-4.1-beta/csft-4.1
sh buildconf.sh
./configure --prefix=/usr/local/sphinx --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib
make;make install
vim /usr/local/sphinx/etc/pinla.conf
[测试]
cd ../testpack
cat var/test/test.xml
/usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc var/test/test.xml
#生成索引
/usr/local/sphinx/bin/indexer --config  /usr/local/sphinx/etc/pinla.conf --all
#启动服务
/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/pinla.conf
#网络索引测试
/usr/local/sphinx/bin/search --config /usr/local/sphinx/etc/pinla.conf

#crontab -e    加入crontab五分钟重新索引
*/5 * * * */usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/pinla.conf --rotate --all
==安装php sphinx client 扩展==

tar zxvf sphinx-2.0.5-release.tar.gz
cd ./sphinx-2.0.5-release/api/libsphinxclient/
#vim sphinxclient.c                   
    找到
    void sock_close ( int sock );
    改为
    static void sock_close ( int sock );
 
./configure --prefix=/usr/local/sphinxclient
make&&make install

tar zxvf sphinx-1.2.0.tgz
cd sphinx-1.2.0
/usr/local/php-5.3.16/bin/phpize
./configure --with-php-config=/usr/local/php-5.3.16/bin/php-config --with-sphinx=/usr/local/sphinxclient
make&&make install
#安装完成后会提示模块已写入的路径
/usr/local/php-5.3.16/lib/php/extensions/no-debug-non-zts-20090626/
vim /usr/local/php-5.3.16/etc/php.ini
追加
extension = sphinx.so
#重启PHP
service php-fpm restart


#创建主索引
/usr/local/sphinx/bin/indexer shop  --config /usr/local/sphinx/etc/pinla.conf --rotate
#创建增量索引:
/usr/local/sphinx/bin/indexer delta --config /usr/local/sphinx/etc/pinla.conf  --rotate
#合并
/usr/local/sphinx/bin/indexer --merge shop delta -c /usr/local/sphinx/etc/pinla.conf --rotate
#查询索引
/usr/local/sphinx/bin/search --config /usr/local/sphinx/etc/pinla.conf  -a 米娜
#计划任务
*/5 * * * * /usr/local/sphinx/bin/indexer delta --config /usr/local/sphinx/etc/pinla.conf --rotate;/usr/local/sphinx/bin/indexer --merge shop delta -c /usr/local/sphinx/etc/pinla.conf --rotate
30 2 * * * /usr/local/sphinx/bin/indexer shop  --config /usr/local/sphinx/etc/pinla.conf --rotat


====安装配置fastdfs_client======
tar zxvf FastDFS_v3.11.tar.gz
cd FastDFS
./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
./make.sh install
cd ./php_client
/usr/local/php-5.3.16/bin/phpize
./configure --with-php-config=/usr/local/php-5.3.16/bin/php-config
make&&make install
mkdir -p /data/fdfs_data
vim /usr/local/php-5.3.16/etc/php.ini
追加
extension=fastdfs_client.so
fastdfs_client.base_path = /tmp
fastdfs_client.connect_timeout = 2
fastdfs_client.network_timeout = 60
fastdfs_client.log_level = info
fastdfs_client.log_filename =
fastdfs_client.http.anti_steal_secret_key =
fastdfs_client.tracker_group_count = 1
fastdfs_client.tracker_group0 = /etc/fdfs/client.conf

vim /etc/fdfs/client.conf
connect_timeout=30
network_timeout=60
base_path=/data/fdfs_data
tracker_server=192.168.10.225:22122
log_level=info
http.tracker_server_port=8080

 

九.haproxy配置
tar zxvf haproxy-1.4.21.tar.gz
cd haproxy-1.4.21
uname -a //查看linux内核版本
make TARGET=linux26 PREFIX=/usr/local/haproxy-1.4.21
make install PREFIX=/usr/local/haproxy-1.4.21

==配置haproxy==
mkdir -p /usr/local/haproxy-1.4.21/conf
vim /usr/local/haproxy-1.4.21/conf/haproxy.conf
#参考haproxy.conf
   
==配置haproxy服务脚本==
mkdir /usr/local/haproxy-1.4.21/init.d/
mkdir -p /usr/local/haproxy-1.4.21/run/
#开启
/usr/local/haproxy-1.4.21/sbin/haproxy -f /usr/local/haproxy-1.4.21/conf/haproxy.conf
或者脚本
vim /usr/local/haproxy-1.4.21/init.d/haproxy
#参考haproxy_启动脚本.sh

chmod +x /usr/local/haproxy-1.4.21/init.d/haproxy
echo "net.ipv4.ip_nonlocal_bind=1" >>/etc/sysctl.conf
sysctl -p
==启动haproxy==
/usr/local/haproxy/init.d/haproxy start
==配置haproxy日志==
mkdir /usr/local/haproxy/log
touch /usr/local/haproxy/log/haproxy.log
vim /etc/syslog.conf
追加
SYSLOGD_OPTIONS="-m 0 -r -x"
local3.*                                                /usr/local/haproxy/log/haproxy.log

/etc/init.d/syslog restart
/usr/local/haproxy/init.d/haproxy stop
/usr/local/haproxy/init.d/haproxy start

=====varnish安装与配置========
yum install pkgconfig
tar zxvf varnish-3.0.2.tar.gz
cd varnish-3.0.2
./configure --prefix=/usr/local/varnish-3.0.2
make && make install
cp redhat/varnish.initrc /etc/init.d/varnish
cp redhat/varnish.sysconfig /etc/sysconfig/varnish
cp redhat/varnish_reload_vcl /usr/local/varnish-3.0.2/bin/

mv   /usr/local/varnish-3.0.2/bin/varnish_reload_vcl /usr/local/varnish-3.0.2/bin/varnish_reload_vcl_back
vim /usr/local/varnish-3.0.2/bin/varnish_reload_vcl
#参照varnish_reload_vcl_config

groupadd varnish
useradd -s /bin/false -M varnish -g varnish
mkdir /data/varnish_logs /data/varnish_cache
chown -R varnish.varnish /data/varnish_logs
chown -R varnish.varnish  /data/varnish_cache
chmod +w /data/varnish_cache
chmod +w /data/varnish_logs


vim /usr/local/varnish-3.0.2/etc/varnish/pinla.vcl
#参照pinla_vcl_config
======服务启动=======
/usr/local/varnish-3.0.2/sbin/varnishd -n /data/varnish_cache -f /usr/local/varnish-3.0.2/etc/varnish/pinla.vcl -a 0.0.0.0:8080 -s file,/data/varnish_cache/varnish_cache.data,50G -g varnish -u varnish -w30000,51200,50 -T 0.0.0.0:3000 -p thread_pool_min=200 -p thread_pool_max=4000 -p thread_pools=4 -p thread_pool_add_delay=2 -p listen_depth=4096 -p lru_interval=20

==配置启动脚本==
mv /etc/sysconfig/varnish /etc/sysconfig/varnish_back
vim /etc/sysconfig/varnish
#参照varnish_config
vim /etc/init.d/varnish
修改
exec="/usr/local/varnish-3.0.2/sbin/varnishd"
reload_exec="/usr/local/varnish-3.0.2/bin/varnish_reload_vcl"

chmod 755 /etc/init.d/varnish
#开启
service varnish start
service varnish stop

===配置varnish日志脚本===
#需要rotatelogs工具(可通过安装apache获得)
yum install httpd
vim /etc/init.d/varnishncsa
#日志脚本可参考varnishncsa.txt
chmod 755 /etc/init.d/varnishncsa

#开启/关闭日志
/etc/init.d/varnishncsa start
/etc/init.d/varnishncsa stop

#不用脚本的方式
#启动varnishncsa用来将Varnish访问日志写入日志文件
/usr/local/varnish-3.0.2/bin/varnishncsa -n /data/varnish_cache -w /data/varnish_logs/varnish.log &

#查看varnish缓存状态及命中率
/usr/local/varnish-3.0.2/bin/varnishstat -n /data/varnish_cache
#基于端口的管理varnish
telnet 127.0.0.1 3000

=========nfs安装配置============
mkdir /data/static
mkdir /data/wwwroot
echo "/data/static  *(rw,sync,no_root_squash)" >> /etc/exports
#开启NFS和portmap服务
service nfs start
service portmap start
chkconfig --level 3 nfs  on
chkconfig --level 3 portmap on
#客户端挂载
#开启portmap服务
service portmap start
如果portmap服务未启,则在mount时会报错:
chkconfig --level 3 portmap on
mkdir /data/static
mount  -t nfs 192.168.10.225:/data/static  /data/static/
#加入rc.loacl
echo "mount  -t nfs 192.168.10.225:/data/static  /data/static/">>/etc/rc.local

===========inotify+rsync=========
#NFS服务器
#查看是否支持,若存在该目录则支持
ll /proc/sys/fs/inotify
tar zxvf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure --prefix=/usr/local/inotify-3.14
make
make install
#生成SSH KEY
ssh-keygen -t rsa
scp ~/.ssh/id_rsa.pub root@192.168.10.241:~/.ssh/
scp ~/.ssh/id_rsa.pub root@192.168.10.240:~/.ssh/
#客户机
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
service sshd restart
#NFS服务器端
#编写脚本
mkdir /data/shell
vim /data/shell/inotifyrsync.sh
#脚本内容详见inotifyrsync.sh文件内
chmod +x /data/shell/inotifyrsync.sh
#将脚本放至后台运行
nohup /data/shell/inotifyrsync.sh &
#使脚本开机自动运行
echo "/data/shell/inotifyrsync.sh &" >> /etc/rc.local


=======nginx添加IP库=====
yum install *GeoIP*

tar zxvf GeoIP-1.4.8.tar.gz
cd GeoIP-1.4.8
./configure
make;make install
#编译nginx的扩展
cd nginx-1.2.3
./configure --user=www --group=www --prefix=/usr/local/nginx-1.2.3 --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module  --with-pcre --with-http_geoip_module
make;make install

gunzip GeoIP.dat.gz
gunzip GeoLiteCity.dat.gz
mv GeoIP.dat /usr/local/nginx-1.2.3/conf/
mv GeoLiteCity.dat /usr/local/nginx-1.2.3/conf/
vim  /usr/local/nginx-1.2.3/conf/nginx.conf
在http中追加
    geoip_country  GeoIP.dat;
    geoip_city     GeoLiteCity.dat;

在server中追加
if ( $http_cookie !~* PL_IPCITY ) {
    add_header Set-Cookie "PL_IPCITY=$geoip_city;Domain=.pinla.com;Path=/" ;  
}
fastcgi_param PL_IPCITY $geoip_city;