到http://nginx.org/下载nginx
yum -y install openssl openssl-devel
yum -y install pcre-devel
tar -xzvf Nignx-0.8.31.tar.gz
./configure --prefix=/usr/local/nginx
make
make install
启动
/user/local/nginx/sbin/nginx
重启
/user/local/nginx/sbin/nginx -s reload
停止
/user/local/nginx/sbin/nginx -s stop
停止
ps -ef | grep nginx
强制停止Nginx
pkill -9 nginx
vi nginx.conf 末尾加上,最后一个大括号前加
#}
include vhost/*.conf;
}
[root@localhost conf]# mkdir vhost
[root@localhost conf]# vi younila.conf
# demo site
server {
listen 80;
server_name www.younila.com;
set $htdocs /webapps/younila/;
root $htdocs;
location / {
index index.html index.htm index.action;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js|html)$ {
expires 30d;
}
location ~*\.(jsp|do|action)$
{
index index.jsp;
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~^/(WEB-INF)/{
deny all;
}
}
tomcat server.xml 加入
<Context path="" docBase="/webapps/younila" crossContext="true" debug="0" reloadable="true"/>