|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!1、装置pcre:
复制代码
cd/usr/local/src
wgethttp://downloads.sourceforge.net/project/pcre/pcre/8.34/pcre-8.34.tar.gz
tarzxvfpcre-8.34.tar.gz
cdpcre-8.34
./configure--prefix=/usr/local/pcre
make
makeinstall
复制代码
2、下载proxy_cache插件
cd/usr/local/src
wgethttp://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz
tarzxvfngx_cache_purge-2.1.tar.gz
3、装置tengine
按Ctrl+C复制代码
按Ctrl+C复制代码
/usr/local/nginx/sbin/nginx#启动nginx
chownnobody.nobody-R/usr/local/nginx/html
chmod700-R/usr/local/nginx/html
假如编译的成绩的话,看看是否是上面的缘故原由:
./configure:error:theHTTPSSLmodulerequiresOpenSSLlibrary
缘故原由:装置http_ssl_module模块必要openssllibrary
办理:yuminstallopenssl-devel
./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.
缘故原由:装置http_rewrite_module模块必要先装置PCRE开辟包
办理:yuminstallpcre-devel
注重:
--with-pcre=/usr/local/src/pcre-8.21指向的是源码包解压的路径,而不是装置的路径,不然会报错。
--add-module=/usr/local/src/ngx_cache_purge-2.1是指加载缓存的插件模块
4、设置Tengine开机启动
vi/etc/rc.d/init.d/nginx#编纂启动文件增加上面内容
复制代码
#!/bin/bash
#TengineStartupscript#processname:nginx
#chkconfig:-8515
#description:nginxisaWorldWideWebserver.Itisusedtoserve
#pidfile:/var/run/nginx.pid
#config:/usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
#Sourcefunctionlibrary.
./etc/rc.d/init.d/functions
#Sourcenetworkingconfiguration.
./etc/sysconfig/network
#Checkthatnetworkingisup.
[${NETWORKING}="no"]&&exit0
[-x$nginxd]||exit0
#Startnginxdaemonsfunctions.
start(){
if[-e$nginx_pid];then
echo"tenginealreadyrunning...."
exit1
fi
echo-n$"Starting$prog:"
daemon$nginxd-c${nginx_config}
RETVAL=$?
echo
[$RETVAL=0]&&touch/var/lock/subsys/nginx
return$RETVAL
}
#Stopnginxdaemonsfunctions.
stop(){
echo-n$"Stopping$prog:"
killproc$nginxd
RETVAL=$?
echo
[$RETVAL=0]&&rm-f/var/lock/subsys/nginx/usr/local/nginx/logs/nginx.pid
}
reload(){
echo-n$"Reloading$prog:"
#kill-HUP`cat${nginx_pid}`
killproc$nginxd-HUP
RETVAL=$?
echo
}
#Seehowwewerecalled.
case"$1"in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status$prog
RETVAL=$?
;;
*)
echo$"Usage:$prog{start|stop|restart|reload|status|help}"
exit1
esac
exit$RETVAL
复制代码
保留加入
chmod775/etc/rc.d/init.d/nginx#付与文件实行权限
chkconfig--level012345nginxon#设置开机启动
/etc/rc.d/init.d/nginxrestart
4、设置Tengine
将nginx初始设置文件备份,我们要从头创立设置文件.
mv/usr/local/nginx/conf/nginx.conf/usr/local/nginx/conf/nginx.conf.bak
创立nginx用户www
groupaddwww
useradd-gwwwwww
编纂主设置文件:
vi/usr/local/nginx/conf/nginx.conf
内容以下:
复制代码
userwwwwww;
worker_processes4;#事情历程数,为CPU的中心数大概两倍
error_loglogs/error.logcrit;#debug|info|notice|warn|error|crit
pidlogs/nginx.pid;
#Specifiesthevalueformaximumfiledescriptorsthatcanbeopenedbythisprocess.
worker_rlimit_nofile65535;
events{
useepoll;#Linux最经常使用撑持年夜并发的事务触发机制
worker_connections65535;
}
http{
includemime.types;#设定mime范例,范例由mime.type文件界说
default_typeapplication/octet-stream;
charsetutf-8;
log_formatmain$remote_addr-$remote_user[$time_local]"$request"
$status$body_bytes_sent"$http_referer"
"$http_user_agent""$http_x_forwarded_for";
access_loglogs/access.logmain;
#设定哀求缓冲
server_names_hash_bucket_size256;#增添,原为128
client_header_buffer_size256k;#增添,原为32k
large_client_header_buffers4256k;#增添,原为32k
#sizelimits
client_max_body_size50m;#同意客户端哀求的最年夜的单个文件字节数
client_header_timeout3m;
client_body_timeout3m;
send_timeout3m;
sendfileon;
tcp_nopushon;
keepalive_timeout60;
tcp_nodelayon;
server_tokenson;#不显现nginx版本信息
limit_conn_zone$binary_remote_addrzone=perip:10m;#增加limit_zone,限定统一IP并发数
#fastcgi_intercept_errorson;#开启毛病页面跳转
includegzip.conf;#紧缩设置文件
includeproxy.conf;#proxy_cache参数设置文件
includevhost/*.conf;#nginx假造主机包括文件目次
includemysvrhost.conf;#后端WEB办事器列表文件
}
复制代码
编纂代办署理设置文件:
cd/usr/local/nginx/conf/
mkdirvhost
vi/usr/local/nginx/conf/proxy.conf
内容以下:
复制代码
#注:proxy_temp_path和proxy_cache_path指定的路径必需在统一分区
proxy_temp_path/tmp/proxy_temp; |
|