| 1 | |
| 2 | = 將 tomcat port 開在 80 = |
| 3 | |
| 4 | 以 crawlzilla 為例 |
| 5 | |
| 6 | * 先安裝 jsvc |
| 7 | |
| 8 | {{{ |
| 9 | sudo apt-get install jsvc |
| 10 | }}} |
| 11 | |
| 12 | * 修改 server.xml 讓 tomcat 運行於 80 port |
| 13 | |
| 14 | vim /opt/crawlzilla/tomcat/conf/server.xml |
| 15 | |
| 16 | {{{ |
| 17 | #!text |
| 18 | <Connector port="80" protocol="HTTP/1.1" |
| 19 | connectionTimeout="20000" |
| 20 | redirectPort="8443" URIEncoding="UTF-8" |
| 21 | useBodyEncodingForURI="true" /> |
| 22 | }}} |
| 23 | |
| 24 | * 修改 sudoers 讓 crawler 可以執行 jsvc |
| 25 | |
| 26 | sudo vim /etc/sudoers |
| 27 | |
| 28 | {{{ |
| 29 | #!text |
| 30 | crawler ALL=NOPASSWD: /opt/crawlzilla/tomcat/bin/startup.sh /opt/crawlzilla/tomcat/bin/shutdown.sh |
| 31 | }}} |
| 32 | |
| 33 | |
| 34 | * 註解掉原本的呼叫方式(最後一行),並再最後面加入兩行用jsvc 驅動的方式 |
| 35 | |
| 36 | sudo vim /opt/crawlzilla/tomcat/bin/startup.sh |
| 37 | |
| 38 | {{{ |
| 39 | #!text |
| 40 | |
| 41 | #exec "$PRGDIR"/"$EXECUTABLE" start "$@" |
| 42 | |
| 43 | cd /opt/crawlzilla/tomcat |
| 44 | |
| 45 | sudo /usr/bin/jsvc -home /usr/lib/jvm/java-6-sun -user crawler -pidfile /var/log/crawlzilla/jsvc.pid -cp /opt/crawlzilla/tomcat/bin/bootstrap.jar -outfile /var/log/crawlzilla/jsvc.tomcat.out -errfile /var/log/crawlzilla/jsvc.tomcat.err org.apache.catalina.startup.Bootstrap |
| 46 | }}} |
| 47 | |
| 48 | 因此,之後呼叫 /opt/crawlzilla/tomcat/bin/startup.sh 前面都要加 sudo |
| 49 | |
| 50 | * 關閉 tomcat |
| 51 | |
| 52 | sudo vim /opt/crawlzilla/tomcat/bin/shutdown.sh |
| 53 | |
| 54 | {{{ |
| 55 | #!text |
| 56 | if [ -e /var/log/crawlzilla/jsvc.pid ];then |
| 57 | PID=$(cat /var/log/crawlzilla/jsvc.pid) |
| 58 | kill $PID |
| 59 | fi |
| 60 | }}} |
| 61 | |
| 62 | * vim /opt/crawlzilla/main/tomcat_restart.sh |
| 63 | |
| 64 | {{{ |
| 65 | #!text |
| 66 | if [ $command == "start" ];then |
| 67 | sudo /opt/crawlzilla/tomcat/bin/startup.sh |
| 68 | debug_info "/opt/crawlzilla/tomcat/bin/startup.sh" |
| 69 | elif [ $command == "stop" ];then |
| 70 | sudo /opt/crawlzilla/tomcat/bin/shutdown.sh |
| 71 | debug_info "/opt/crawlzilla/tomcat/bin/shutdown.sh" |
| 72 | kill $tom_pids |
| 73 | debug_info "kill $tom_pids" |
| 74 | else |
| 75 | sudo /opt/crawlzilla/tomcat/bin/shutdown.sh |
| 76 | debug_info "/opt/crawlzilla/tomcat/bin/shutdown.sh" |
| 77 | kill $tom_pids |
| 78 | debug_info "kill $tom_pids" |
| 79 | sudo /opt/crawlzilla/tomcat/bin/startup.sh |
| 80 | debug_info "/opt/crawlzilla/tomcat/bin/startup.sh" |
| 81 | fi |
| 82 | }}} |