---
title: "nginx tomcat 配置"
author: "ileson"
date: "2014-09-16T19:40:53Z"
tags: []
categories: ["企业架构"]
slug: "nginx-tomcat"
draft: false
lastmod: "2014-12-08T16:50:24Z"
id: 2117159
url: "https://ileson.iteye.com/blog/2117159"
---

nginx : 取代apache 

一、linux 安装：[官方网站说明](http://nginx.org/en/linux_packages.html)
0、[官方下载](http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm)rpm包到/usr/local/src/ 下
   
```shell
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
```

  我用的是centos6.x
 

1、安装官方提供的对应版本的rpm包(我用的是centos6.x)

```shell
rpm -Uvh  nginx-release-centos-6-0.el6.ngx.noarch.rpm
```
  
执行这句的结果是：在/etc/yum.repo.d/ 下面 生成了一个源: nginx.repo  
 
2、然后执行安装nginx

```shell
yum install nginx
```

安装后，配置文件位置： /etc/nginx/nginx.conf 
文件内容最下面有一句：include /etc/nginx/conf.d/*.conf;
意思是：包含conf.d 目录下面的所有后缀是.conf 的文件。
 
3、启动nginx 
   安装好后，执行:
```shell
chkconfig |grep nginx
```
 
   会显示有服务了
    nginx     0:off   1:off   2:on    3:on    4:on    5:on    6:off
   
   这时：
```shell
service nginx status
```

   查看nginx 服务是否启动。若没有启动则启动
```shell
service nginx start
```


4、测试是否正常：http://localhost 
   出现：Welcome to nginx! 说明安装成功。


二、配置
   
![](http://dl2.iteye.com/upload/attachment/0101/5445/58acf5d8-2b26-31db-ac45-3476744435a3.png)




[windows 下的nginx 与tomcat 配合提供服务](http://cxshun.iteye.com/blog/1535188)


过程中碰到的问题：
1、yum update 时，报安装内核时boot 内存不足。
   Transaction Check Error:
  installing package kernel-2.6.32-131.2.1.el6.x86_64 needs 8MB on the /boot filesystem
Error Summary
-------------
Disk Requirements:
  At least 8MB more space needed on the /boot filesystem.

解决办法:[参考这个](http://www.cyberciti.biz/faq/installing-kernel-2-6-32-131-2-1-el6-x86_64-needs-8mb-on-boot-filesystem/)

2、windows nginx 配置中遇到的细节。
   include vhost/*.conf;  #首先别忘记后面的分号(;) 其次nginx 的目录结构为：  
![](http://dl2.iteye.com/upload/attachment/0101/6675/70508814-4507-349e-8c36-f51c68b26a0d.png)

这样可以将虚拟机配置文件（也就是server 部分）单独放到vhost目录中。

3、小脚本.bat

```CMD
@echo off	 
::定义nginx 文件所在目录 的变量 curdir 	
set "curdir=D:\Server\nginx-1.6.2\" 
::进行入到指定目录
cd /d %curdir% 
::启动nginx
start nginx
```



```CMD
@echo off	   	
set "dir_1=D:\Server\nginx-1.6.2" 

::进行入到指定目录
cd /d %dir_1%   

::执行退出命令  	
%dir_1%\nginx -s quit

::暂停
::pause	
```
		

引入其它[配置博文](http://freeloda.blog.51cto.com/2033581/1288553)

4、今天遇到了,session 的[这个问题](http://www.oschina.net/question/93241_10926)

5、更改Tomcat startup.bat启动窗口名称
   找到catalina.bat   查找“TITLE”　附近有个“Tomcat” 的你改成你想显示的字符串。每个版本不一样。多尝试。