Repository Management with Nexus
When installing Nexus for production usage you should configure Nexus as a service, so it starts back up after server reboots. It is good practice to run that service or daemon as a specific user that has only the required access righs. The following sections provide instructions for configuring Nexus as a service or daemon on various operating systems.
You can configure Nexus to start automatically by copying the
script to the
/etc/init.d directory. On a Linux system
perform the following operations as the root user:
nexususer with sufficient access rights to run the service
/etc/init.d/nexusor create a symlink
/etc/init.d/nexusscript executable -
chmod 755 /etc/init.d/nexus
Edit this script changing the following variables:
NEXUS_HOMEto the absolute folder location (e.g.,
nexusor any other user with restricted rights that you want to use to run the service. You should not be running Nexus as root.
PIDDIRto a directory where this user has read/write permissions. In most Linux distributions,
/var/runis only writable by root. The property you need to add to customize the PID file location is
wrapper.pid. For more information about this property and how it would be configured in wrapper.conf, see: http://wrapper.tanukisoftware.com/doc/english/properties.html.
Change the owner and group of your Nexus-related directories,
sonatype-work/nexus, to the
nexususer that will run the application.
If Java is not on the default path for the user running Nexus, add
JAVA_HOMEvariable which points to your local Java installation and add a
While not recommended, it is possible to run Nexus as root
user by setting
This 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
chkconfig manages the
symbolic links in
/etc/rc[0-6].d which control the services to be
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.
The process for setting up Nexus as a service on Ubuntu differs
slightly from the process used on a Red Hat variant. Instead of running
chkconfig, you should run the following sequence of commands once
you’ve configured the startup script in
$ cd /etc/init.d $ update-rc.d nexus defaults $ service nexus start Starting Sonatype Nexus... $ tail -f /usr/local/nexus/logs/wrapper.log
The standard way to run a service on Mac OS X is by using
which uses plist files for configuration. An example plist file for
Nexus is shown A sample com.sonatype.nexus.plist file.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.sonatype.nexus</string> <key>ProgramArguments</key> <array> <string>/usr/local/nexus/bin/nexus</string> <string>console</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
After saving the file as
/Library/LaunchDaemons/ you have to change the ownership and access
sudo chown root:wheel /Library/LaunchDaemons/com.sonatype.nexus.plist sudo chmod 644 /Library/LaunchDaemons/com.sonatype.nexus.plist
Consider setting up a different user to run Nexus and adapt permissions and the RUN_AS_USER setting in the nexus startup script.
With this setup Nexus will start as a service at boot time. To manually start it after the configuration you can use
sudo launchctl load /Library/LaunchDaemons/com.sonatype.nexus.plist
The startup script for Nexus on Windows platforms is
bin/nexus.bat. Besides the standard commands for starting and
stopping the service, it has the additional commands
uninstall. Running these commands with elevated privileges will set
up the service for you or remove it as desired. Once installed as a
service with the
install command, the batch file can be used to start
and stop the service. In addition, the service will be available in the
usual Windows service management console as a service named nexus.