1: Overview of the JSP development environment under nginx
If you want to use JSP technology in the nginx server, you must build a JSP development environment in the nginx server
2: JDK installation
JDK — that is, javaSDK, JDK is the core of java, Including java runtime environment and java tools
, java basic class library, etc. Therefore, before setting up a JSP development environment, you must install JDK
Go to the official website to download jdk, unzip and install.
Move to the /usr/local/ directory
<code>mv jdk1.<span>7.0_79</span>/ <span>/usr/local</span></code>
Rename the folder:
<code>mv jdk1.7.0_79/ jdk</code>
3.3: Configure environment variables:
<code>vim /etc/profile</code>
Go to the end of the file:
<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>
Let the configuration take effect immediately:
<code><span>source</span> /etc/profile</code>
Verify whether jdk is installed Success:
<code>Java –<span>version</span></code>
3: Tomcat installation
Go to the official website to download
Unzip and install
Configure tomcat into /etc/profile:
CATALINA_HOME=”/usr/local/tomcat”
4: tomcat+nginx configuration
<code>安装好JDK和tomcat后,要把tomcat和nginx服务器之间建立关联, </code>
This will enable tomcat to be used in the nginx server.
Create jsp.conf in the /usr/local/nginx/conf/ directory
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>
Create test.jsp under tomcat’s ROOT and enter the content test a.jsp
Start tomcat
Start nginx
<code>/usr/<span>local</span>/nginx/sbin/nginx <span>-c</span> /usr/<span>local</span>/nginx/conf/jsp<span>.</span>conf</code>
When accessing http://192.168.1.102:90/test.jsp at this time, the tomcat server will process and parse the test.jsp page and return it to the client.
The above introduces the establishment of JSP development environment under nginx, including jsp development and nginx content. I hope it will be helpful to friends who are interested in PHP tutorials.