You can configure Nexus to start automatically, by copying the
app script to the /etc/init.d
directory. On a Linux system (tested with Redhat, Fedora, Ubuntu, or
CentOS) perform the following operations as the root user:
-
Copy either
${NEXUS_HOME}/bin/jsw/linux-ppc-64/nexus,${NEXUS_HOME}/bin/jsw/linux-x86-32/nexus, or${NEXUS_HOME}/bin/jsw/linux-x86-64/nexusto/etc/init.d/nexus. -
Make the
/etc/init.d/nexusscript executable - chmod 755 /etc/init.d/nexus -
Edit this script changing the following variables:
-
Change
APP_NAMEto "nexus" -
Change
APP_LONG_NAMEto "Sonatype Nexus" -
Add a variable
NEXUS_HOMEwhich points to your Nexus installation directory -
Add a variable
PLATFORMwhich contains eitherlinux-x86-32,linux-x86-64, orlinux-ppc-64 -
Change
WRAPPER_CMDto${NEXUS_HOME}/bin/jsw/${PLATFORM}/wrapper -
Change
WRAPPER_CONFto${NEXUS_HOME}/conf/wrapper.conf -
Change
PIDDIRto/var/run. -
Add a
JAVA_HOMEvariable which points to your local Java installation -
Add a
${JAVA_HOME}/binto thePATH
-
-
(Optional) Set the RUN_AS_USER to "nexus". If you do this, you will need to:
-
Create a nexus user
-
Change the Owner and Group of your nexus install directory to nexus
-
At the end of this you should have a file in
/etc/init.d/nexus which starts with a series of
configuration properties which look something like this (assuming that
you've installed Nexus in /usr/local/nexus and that
you have Java installed in /usr/java/latest):
JAVA_HOME=/usr/java/latest
PATH=${PATH}:${JAVA_HOME}/bin
APP_NAME="nexus"
APP_LONG_NAME="Sonatype Nexus"
NEXUS_HOME=/usr/local/nexus
PLATFORM=linux-x86-64
WRAPPER_CMD="${NEXUS_HOME}/bin/jsw/${PLATFORM}/wrapper"
WRAPPER_CONF="${NEXUS_HOME}/conf/wrapper.conf"
PRIORITY=
PIDDIR="/var/run"
#RUN_AS_USER=nexusThis script has the appropriate chkconfig directives, so all you need to do to add Nexus as a service is run the following commands:
$ cd /etc/init.d $ chkconfig --add nexus $ chkconfig --levels 345 nexus on $ service nexus start Starting Sonatype Nexus... $ tail -f /usr/local/nexus/logs/wrapper.log
The second command adds nexus as a service to be started and
stopped with the service command and managed by
chkconfig command. chkconfig
manages the symbolic links in /etc/rc[0-6].d which
control the services which are started and stopped when the operating
system restarts or transitions between run-levels. The third command
adds nexus to run-levels 3, 4, and 5. The service command starts Nexus,
and the last command tails the wrapper.log to
verify that Nexus has been started successfully. If Nexus has started
successfully you should see a message notifying you that Nexus is
listening for HTTP connections on a port.
The process for setting Nexus up as a service on Ubuntu differs
slightly from the process used on a Redhat variant. Instead of running
chkconfig, you should run the following sequence of commands once you've
configured the startup script in
/etc/init.d:
$ cd /etc/init.d $ update-rc.d nexus defaults $ service nexus start Starting Sonatype Nexus... $ tail -f /usr/local/nexus/logs/wrapper.log
