开机自启动,将要执行的语句写入/etc/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. # source /etc/environment
source /etc/profile
locale >> /home/cnic/locale.txt
/usr/tomcat/apache-tomcat-8.0./bin/startup.sh
echo "tomcat started--." exit

在/etc/profile中要有JAVA_HOME的设置,缺少必要的环境变量,是无法启动tomcat的。也可以环境变量的设置放在rc.local中而不用 source /etc/profile

JAVA_HOME=/usr/java/jdk1..0_79
...

为分析rc.local是否成功运行,可以在 /var/log/boot.log中查看开机启动时的输出信息。

如上设置后,开机启动了tomcat, 但页面上的中文全是乱码,在rc.local中加上语句

locale >> /home/cnic/locale.txt

让语言配置信息在开机时输出到文件中,可以看到开机时的locate输出:

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=

手动输入locate输出一下内容:

LANG=en_US.UTF-
LANGUAGE=
LC_CTYPE=en_US.UTF-
LC_NUMERIC=en_US.UTF-
LC_TIME=en_US.UTF-
LC_COLLATE=en_US.UTF-
LC_MONETARY=en_US.UTF-
LC_MESSAGES=en_US.UTF-
LC_PAPER=en_US.UTF-
LC_NAME=en_US.UTF-
LC_ADDRESS=en_US.UTF-
LC_TELEPHONE=en_US.UTF-
LC_MEASUREMENT=en_US.UTF-
LC_IDENTIFICATION=en_US.UTF-
LC_ALL=

可以看出在rc.local运行时,没有语言编码相关的设置,导致中文输出乱码。

如何在rc.local开机运行时设置LC_ALL等参数,未找到解决方法。

参照网上相关文献,在tomcat/bin/catalina.sh中添加以下语句:

...
export JAVA_OPTS="-Dfile.encoding=UTF-8 -Duser.language=en_US"
...

重新启动后,tomcat可开机启动,且中文显示正常。

最终的解决方案,不更改tomcat/bin/catalina.sh, 只在rc.local中多加几条语句。#!/bin/sh -e

#
# rc.local
# source /etc/profile
#source /etc/default/locale # 只写export或只写update-local都还是乱码,两个都写了才能正确显示中文,具体原因还是不清楚,但问题解决了。
export LANG="en_US.UTF-8"
export LANGUAGE="en_US:en_GB:en"
export LC_ALL="en_US.UTF-8"
update-locale LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8" LANGUAGE="en_US:en_GB:en"
/usr/tomcat/apache-tomcat-8.0./bin/startup.sh exit

系统环境为:ubuntu 14, 英文

ubuntu 14 中tomcat的开机启动设置的更多相关文章

  1. 服务器安装ubuntu 14.04 server,开机启动屏幕不停滚动错误WRITE SAME failed. Manually zeroing

    昨天给服务器上安装了一个Ubuntu-14.04-server系统,安装完成后系统可以正常启动,但屏幕上一直滚动着一个错误,sda1:WRITE SAME failed. Manually zeroi ...

  2. Tomcat开机启动设置

    omcat开机启动设置 1.修改/etc/rc.d/rc.local,使用vi /etc/rc.d/rc.local 命令2.在/etc/rc.d/rc.local文件最后添加下面两行脚本 expor ...

  3. Ubuntu 14 中给 APACHE2安装 SSL 模块 Enable SSL site on Ubuntu 14 LTS, Apache 2.4.7:

    Ubuntu 14 中给 APACHE2安装 SSL 模块 Enable SSL site on Ubuntu 14 LTS, Apache 2.4.7: 参考 http://blog.csdn.ne ...

  4. [ubuntu][deepin]系统增加自定义开机启动项

    [ubuntu][deepin]系统增加自定义开机启动项 进行配置 cd /etc/init.d/ ls vim myScript nginx实例 #! /bin/sh # chkconfig: # ...

  5. eclipse中tomcat能正常启动,在浏览器中不能打开问题

    问题原因:没有在eclipse中tomcat的server location设置到tomcat的安装目录. 解决办法:1.选择server点击右键,选择Open选项,然后在server locatio ...

  6. Ubuntu 14 中,SecureCRT、SecureFX个性化设置

    [SecureCRT 个性化设置] 打开设置路径:菜单栏 -> Opions -> Global Options -> General -> Default Session - ...

  7. [ 手记 ] 关于tomcat开机启动设置问题

    今天尝试将tomcat设置为开机启动,大家都知道只需要将启动脚本添加到/etc/rc.local下面开机就会自动执行. /usr/local/tomcat8./bin/startup.sh >& ...

  8. CenterOS中安装Redis及开机启动设置

    Redis安装 从官方下载最新Redis进行安装,官网地址:http://redis.io/download $ wget http://download.redis.io/releases/redi ...

  9. Win7 + Ubuntu 14.04 +tomcat + mysql 搭建测试环境手册

    一.Win7下做安装ubuntu 下载ununtu14.04和EasyBCD软件 Win7下要腾出一个盘来安装ubuntu.我是格式化掉F盘,然后回到桌面,右键点击计算机-->管理-->存 ...

随机推荐

  1. Ext.get Ext.getDom Ext.getCmp 的区别

    Html DOM     Ext Element   Component Component 最高层 Html DOM 最基础 Ext.getCmp  是  Ext.ComponentMgr.get ...

  2. Xcode Pod使用

    安装pod  略.. 打开终端 cd  项目路径  (可以在xocde里项目右键show in Finder  讲工程目录拖入终端) 回车 vim podfile 回车 输入 :wq 保存 建立pod ...

  3. asp.net Ajax和web services

    新建一个web服务 using System; using System.Collections.Generic; using System.Linq; using System.Web; using ...

  4. eclipse maven spring mvc el表达式无效

    http://www.myexception.cn/javascript/2031310.html

  5. ViewPager+Fragment实现页面的切换

    新知识,新摘要: 效果图:framgent导入包都是v4包下,谨慎导入错误! 首先设置viewPager布局: <?xml version="1.0" encoding=&q ...

  6. .net core 安装失败 的问题彻底解决

    解决方法: 已经整理好包:   https://pan.baidu.com/s/1dFuU80p 下载解压运行: DotNetCore.1.0.1-VS2015Tools.Preview2.0.2.e ...

  7. SQL Server查询结果插入表

    a) 插入新表 select * into newtable from table b) 插入已经存在的表 insert into table select * from table2 where.. ...

  8. CC1310电源管脚

    对于48pin脚的CC1310而言,属于电源类的管脚如下: 上述电源类管脚的关系如下: 1 VDDS类管脚 VDDS类管脚包括VDDS.VDDS2.VDDS3和VDDS_DCDC四个管脚.其中VDDS ...

  9. Git查看、删除、重命名远程分支和tag(转)

    转:http://zengrong.net/post/1746.htm 这篇文章记录我在使用git的过程中碰到远程分支和tag的相关内容,提纲: 查看远程分支 删除远程分支和tag 删除不存在对应远程 ...

  10. 06Java数组

    动手动脑: import java.io.*; public class QiPan { //定义一个二维数组来充当棋盘 private String[][] board; //定义棋盘的大小 pri ...