1、修改配置文件,/usr/local/nexus-2.14.9-01/bin/jsw/conf
#开机没有环境变量,修改环境变量为绝对路径
# Set the JVM executable
# (modify this to absolute path if you need a Java that is not on the OS path)
#wrapper.java.command=java
wrapper.java.command=/java/jdk/jdk1.8/bin/java
2、在/etc/init.d/下创建nexus脚本
#!/bin/sh
#chkconfig:2345 20 90
#description:nexus
#processname:nexus
export JAVA_HOME=/java/jdk/jdk1.8
case $1 in
start) su root /usr/local/nexus-2.14.9-01/bin/nexus start;;
stop) su root /usr/local/nexus-2.14.9-01/bin/nexus stop;;
status) su root /usr/local/nexus-2.14.9-01/bin/nexus status;;
restart) su root /usr/local/nexus-2.14.9-01/bin/nexus restart;;
dump) su root /usr/local/nexus-2.14.9-01/bin/nexus dump ;;
console) su root /usr/local/nexus-2.14.9-01/bin/nexus console ;;
*) echo "require console | start | stop | restart | status | dump " ;;
esac
3、加上可执行权限
chmod +x nexus
4、加入开机自启服务
chkconfig --add nexus
5、检查是否已加入开机自启服务
[root@localhost init.d]# chkconfig --list
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nexus 0:off 1:off 2:on 3:on 4:on 5:on 6:off
redisd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6、然后就可以使用service nexus start 启动服务了