在一个tomcat下配置多个项目的时候,如果你有定时任务,且有多个host存在
大家都访问的是同意webapps,会导致定时任务多次启动
解决方案就是把tomcat拆开,需要用到ngxin
先说几个常用的路径与命令
nginx访问日志的默认路径
/var/log/nginx
默认配置文件,在没有nginx.conf的时候使用的是/etc/nginx/conf.d/default.conf
配置demo
#
# The default server
#
server {
listen 80;
server_name 域名1;
location / {
proxy_pass http://127.0.0.1:7070;
}
root /usr/share/nginx/html;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 80;
server_name 域名2;
location / {
proxy_pass http://127.0.0.1:8080;
}
root /usr/share/nginx/html;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
之后启动提示sccess说明成功。
安装命令yum install nginx会根据你的linux版本去安装。
测试
/usr/sbin/nginx -t
启动
/usr/sbin/nginx
重启
/usr/sbin/nginx -s reload\
结束
ps -ef |grep nginx 或者netstat -tunpl | grep 80 一般都是占用80端口
kill -s 9 nginx的pid即可