CentOS下编译Nginx,mysql,php-fpm,eaccelerator
wget http://sourceforge.net/projects/e2fsprogs/files/e2fsprogs/1.41.11/e2fsprogs-1.41.11.tar.gz/download
tar zxvf e2fsprogs-1.41.11.tar.gz
cd e2fsprogs-1.41.11
mkdir build; cd build
../configure
make
make install
sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
#openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
mkdir -p /data/soft
cd /data/soft
wget http://sysoev.ru/nginx/nginx-0.8.36.tar.gz
wget http://nginx.org/download/nginx-0.7.65.tar.gz
wget http://cn.php.net/get/php-5.3.2.tar.gz/from/this/mirror
wget http://mysql.proserve.nl/Downloads/MySQL-5.5/mysql-5.5.4-m3.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
wget http://pecl.php.net/get/memcache-2.2.5.tgz
wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.02.tar.gz
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
wget http://sourceforge.net/projects/imagemagick/files/ImageMagick/00-6.6.2/ImageMagick-6.6.2-0.tar.gz/download
wget http://pecl.php.net/get/imagick-2.3.0.tgz
wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./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
/sbin/ldconfig
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
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
tar zxvf mysql-5.5.4-m3.tar.gz
cd mysql-5.5.4-m3/
./configure --prefix=/usr/local/mysql --localstatedir=/data/mysql/data --enable-assembler --with-mysqld-ldflags=-rdynamic --with-client-ldflags=-all-static --with-plugins=innobase,partition --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=all --with-unix-socket-path=/tmp/mysql.sock --with-big-tables --with-readline --with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg --with-pthread --without-debug
make && make install
cd ../
mkdir -p /data/mysql/data/
mkdir -p /data/mysql/binlog/
mkdir -p /data/mysql/relaylog/
chmod +w /data/mysql
chown -R mysql:mysql /data/mysql
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/data --user=mysql
vim /data/mysql/my.cnf
[client]
character-set-server = utf8
port = 3306
socket = /tmp/mysql.sock
[mysqld]
character-set-server = utf8
default-storage-engine=MYISAM
replicate-ignore-db = mysql
replicate-ignore-db = test
replicate-ignore-db = information_schema
user = mysql
port = 3306
socket = /tmp/mysqld.sock
basedir = /usr/local/mysql
datadir = /data/mysql/data
log-error = /data/mysql/mysql_error.log
pid-file = /data/mysql/mysql.pid
open_files_limit = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
table_cache = 614
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 300
#thread_concurrency = 8
query_cache_size = 512M
query_cache_limit = 2M
query_cache_min_res_unit = 2k
max_connections=1000
thread_cache_size=64
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 246M
max_heap_table_size = 246M
long_query_time = 3
log-slave-updates
log-bin = /data/mysql/binlog/binlog
binlog_cache_size = 4M
binlog_format = MIXED
max_binlog_cache_size = 8M
max_binlog_size = 1G
relay-log-index = /data/mysql/relaylog/relaylog
relay-log-info-file = /data/mysql/relaylog/relaylog
relay-log = /data/mysql/relaylog/relaylog
expire_logs_days = 30
key_buffer_size = 256M
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
interactive_timeout = 120
wait_timeout = 120
skip-name-resolve
log-bin-trust-function-creators=1
#master-connect-retry = 10
slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
#master-host = 192.168.1.2
#master-user = username
#master-password = password
#master-port = 3306
server-id = 1
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 512M
innodb_data_file_path = ibdata1:256M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
#log-slow-queries = /data/mysql/slow.log
#long_query_time = 10
[mysqldump]
quick
max_allowed_packet = 32M
vim /etc/init.d/mysql
#!/bin/bash
#
# Init file for mysql server daemon
#
# chkconfig: 2345 55 25
# description: mysql server daemon
#
# processname: mysqld
. /etc/rc.d/init.d/functions
basedir=/usr/local/mysql
bindir=/usr/local/mysql/bin
datadir=/data/mysql/data
sbindir=/usr/local/mysql/bin
libexecdir=/usr/local/mysql/libexec
service_startup_timeout=900
# pid_file=$datadir/`/bin/hostname`.pid
pid_file=$datadir/localhost.pid
use_mysqld_safe=1
user=mysql
datadir_set=
other_args="--skip-name-resolve"
conf=/data/mysql/my.cnf
#######################################################
MYSQLD="$basedir/bin/mysqld_safe --defaults-file=$conf $other_args"
# echo $MYSQLD
usage(){
echo "usage:"
echo " $0 start|stop|status "
exit 1
}
if test -z $1
then
usage
fi
STATUS=$pid_file
case "$1" in
"start")
if test -s "$STATUS"
then
echo "The MySQL is running ..."
echo $pid_file
exit 1
fi
if test -s "$STATUS"
then
echo "The MySQL start fail ..."
else
$MYSQLD > /dev/null 2>&1 &
echo 'SUCCESS'
fi
;;
"stop")
pid=`cat $pid_file`
`kill $pid > /dev/null 2>&1`
echo "The MySQL is stop ..."
;;
"reload")
pid=`cat $pid_file`
`kill -HUP $pid > /dev/null 2>&1`
;;
"status")
if test -s "$STATUS"
then
echo "The MySQL is running..."
else
echo "The MySQL is down..."
fi
;;
*)
usage
;;
esac
exit 1
chmod +x /etc/init.d/mysql
mysql start
set password for root@localhost=password('在这里填入root密码');
tar zxvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr/local
make
make install
cd ..
ln -s /usr/local/lib/libevent-1.4.so.2 /usr/lib/libevent-1.4.so.2
tar zxvf php-5.3.2.tar.gz
cd php-5.3.2
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
svn co http://svn.php.net/repository/php/php-src/trunk/sapi/fpm sapi/fpm
svn co http://svn.php.net/repository/php/php-src/branches/PHP_5_3/sapi/fpm sapi/fpm
yum install autoconf213.noarch
export PHP_AUTOCONF=/usr/bin/autoconf-2.13
export PHP_AUTOHEADER=/usr/bin/autoheader-2.13
./buildconf --force
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --disable-debug --disable-ipv6 --enable-ftp --with-libevent --with-pear --enable-suhosin --with-zend-vm=GOTO --with-mysql-sock --enable-json --disable-reflection --with-bz2 --with-iconv --enable-sysvshm --with-pcre-regex --with-gettext --enable-sqlite-utf8 --with-ttf --enable-calendar --enable-dba --enable-gd-jis-conv --enable-exif --with-mime-magic --enable-memcache --enable-pdo --with-oci8
#--disable-rpath
# --with-ldap --with-ldap-sasl --with-libevent=/usr/local --with-fpm-user=www --with-fpm-group=www --with-iconv-dir=/usr/local
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-production /usr/local/php/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
vim /etc/init.d/php-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
### END INIT INFO
prefix=/usr/local/php
exec_prefix=${prefix}
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
# php_fpm_PID=${prefix}/var/run/php-fpm.pid
php_fpm_PID=/var/run/php-fpm.pid
php_opts="--fpm-config $php_fpm_CONF"
wait_for_pid () {
try=0
while test $try -lt 35 ; do
case "$1" in
'created')
if [ -f "$2" ] ; then
try=''
break
fi
;;
'removed')
if [ ! -f "$2" ] ; then
try=''
break
fi
;;
esac
echo -n .
try=`expr $try + 1`
sleep 1
done
}
case "$1" in
start)
echo -n "Starting php-fpm "
$php_fpm_BIN $php_opts
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
fi
wait_for_pid created $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Gracefully shutting down php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -QUIT `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed. Use force-exit"
exit 1
else
echo " done"
fi
;;
force-quit)
echo -n "Terminating php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -TERM `cat $php_fpm_PID`
wait_for_pid removed $php_fpm_PID
if [ -n "$try" ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reload service php-fpm "
if [ ! -r $php_fpm_PID ] ; then
echo "warning, no pid file found - php-fpm is not running ?"
exit 1
fi
kill -USR2 `cat $php_fpm_PID`
echo " done"
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload}"
exit 1
;;
esac
cd ../
mv /usr/local/php/etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf.bak
vim /usr/local/php/etc/php-fpm.conf
;
; Global
;
pid = /var/run/php-fpm.pid
error_log = /var/log/php-fpm.log
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
daemonize = yes
;pools here
include = /usr/local/php/etc/fpm.d/*.conf
mkdir -p /usr/local/php/etc/fpm.d
vim /usr/local/php/etc/fpm.d/eric_blog.conf
;
; eric's blog pool
;
[blog]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
;listen.owner = www
;listen.group = www
;listen.mode = 0666
user = www
group = www
; 有两种形式,static , dynamic 默认是以dynamic。
pm = static
pm.max_children = 50;
pm.start_servers = 20
;pm.min_spare_servers = 5
;pm.max_spare_servers = 35
pm.max_requests = 65535
;pm.status_path = /status
;ping.path = /ping
;ping.response = pong
request_terminate_timeout = 0s
request_slowlog_timeout = 0s
slowlog = /var/log/php-fpm.log.slow
rlimit_files = 65535
rlimit_core = 0
catch_workers_output = yes
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f
php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 20M
php_admin_value[open_basedir] = /data/htdocs/localhost:/data/cache/sessions:/tmp
php_admin_value[session.save_path] = /data/cache/sessions
vim /var/local/nginx/conf/fastcgi_param
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_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 GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
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;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
tar zxvf 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
make
make install
cd ../
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make
make install
cd ../
tar zxvf ImageMagick-6.6.2-3.tar.gz
cd ImageMagick-6.6.2-3
./configure
make
make install
cd ../
tar zxvf imagick-2.3.0.tgz
cd imagick-2.3.0/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ../
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"\nextension = "memcache.so"\nextension = "pdo_mysql.so"\nextension = "imagick.so"\n#' /usr/local/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini
sed -i "s#; always_populate_raw_post_data = On#always_populate_raw_post_data = On#g" /usr/local/php/etc/php.ini
mkdir -p /data/cache/eaccelerator
vim /usr/local/php/etc/php.ini
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/data/cache/eaccelerator"
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"
mkdir -p /data/htdocs
vim /usr/local/php/etc/php-fpm.conf
ulimit -SHn 65535
/usr/local/php/sbin/php-fpm
tar zxvf pcre-8.02.tar.gz
cd pcre-8.02/
./configure
make && make install
cd ../
tar zxvf nginx-0.8.36.tar.gz
cd nginx-0.8.36/
./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
rm -rf /usr/local/nginx/conf/nginx.conf
vim /usr/local/nginx/conf/nginx.conf
user www www;
worker_processes 8;
#nginx进程数,建议按照cpu数目来指定,一般为它的倍数
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
error_log /var/log/nginx/error.log crit;
pid /var/run/nginx.pid;
worker_rlimit_nofile 204800;
#这个指令是指当一个nginx进程打开的最多文件描述符数目,理论值应该是最多打开文件数(ulimit -n)与nginx进程数相除,但是nginx分配请求并不是那么均匀,所以最好与ulimit -n的值保持一致
events
{
use epoll;
worker_connections 204800;
#每个进程允许的最多连接数,理论上每台nginx服务器的最大连接数为worker_processes*worker_connections
}
http
{
include mime.types;
default_type application/octet-stream;
charset utf-8;
server_names_hash_max_size 512;
#服务器的名称哈希表的最大尺寸,默认512
server_names_hash_bucket_size 128;
access_log off;
server_tokens off;
#是否发送Nginx的版本号在错误页和Server标头
#客户端请求头部的缓冲区大小,这个可以根据你的系统分页大小来设置,一般一个请求头的大小不会超过1k,不过由于一般系统分页都要大于1k,所以这里设置为分页大小。分页大小可以用命令getconf PAGESIZE取得
client_header_buffer_size 4k;
#客户请求头部buffer大小
large_client_header_buffers 8 32k;
#client_max_body_size 8m;
client_max_body_size 5M;
client_body_buffer_size 16k;
#此指令限定了客户http请求体的大小,如果请求体的大小大于这个buffer的值,全部body或部分body将会被存储在临时文件里。默认值是两倍页面的大小,视平台而定,一般为8k/16k
#client_body_temp_path dir_path [ level1[level2 [level3 ] ] ]
#指定存储用户请求体文件的目录,在dir_path中有一个三层子目录的层次
client_header_timeout 60;
client_body_timeout 60;
#设定从客户端读取http请求体的超时时间
send_timeout 300;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
#keepalive超时时间
fastcgi_cache_path /data/cache/fastcgi levels=1:2 keys_zone=TEST:10m inactive=5m;
#这个指令为FastCGI缓存指定一个路径,目录结构等级,关键字区域存储时间和非活动删除时间
fastcgi_connect_timeout 300;
#指定连接到后端FastCGI的超时时间
fastcgi_send_timeout 300;
#向FastCGI传送请求的超时时间,这个值是指已经完成两次握手后向FastCGI传送请求的超时时间
fastcgi_read_timeout 300;
#接收FastCGI应答的超时时间,这个值是指已经完成两次握手后接收FastCGI应答的超时时间
fastcgi_buffer_size 4k;
#指定读取FastCGI应答第一部分需要用多大的缓冲区,一般第一部分应答不会超过1k,由于页面大小为4k,所以这里设置为4k
fastcgi_buffers 8 32k;
#指定本地需要用多少和多大的缓冲区来缓冲FastCGI的应答
fastcgi_busy_buffers_size 32k;
#这个指令我也不知道是做什么用,只知道默认值是fastcgi_buffers的两倍
fastcgi_temp_file_write_size 32k;
#在写入fastcgi_temp_path时将用多大的数据块,默认值是fastcgi_buffers的两倍
#fastcgi_cache TEST;
#开启FastCGI缓存并且为其制定一个名称。个人感觉开启缓存非常有用,可以有效降低CPU负载,并且防止502错误
#fastcgi_cache_valid 200 302 1h;
#fastcgi_cache_valid 301 1d;
#fastcgi_cache_valid any 1m;
#为指定的应答代码指定缓存时间,如上例中将200,302应答缓存一小时,301应答缓存1天,其他为1分钟
#fastcgi_cache_min_uses 1;
#缓存在fastcgi_cache_path指令inactive参数值时间内的最少使用次数,如上例,如果在5分钟内某文件1次也没有被使用,那么这个文件将被移除
#fastcgi_cache_use_stale error timeout invalid_header http_500;
#不知道这个参数的作用,猜想应该是让nginx知道哪些类型的缓存是没用的
#open_file_cache max=204800 inactive=20s;
#这个将为打开文件指定缓存,默认是没有启用的,max指定缓存数量,建议和打开文件数一致,inactive是指经过多长时间文件没被请求后删除缓存
#open_file_cache_min_uses 1;
#open_file_cache指令中的inactive参数时间内文件的最少使用次数,如果超过这个数字,文件描述符一直是在缓存中打开的,如上例,如果有一个文件在inactive时间内一次没被使用,它将被移除
#open_file_cache_valid 30s;
#这个是指多长时间检查一次缓存的有效信息
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_vary on;
gzip_types application/x-javascript text/html text/plain application/xml text/xml application/xhtml+xml text/css;
#gzip_types text/plain application/x-javascript text/css application/xml;
log_not_found off;
#upstream WEB_IP {
#定义web负载集群的IP组
#server 192.168.1.5:80;
#server 192.168.1.6:80;
#ip_hash;
#}
include conf.d/*.conf;
include conf.d/*.cn;
include conf.d/*.net;
include conf.d/*.com;
include conf.d/*.org;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$upstream_addr "$upstream_status" $upstream_response_time "$upstream_http_HEADER" ';
}
vim /usr/local/nginx/conf.d/localhost.conf
server
{
listen 80;
server_name _;
index index.html index.htm index.php;
root /data/htdocs/html;
location /status
{
stub_status on;
}
error_page 404 /404.html;
location = /404.html {
root /data/htdoc/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /data/htdoc/html;
}
location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
{
expires 30d;
}
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /var/log/nginx/localhost_access.log access;
}
mount -t tmpfs -o size=256M,mode=0777 tmpfs /data/cache/
mount -t tmpfs -o size=64M,mode=0777 tmpfs /data/session/
wget http://ncu.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.3/phpMyAdmin-3.3.3-all-languages.tar.gz
tar zxvf phpMyAdmin-3.3.3-all-languages.tar.gz
mv phpMyAdmin-3.3.3-all-languages pma
ulimit -SHn 65535
/usr/local/nginx/sbin/nginx