设置tomcat开机自启
找到/etc/rc.d/文件下的rc.local,添加如下内容
export JAVA_HOME=/usr/local/jdk1.8.0_144
export JRE_HOME=$JAVA_HOME/jre
sh /usr/local/tomcat1-8080/bin/startup.sh
sh /usr/local/tomcat2-8081/bin/startup.sh
sh /usr/tomcat/apache-tomcat-9.0.0.M1-80/bin/startup.sh这条命令是启动命令,可以配置多条。
给rc.local文件添加执行权限
chmod +x rc.local
重启服务器
reboot
然后在浏览器访问
运行.sh文件的方法
linux下运行.sh文件的方法,有两种:
直接./加上文件名.sh,如运行hello.sh为./hello.sh(hello.sh必须有x权限)
直接sh加上文件名.sh,如运行hello.sh为sh hello.sh(hello.sh可以没有x权限)
Linux下Mysql自启动
如果你都是按照默认配置安装的那么只要按照如下步骤就可以了
1、cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 将服务文件拷贝到init.d下,并重命名为mysql
2、chmod +x /etc/init.d/mysql 赋予可执行权限
3、chkconfig --add mysql 添加服务
4、chkconfig --list 显示服务列表
如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则键入
chkconfig --level 345 mysql on
5、reboot重启电脑
6、netstat -na | grep 3306,如果看到有监听说明服务启动了