Linux相關問題-Ubuntu 12.04下解決Tomcat自啓動問題

當我們安裝好Tomcat使用後發現,每次啓動都需要在終端中手動鍵入sudo /var/tomcat/bin/startup.sh,那麼我們怎麼解決這個問題呢

以下是我的解決方案:


1.首先打開終端,輸入su,接着輸入ROOT的密碼獲得ROOT權限。進入/etc文件夾(使用cd /etc命令)

2.打開rc.local文件(在/etc目錄下使用vi rc.local命令)

3.rc.local文件內容默認如下

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/var/tomcat/bin/startup.sh


exit 0 


4.紅色內容爲我們手動添加的內容,這裏指的是tomcat啓動項,那麼如何更改呢,首先鍵入A 進入INSERT模式,移動光標到紅色位置輸入準確路徑,按ESC退出INSERT模式,光標移動到行尾,鍵入:wq保存文件


至此,我們已經解決這個問題,重啓Ubuntu我們發現已經可以自動訪問Tomcat下的內容了



發佈了44 篇原創文章 · 獲贊 8 · 訪問量 38萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章