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