下面假设相关的软件及模块的压缩包都在/home/soft目录下:
1. 解压nginx
cd /home/soft tar -zxvf nginx-1.2.0.tar.gz
2. 准备nginx_upstream_jvm_route模块的包
cd /nginx-1.2.0 patch -p0 < ../nginx_upstream_jvm_route/jvm_route.patch
3. 解压下载好的pcre包
cd ../ tar -zxvf pcre-8.31.tar.gz
4.下面安装nginx
cd /nginx-1.2.0 ./configure --prefix=/usr/local/nginx --with-pcre=/home/soft/pcre-8.31 --with-http_stub_status_module --with-http_ssl_module --add-module=/home/soft/nginx_upstream_jvm_route make make install
5. 查看Nginx已安装/编译的模块
/usr/local/nginx/sbin/nginx -V
6. 使用中发现某个模块(例如:http_realip_module)未安装?可以重新编译,然后复制objs/ngxin到nginx的sbin目录,替换原来的文件
重新编译并添加新模块(注意make后就不要make install了,不然就是覆盖安装了)
cd /nginx-1.2.0 ./configure --prefix=/usr/local/nginx --with-pcre=/home/soft/pcre-8.31 --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=/home/soft/nginx_upstream_jvm_route make
备份并替换原来的sbin/nginx文件
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak cp ./objs/nginx /app/nginx/sbin/
7. 让nginx作为服务启动
vi /etc/init.d/nginx
然后输入如下内容
#! /bin/sh # description: Nginx Server # chkconfig: 2345 99 01 # source function library . /etc/rc.d/init.d/functions set -e ulimit -SHn 51200 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="nginx daemon" NAME=nginx DAEMON=/usr/local/nginx/sbin/$NAME CONFIGFILE=/usr/local/nginx/conf/nginx.conf PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed. test -x $DAEMON || exit 0 d_start() { $DAEMON -c $CONFIGFILE || echo -n " already running" } d_stop() { kill -QUIT `cat $PIDFILE` || echo -n " not running" killall nginx >/dev/null 2>1& } d_test() { $DAEMON -t } d_reload() { kill -HUP `cat $PIDFILE` || echo -n " can't reload" } case "$1" in start) echo -n "Starting $DESC: $NAME" d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; test) d_test ;; reload) echo -n "Reloading $DESC configuration..." d_reload echo "reloaded." ;; restart) echo -n "Restarting $DESC: $NAME" d_stop # One second might not be time enough for a daemon to stop, # if this happens, d_start will fail (and dpkg will break if # the package is being upgraded). Change the timeout if needed # be, or change d_stop to have start-stop-daemon use --retry. # Notice that using --retry slows down the shutdown process somewhat. sleep 1 d_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac exit 0
添加执行权限
chmod +x /etc/init.d/nginx
添加服务
chkconfig --add nginx chkconfig nginx on
启动/停止服务
service nginx start/stop
8. 启动失败
如下
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
查看端口占用情况
netstat -ntpl
结束占用端口的进程,重新启动nginx
相关推荐
2) Nginx配置 - 1 - a)对c:\nginx\conf\nginx.conf文件进行配置: - 1 - b)常用的 Nginx 参数 - 3 - c)静态文件处理 - 4 - d)动态页面请求处理 - 4 - e)下面为nginx.conf配置实例: - 5 - f)Nginx 启动,停止等命令 ...
提供nginx的安装配置,根据这就可傻瓜式安装配置。http节点下的upstream表示负载均衡,圆圈中的为前置机地址,提供给医院访问,方框中地址为服务端实际部署的地址(端口需一致,如果只有一个端口则只需要一个listen...
nginx安装配置全攻略:都是实际安装配置经验,傻瓜式步骤
nginx 安装 配置 明细文档
centos 6 nginx 安装配置手册,最适合新手的安装配置教程,从0开始。
linuxnginx安装配置文件支持php.pdf
Nginx安装配置1.源码安装上传openssl-1.0.1s.tar.gz、pcre-8.38.tar.bz2、ngx_cache_purge-2.3.tar
Linux nginx安装配置步骤.txt
linux系统下的nginx安装配置文档,nginx主要用于web服务器的负载均衡及流量代理,提高系统的安全性和稳定性。
Linux环境下nginx安装配置.docx
「linux命令大全Nginx安装配置」.docx
CentOS6环境FastDFS+Nginx安装配置笔记.pdf
Nginx安装配置PageSpeed模块实现网站加速.docx
linux下安装nginx被配置sticky模块的相关软件包,包含nginx.conf的简单实例
nginx安装、不同配置含义、常用命令、安全等方面的介绍
nginx安装、配置、负载均衡.ppt