- # yum -y install pcre-devel
- # yum -y groupinstall "group_name"
- # groupadd -r nginx
- # useradd -r -g nginx nginx
- # tar xvf nginx-1.2.3.tar.gz
- # cd nginx-1.2.3
- # ./configure \
- --prefix=/usr \
- --sbin-path=/usr/sbin/nginx \
- --conf-path=/etc/nginx/nginx.conf \
- --error-log-path=/var/log/nginx/error.log \
- --http-log-path=/var/log/nginx/access.log \
- --pid-path=/var/run/nginx/nginx.pid \
- --lock-path=/var/lock/nginx.lock \
- --user=nginx \
- --group=nginx \
- --with-http_ssl_module \
- --with-http_flv_module \
- --with-http_stub_status_module \
- --with-http_gzip_static_module \
- --http-client-body-temp-path=/var/tmp/nginx/client/ \
- --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
- --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
- --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
- --http-scgi-temp-path=/var/tmp/nginx/scgi \
- --with-pcre
- # make && make install
- #!/bin/sh
- #
- # nginx - this script starts and stops the nginx daemon
- #
- # chkconfig: - 85 15
- # description: Nginx is an HTTP(S) server, HTTP(S) reverse \
- # proxy and IMAP/POP3 proxy server
- # processname: nginx
- # config: /etc/nginx/nginx.conf
- # config: /etc/sysconfig/nginx
- # pidfile: /var/run/nginx.pid
- # Source function library.
- . /etc/rc.d/init.d/functions
- # Source networking configuration.
- . /etc/sysconfig/network
- # Check that networking is up.
- [ "$NETWORKING" = "no" ] && exit 0
- nginx="/usr/sbin/nginx"
- prog=$(basename $nginx)
- NGINX_CONF_FILE="/etc/nginx/nginx.conf"
- [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
- lockfile=/var/lock/subsys/nginx
- make_dirs() {
- # make required directories
- user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
- options=`$nginx -V 2>&1 | grep 'configure arguments:'`
- for opt in $options; do
- if [ `echo $opt | grep '.*-temp-path'` ]; then
- value=`echo $opt | cut -d "=" -f 2`
- if [ ! -d "$value" ]; then
- # echo "creating" $value
- mkdir -p $value && chown -R $user $value
- fi
- fi
- done
- }
- start() {
- [ -x $nginx ] || exit 5
- [ -f $NGINX_CONF_FILE ] || exit 6
- make_dirs
- 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
- }
- 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|configtest)
- $1
- ;;
- 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|configtest}"
- exit 2
- esac
- # chmod +x /etc/rc.d/init.d/nginx
- # chkconfig --add nginx
- # chkconfig nginx on
- # service nginx start
- # groupadd -r mysql
- # useradd -g mysql -r -s /sbin/nologin -M -d /data/mydata mysql
- # chown -R mysql:mysql /data/mydata
- # tar xf mysql-5.5.28-linux2.6-i686.tar.gz -C /usr/local
- # cd /usr/local/
- # ln -sv mysql-5.5.28-linux2.6-i686 mysql
- # cd mysql
- # chown -R :mysql .
- # scripts/mysql_install_db --user=mysql --datadir=/mydata/data
- # cd /usr/local/mysql
- # cp support-files/my-large.cnf /etc/my.cnf
- thread_concurrency = 2
- datadir = /data/mydata #指定文件存放的位置
- # cd /usr/local/mysql
- # cp support-files/mysql.server /etc/rc.d/init.d/mysqld
- # chkconfig --add mysqld
- # chkconfig mysqld on
- MANPATH /usr/local/mysql/man
- # ln -sv /usr/local/mysql/include /usr/include/mysql
- # echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
- # ldconfig -v
- vim /etc/profile.d/mysql.sh
- # /usr/local/mysql/bin
- # yum -y groupinstall "X Software Development"
- libmcrypt-2.5.7-5.el5.i386.rpm
- libmcrypt-devel-2.5.7-5.el5.i386.rpm
- mhash-0.9.2-6.el5.i386.rpm
- mhash-devel-0.9.2-6.el5.i386.rpm
- mcrypt-2.6.8-1.el5.i386.rpm
- libevent-2.0.17-2.i386.rpm
- libevent-devel-2.0.17-2.i386.rpm
- # tar xf php-5.4.8.tar.bz2
- # cd php-5.4.8
- # ./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
- # cp php.ini-production /etc/php.ini
- # cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
- # chmod +x /etc/rc.d/init.d/php-fpm
- # chkconfig --add php-fpm
- # chkconfig php-fpm on
- # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
- pm.max_children = 50
- pm.start_servers = 5
- pm.min_spare_servers = 2
- pm.max_spare_servers = 8
- pid = /usr/local/php/var/run/php-fpm.pid
- # service php-fpm start
- # ps aux | grep php-fpm
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- include fastcgi_params;
- }
- 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;
- location / {
- root html;
- index index.php index.html index.htm;
- }
- # service nginx reload | restart
- # vim /usr/html/index.php
- <?php
- phpinfo();
- ?>
- # tar xf libevent-2.0.20-stable.tar.gz
- # cd libevent-2.0.20-stable
- # ./configure --prefix=/usr/local/libevent
- # make && make install
- # echo "/usr/local/libevent/lib" > /etc/ld.so.conf.d/libevent.conf
- # ldconfig -v
- # tar xf memcached-1.4.15.tar.gz
- # cd memcached-1.4.15
- # ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
- # make && make install
- #!/bin/bash
- #
- # Init file for memcached
- #
- # chkconfig: - 86 14
- # description: Distributed memory caching daemon
- #
- # processname: memcached
- # config: /etc/sysconfig/memcached
- . /etc/rc.d/init.d/functions
- ## Default variables
- PORT="11211"
- USER="nobody"
- MAXCONN="1024"
- CACHESIZE="64"
- OPTIONS=""
- RETVAL=0
- prog="/usr/local/memcached/bin/memcached"
- desc="Distributed memory caching"
- 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
- # chmod +x /etc/init.d/memcached
- # chkconfig --add memcached
- # service memcached start
- [root@www ~]# telnet 127.0.0.1 11211
- Trying 127.0.0.1...
- Connected to localhost.localdomain (127.0.0.1).
- Escape character is '^]'.
- set key 0 60 3
- abd
- STORED
- get key
- VALUE key 0 3
- abd
- END
- # tar xf memcache-2.2.5.tgz
- # cd memcache-2.2.5
- /usr/local/php/bin/phpize
- # ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache
- # make && make install
- extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so
- unzip memadmin-master.zip
- cd memadmin-master
- mv * /usr/html/
- # tar xf libmemcached-1.0.2.tar.gz
- # cd libmemcached-1.0.2
- # ./configure
- # make && make install
- # ldconfig -v
- [root@www ~]# memping --server=127.0.0.1:11211
- [root@www ~]# memstat --server=127.0.0.1:11211
- Server: 127.0.0.1 (11211)
- pid: 29198
- uptime: 3660
- time: 1352786258
- version: 1.4.15
- libevent: 2.0.20-stable
- pointer_size: 32
- rusage_user: 0.003999
- rusage_system: 0.037994
- curr_connections: 10
- ………………………………
- vim /etc/nginx/nginx.conf
- server {
- listen 80;
- server_name www.magedu.com;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- set $memcached_key $uri;
- memcached_pass 127.0.0.1:11211;
- default_type text/html;
- error_page 404 @fallback;
- }
- location @fallback {
- proxy_pass http://172.16.0.1;
- }
- }