當(dāng)我們安裝好Tomcat使用后發(fā)現(xiàn),每次啟動都需要在終端中手動鍵入sudo /var/tomcat/bin/startup.sh,那么我們怎么解決這個問題呢
以下是我的解決方案:
1.首先打開終端,輸入su,接著輸入ROOT的密碼獲得ROOT權(quán)限。進入/etc文件夾(使用cd /etc命令)
2.打開rc.local文件(在/etc目錄下使用vi rc.local命令)
3.rc.local文件內(nèi)容默認如下
#!/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.紅色內(nèi)容為我們手動添加的內(nèi)容,這里指的是tomcat啟動項,那么如何更改呢,首先鍵入A 進入INSERT模式,移動光標(biāo)到紅色位置輸入準(zhǔn)確路徑,按ESC退出INSERT模式,光標(biāo)移動到行尾,鍵入:wq保存文件
至此,我們已經(jīng)解決這個問題,重啟Ubuntu我們發(fā)現(xiàn)已經(jīng)可以自動訪問Tomcat下的內(nèi)容了