[toc]
Linux下安装Nginx
- image.png
-
安装依赖包
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel // 安装过程中,要选择:y yum install GeoIP gd libXpm libxslt // 安装gcc gcc-c++ yum -y install gcc gcc-c++ autoconf automake make
-
安装nginx
// 解压 tar -zxvf nginx-1.14.0.tar.gz cd nginx-1.14.0/ // 安装到/usr/local/nginx目录下 ./configure --prefix=/usr/local/nginx make make install
nginx常用命令
- 启动命令:
/usr/local/nginx/sbin/nginx
- 重启命令:
/usr/local/nginx/sbin/nginx -s reload
- 查看命令:
ps -ef | grep nginx
- 关闭命令:
kill -9 进程号
nginx常用配置
配置文件位置:/usr/local/nginx/conf/nginx.conf
Nginx初试Tomcat,部署Guns-admin
网上关于nginx的资料很零碎,我就想整个tomcat+nginx运行一下guns的项目而已,访问admin.idudiao.com后转到服务器上的
http://localhost:8080/guns-admin
上,无果,不是重定向次数过多,就是session失效。
最后,用了个折中的法子,访问admin.idudiao.com后转到服务器上的http://localhost:8080
-
部署guns-admin项目,同时修改项目发布路径为:''。 修改tomcat/conf/server.xml
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!--修改发布路径--> <Context path="" docBase="/tomcat-8.0.53-guns/webapps/guns-admin" debug="0" reloadable="true"/> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
参考:https://blog.csdn.net/u011042133/article/details/46349593
-
path
是虚拟路径; -
docBase
是应用程序的物理路径; -
debug
则是设定debug level, 0表示提供最少的信息,9表示提供最多的信息; -
reloadable
如果为true,则tomcat会自动检测应用程序的/WEB-INF/lib 和/WEB-INF/classes目录的变化,自动装载新的应用程序,可以在不重起
-
-
配置Nginx,修改
/usr/local/nginx/conf/nginx.conf
文件,在http{}模块下添加:http { ... #add by dudiao at 20180815 server { listen 80; server_name admin.idudiao.com; location / { proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~ .*\.(gif|jpg|jpeg|png|js|css)$ { root /tomcat-8.0.53-guns/webapps/guns-admin/; expires 1d; } } #add by dudiao end ... }
网友评论