1:nginx下JSP開發環境概述
如果想在nginx伺服器中使用JSP技術,要在nginx伺服器中搭建JSP開發環境
2:JDK的安裝
JDK — 即javaSDK,JDK是java的核心,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>
讓設定立即生效:
re成功:<code><span>source</span> /etc/profile</code>
解壓縮即安裝
將tomcat配置到/etc/profile中:
CATALINA_HOME=”/usr/local/tomcat”
<code>Java –<span>version</span></code>
在/usr/local/nginx/conf/目錄下建立jsp.conf
jsp.conf:
<code>安装好JDK和tomcat后,要把tomcat和nginx服务器之间建立关联, </code>
啟動tomcat
<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>