nginx是一個反向 Proxy伺服器,它可以代理php,同樣也可以代理tomcat
首先,你要安裝好nginx,jdk,tomcat
tomcat的安裝很簡單,解壓出來就可以運行了。
然後進入ngxin設定檔所在目錄,我的是在/usr/local/nginx/conf
建立一個設定檔,盡量避免修改原來的設定檔,在開啟的時候使用我們建立的設定檔即可
vim jsp.conf
內容如下:
user nobody;worker_processes 4;events{ worker_connections 1024;}http{ server { listen 80; server_name localhost; location ~ \.jsp$ { root /usr/local/tomcat/webapps; indexindex.jsp; proxy_pass http://localhost:8080; } }}
以上配置表示,監聽80連接埠,所有以.jsp結尾的地址都轉寄給localhost:8080,也就是tomcat。工程目錄部署在/usr/local/tomcat/webapps下
然後啟動tomcat
cd /usr/local/tomcat/bin./startup.sh
啟動ngxin,使用我們剛剛建立的設定檔
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/jsp.conf
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介紹了Linux筆記(65)——nginx代理tomcat,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。