ubuntu系统中nginx启动脚本

ubuntu系统中nginx启动脚本

代码如下:#! /bin/sh### BEGIN INIT INFO# Provides:          nginx# Required-Start:    $remote_fs $syslog# Required-Stop:     $remote_fs $syslog# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: nginx init.d dash script for Ubuntu or other *nix.# Description:       nginx init.d dash script for Ubuntu or other *nix.### END INIT INFO#------------------------------------------------------------------------------# nginx - this Debian Almquist shell (dash) script, starts and stops the nginx#         daemon for Ubuntu and other *nix releases.## description:  Nginx is an HTTP(S) server, HTTP(S) reverse #               proxy and IMAP/POP3 proxy server.  This #               script will manage the initiation of the #               server and it's process state.## processname: nginx# config:      /usr/local/nginx/conf/nginx.conf# pidfile:     /usr/local/nginx/logs/nginx.pid# Provides:    nginx## Author:  Jason Giedymin#          <jason.giedymin AT gmail.com>.## Version: 3.5.1 11-NOV-2013 jason.giedymin AT gmail.com# Notes: nginx init.d dash script for Ubuntu.# Tested with: Ubuntu 13.10, nginx-1.4.3# # This script's project home is:#   http://github.com/JasonGiedymin/nginx-init-ubuntu##------------------------------------------------------------------------------#                               MIT X11 License#------------------------------------------------------------------------------## Copyright (c) 2008-2013 Jason Giedymin, http://jasongiedymin.com## Permission is hereby granted, free of charge, to any person obtaining# a copy of this software and associated documentation files (the# "Software"), to deal in the Software without restriction, including# without limitation the rights to use, copy, modify, merge, publish,# distribute, sublicense, and/or sell copies of the Software, and to# permit persons to whom the Software is furnished to do so, subject to# the following conditions:## The above copyright notice and this permission notice shall be# included in all copies or substantial portions of the Software.## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.#------------------------------------------------------------------------------
nginx配置gzip压缩页面

nginx配置gzip压缩页面

gzip(GNU-ZIP)是一种压缩技术。经过gzip压缩后页面大小可以变为原来的30%甚至更小,这样,用户浏览页面的时候速度会块得多。gzip的压缩页面需要浏览器和服务器双方都支持,实际上就是服务器端压缩,传到浏览器后浏览器解压并解析。
Nginx配置优化详解

Nginx配置优化详解

大多数的Nginx安装指南告诉你如下基础知识――通过apt-get安装,修改这里或那里的几行配置,好了,你已经有了一个Web服务器了!而且,在大多数情况下,一个常规安装的nginx对你的网站来说已经能很好地工作了。然而,如果你真的想挤压出nginx的性能,你必须更深入一些。在本指南中,我将解释Nginx的那些设置可以微调,以优化处理大量客户端时的性能。需要注意一点,这不是一个全面的微调指南。这是一个简单的预览――那些可以通过微调来提高性能设置的概述。你的情况可能不同。
nginx缓存页面后 串会话问题的解决方法

nginx缓存页面后 串会话问题的解决方法

nginx支持页面缓存,之前我的博客有介绍配置方案,昨天出了一个诡异的问题,别人的机器登录后,我的机器打开应用的首页会出现别人的用户信息,也就是说我的浏览器访问的应用会话其实是别人的会话。 经检查,nginx会把响应页面的头信息也一起缓存,包括Set-cookie,导致后面访问页面的用户的cookie被设置成缓存的头。 解决方案,nginx提供proxy_hide_header的指令,可以去掉相关 ···
如何让Nginx支持中文文件名具体设置步骤

如何让Nginx支持中文文件名具体设置步骤

首先得让你的系统有中语语言包: 设置前可以执行:locale 看一下,如果显示是en_US.UTF-8,即是正常,不用按下面的步骤设置。如果显示其他编码需要按如下步骤设置。 CentOS 编辑/etc/sysconfig/i18n 文件,内容修改为:(可以使用vi、nano或winscp图形管理软件,依个人口味选择) LANG="en_US.UTF-8" SYSFONT="latarcyrheb- ···
使用Nginx反向代理与proxy_cache缓存搭建CDN服务器的配置方法

使用Nginx反向代理与proxy_cache缓存搭建CDN服务器的配置方法

###################以下操作在nginx反向代理服务器上配置################### 1、关闭SELinux vi /etc/selinux/config#SELINUX=enforcing #注释掉#SELINUXTYPE=targeted #注释掉SELINUX=disabled #增加:wq 保存,关闭。shutdown -r now重启系统2、开启防火墙80端口 vi /etc/sysconfig/iptables添加下面的内容-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT/etc/init.d/iptables restart #重启防火墙使配置生效3、安装编译工具 yum install wget make gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl4 、系统约定 软件源代码包存放位置:/usr/local/src源码包编译安装位置:/usr/local/软件名字5、下载软件 cd /usr/local/src #进入目录(一)、下载nginx(目前稳定版)wget http://nginx.org/download/nginx-1.0.12.tar.gz(二)、下载pcre (支持nginx伪静态)wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz(二)、下载ngx_cache_purge(清除指定URL缓存)wget http://labs.frickle.com/files/ngx_cache_purge-1.5.tar.gz6、安装pcre cd /usr/local/srcmkdir /usr/local/pcre #创建安装目录tar zxvf pcre-8.21.tar.gzcd pcre-8.21./configure --prefix=/usr/local/pcre #配置makemake install7、安装 nginx groupadd www #添加www组useradd -g www www -s /bin/false #创建nginx运行账户www并加入到www组,不允许www用户直接登录系统 cd /usr/local/srctar zxvf ngx_cache_purge-1.5.tar.gztar zxvf nginx-1.0.12.tar.gzcd nginx-1.0.12./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.21 --add-module=../ngx_cache_purge-1.5 注意:--with-pcre=/usr/local/src/pcre-8.21指向的是源码包解压的路径,而不是安装的路径,否则会报错 make #编译make install #安装/usr/local/nginx/sbin/nginx #启动nginxchown www.www -R /usr/local/nginx/html #设置目录所有者chmod 700 -R /usr/local/nginx/html #设置目录权限vi /etc/rc.d/init.d/nginx # 设置nginx开启启动,编辑启动文件添加下面内容 =======================================================#!/bin/bash# nginx Startup script for the Nginx HTTP Server# it is v.0.0.2 version.# chkconfig: - 85 15# description: Nginx is a high-performance web and proxy server.# It has a lot of features, but it's not for everyone.# processname: nginx# pidfile: /var/run/nginx.pid# config: /usr/local/nginx/conf/nginx.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/usr/local/nginx/logs/nginx.pidRETVAL=0prog="nginx"# Source function library.. /etc/rc.d/init.d/functions# Source networking configuration.. /etc/sysconfig/network# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];thenecho "nginx already running...."exit 1fiecho -n $"Starting $prog: "daemon $nginxd -c ${nginx_config}RETVAL=$?echo[ $RETVAL = 0 ] && touch /var/lock/subsys/nginxreturn $RETVAL}# Stop nginx daemons functions.stop() {echo -n $"Stopping $prog: "killproc $nginxdRETVAL=$?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 -HUPRETVAL=$?echo}# See how we were called.case "$1" instart)startstop)stopreload)reloadrestart)stopstart;;
Nginx静态文件响应POST请求 提示405错误的解决方法

Nginx静态文件响应POST请求 提示405错误的解决方法

例1:用linux下的curl命令发送POST请求给Apache服务器上的HTML静态页 代码如下:[root@localhost ~]# curl -d 11=1 //www.jb51.net/index.html    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">   <HTML>       <HEAD>           <TITLE>405 Method Not Allowed</TITLE>       </HEAD>       <BODY>           <H1>Method Not Allowed</H1>           The requested method POST is not allowed for the URL /index.html.<P>           <HR>           <ADDRESS>Apache/1.3.37 Server at www.jb51.net Port 80</ADDRESS>       </BODY>   </HTML>