创建服务脚本
在linux系统的/etc/init.d/目录下创建nexus文件的链接,使用如下命令:
ln -s /usr/local/nexus/nexus-2.14.3-02/bin/nexus /etc/init.d/nexus
然后,就可以通过该脚本对服务进行管理了:
/etc/init.d/nexus start
/etc/init.d/nexus stop
服务启动问题解决
1、 用户不能为root,需要找到nexus2.x/bin/nexus,修改内容#RUN_AS_USER=
为:RUN_AS_USER=root
2、nexus启动失败,查找nexus2.x/logs/wrapper.logs,发现如下错误:
--> Wrapper Started as Daemon
wrapper | Launching a JVM...
wrapper | Unable to start JVM: No such file or directory (2)
wrapper | JVM exited while loading the application.
需找到nexus2.x/bin/jsw/conf/wrapper.conf 第15行 wrapper.java.command=java 修改为
wrapper.java.command=/opt/Java/jdk1.7.0_76/bin/java
注意,修改端口的 配置文件在nexus2.x/conf/nexus.properties下面
注册为自启动服务
上面的方法完成了用脚本管理nginx服务的功能,但是还是不太方便,比如要设置nginx开机启动等。这时可以使用chkconfig来设置。
先将nginx服务加入chkconfig管理列表:
chkconfig --add /etc/init.d/nexus
加完这个之后,就可以使用service对nexus进行启动,重启等操作了。
service nexus start
service nexus stop
设置终端模式开机启动:
chkconfig --level 35 nexus on