Rumah >pembangunan bahagian belakang >tutorial php >nginx下JSP开发环境搭建 jsp开发框架 jsp开发软件 jsp标签开
1:nginx下JSP开发环境概述
如果想在nginx服务器中使用JSP技术,要在nginx服务器中搭建JSP开发环境
2:JDK的安装
JDK — 即javaSDK,JDK是java的核心,包括java运行环境、java工具
、java基础类库等。所以搭建JSP开发环境前,要安装JDK
到官网下载jdk,解压即安装。
移动到/usr/local/目录下即可
<code>mv jdk1.<span>7.0_79</span>/ <span>/usr/local</span></code>
重命名文件夹:
<code>mv jdk1.7.0_79/ jdk</code>
3.3: 配置环境变量:
<code>vim /etc/profile</code>
到文件最后:
<code>JAVA_HOME=”/usr/<span>local</span>/jdk” CLASS_PATH=”<span>$JAVA_HOME</span>/lib:<span>$JAVA_HOME</span>/jre/lib” PATH=”.:<span>$PATH</span>:<span>$JAVA_HOME</span>/bin” CATALINA_HOME=”/usr/<span>local</span>/tomcat” Export JAVA_HOME CATALINA_HOME</code>
让配置立即生效:
<code><span>source</span> /etc/profile</code>
验证jdk是否安装成功:
<code>Java –<span>version</span></code>
3:tomcat的安装
到官网下载
解压即安装
将tomcat配置到/etc/profile中:
CATALINA_HOME=”/usr/local/tomcat”
4:tomcat+nginx配置
<code>安装好JDK和tomcat后,要把tomcat和nginx服务器之间建立关联, </code>
这样才能使tomcat能够在nginx服务器中使用。
在/usr/local/nginx/conf/目录下建立jsp.conf
jsp.conf:
<code>User nobody; Worker_processes <span>4</span>; Events { Worker_connections <span>1024</span>; } http { server { listen <span>90</span>; server_name <span>127.0</span><span>.0</span><span>.1</span>; access_log logs/server1<span>.</span>access<span>.</span><span>log</span> combined; location ~ <span>\</span><span>.</span>(jsp<span>|</span>jspx<span>|</span><span>do</span>)<span>?</span>$ { root /data0/www; index index<span>.</span>jsp index<span>.</span>jspx index<span>.</span><span>do</span>; proxy_set_header X<span>-Forworded</span><span>-Host</span><span>$host</span>; proxy_set_header X<span>-Forwarded</span><span>-Server</span><span>$host</span>; proxy_set_header X<span>-Forwarded</span><span>-For</span><span>$proxy_add_x_forwarded_for</span>; proxy_pass http:<span>//localhost:8080;</span> } } } </code>
在tomcat的ROOT下建立test.jsp并输入内容test a.jsp
启动tomcat
启动nginx
<code>/usr/<span>local</span>/nginx/sbin/nginx <span>-c</span> /usr/<span>local</span>/nginx/conf/jsp<span>.</span>conf</code>
此时访问http://192.168.1.102:90/test.jsp时,会由tomcat服务器进行处理解析test.jsp页面并返回到客户端。
以上就介绍了nginx下JSP开发环境搭建,包括了jsp开发,nginx方面的内容,希望对PHP教程有兴趣的朋友有所帮助。