On boot, the statement that will be executed is written to/etc/rc.local.
#!/bin/SH-e## rc.local## This script was executed at the end of all multiuser runlevel.# make sure that the script would"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.# source/etc/Environmentsource/etc/Profilelocale>>/home/cnic/locale. txt/usr/tomcat/apache-tomcat-8.0. -/bin/startup.SHEcho "Tomcat started--."Exit0
If you do not add/etc/profile, you will not be able to start Tomcat without the necessary environment variables.
To analyze whether the rc.local is running successfully, you can view the output information at boot-up in/var/log/boot.log.
As set up, the boot started Tomcat, but the page of Chinese is all garbled, in the rc.local add the statement
Locale >>/home/cnic/locale.txt
Let the language configuration information output to the file at boot, you can see the locate output at boot:
lang=LANGUAGE=lc_ctype="POSIX"lc_numeric="POSIX"Lc_time="POSIX"lc_collate="POSIX"lc_monetary="POSIX"lc_messages="POSIX"Lc_paper="POSIX"Lc_name="POSIX"lc_address="POSIX"Lc_telephone="POSIX"lc_measurement="POSIX"lc_identification="POSIX"Lc_all=
Manually enter locate to output the content:
Lang=en_us. utf-8LANGUAGE=lc_ctype=en_us. utf-8lc_numeric=en_us. utf-8Lc_time=en_us. utf-8lc_collate=en_us. utf-8lc_monetary=en_us. utf-8lc_messages=en_us. utf-8Lc_paper=en_us. utf-8Lc_name=en_us. utf-8lc_address=en_us. utf-8Lc_telephone=en_us. utf-8lc_measurement=en_us. utf-8lc_identification=en_us. utf-8Lc_all=
Can be seen in the rc.local run, there is no language encoding related settings, resulting in Chinese output garbled.
How to set parameters such as Lc_all when the rc.local is running, no workaround is found.
Refer to the relevant literature on the Internet to add the following statement in tomcat/bin/catalina.sh:
... export java_opts="-dfile.encoding=utf-8-duser.language=en_us"...
After restarting, Tomcat boots up and the Chinese display is normal.
The system environment is: Ubuntu 14, English
Boot startup settings for Tomcat in Ubuntu 14