Setup Nexus Repository Manager

6 minute read

Install Nexus Repository Manager

Get all the files and edit the files. I’m sure you are smart enough to use the script! Edit the variables and follow the instructions. You can execute script commands seperately on your own.


  • Become familiar with the basic directory structure of a Nexus Repository Manager installation. You are encouraged to stick with the standard installation layout to make future upgrades as simple as possible.

You will have to determine your existing installation data directory location. Record this value for later use.

Download the Latest Installer Archive

Download the latest installer archive for your platform from the official downloads. Extract the newest downloaded distribution archive using the standard approach.

Preparing the new Install

Suppose 3.14.0-04 is the new version.

  • Move the downloaded zip to your desired directory. (Basic place is /usr/local)
sudo cp nexus-3.14.0-04-unix.tar.gz /usr/local
sudo tar xzvf nexus-3.14.0-01-unix.tar.gz
  • Compare the nexus-3.14.0-04/bin/nexus.vmoptions file with your existing version.

  • If you have changed the default location of the Data Directory, then edit ./bin/nexus.vmoptions and change the line to point to your existing data directory. Example:

  • If you changed the default location of the temporary directory, then edit ./bin/nexus.vmoptions and replace the line to point to your preferred temporary directory.

  • If you adjusted the default Java virtual machine max heap memory, then edit ./bin/nexus.vmoptions and edit the line -Xmx1200M accordingly.

  • If you have enabled jetty HTTPS access, make sure your etc/jetty/jetty-https.xml SSL keystore location is still available to the new install.

  • If you manually adjusted any other install files under ./etc you will need to manually perform a diff between the old files and the new files and apply your changes if applicable to the new version.

  • Perform the Upgrade.

  • Ensure you have taken recent backups of the existing Data Directory and any custom blobstore locations according to our recommended practices. Because of involved Upgrade steps, downgrading a NXRM version is not supported and will almost always result in failures.If you have issues, restore from this backup instead.

  • Stop your existing install using the scripts under ./bin or your operating system service. Make sure it stops completely.

sudo service nexus stop
./nexus/bin/nexus stop
  • Change owner of the new directory to the your desired user:
sudo chown user:user nexus-3.14.0-04/ -R
  • Remove previous soft links and create new one and update permissions of it:
sudo rm nexus
sudo ln -s /usr/local/nexus-3.14.0-04 /usr/local/nexus
sudo chown user:user nexus -R
  • If you have configure Nexus Service, update the service as well:
sudo update-rc.d nexus defaults
  • Update user in the file /usr/local/nexus/bin/nexus.rc
  • Start the new installation using the scripts under ./bin or adjust your operating system service to use these scripts.
./nexus start
sudo service nexus start
  • Review the log files for any possible issues and sign-in to the server to confirm things are working as expected.


  1. changeRepo script:

if [ -f ~/.m2/settings.xml ]
  if [ -f ~/.m2/settings.xml.orig ]
    mv ~/.m2/settings.xml ~/.m2/settings.xml.tmp
    mv ~/.m2/settings.xml.orig ~/.m2/settings.xml
    mv ~/.m2/settings.xml.tmp ~/.m2/settings.xml.orig
    # echo "settings.xml and settings.xml.orig replaced successfully!"
    if grep --quiet "nexus" ~/.m2/settings.xml ; then
      echo "Maven is behind nexus!"
      echo "Maven isn't behind nexus!"
    echo "settings.xml.orig doesn't exist!"
  echo "settings.xml doesn't exist!"

exit 0
  1. script:

# install 

# change the user to your preferred user
# This file should be next to this script

confirm () {
    # call with a prompt string or use a default
    read -r -p "${1:-Are you sure? [y/N]} " response
    case $response in

sudo cp $changeRepo /usr/bin/
sudo cp settings.xml.orig /home/$myUser/.m2

sudo cp $nexusTarGz /usr/local
cd /usr/local
sudo tar xzf $nexusTarGz
sudo rm $nexusTarGz
sudo ln -s /usr/local/$nexusVer /usr/local/nexus
sudo chown $myUser:$myUser nexus -R
sudo chown $myUser:$myUser $nexusVer -R
sudo chown $myUser:$myUser sonatype-work/ -R

echo "export NEXUS_HOME=\"/usr/local/nexus\"" | tee -a /home/$myUser/.bashrc
source /home/$myUser/.bashrc


echo "Set this variable in $NEXUS_HOME/bin/nexus"
echo "INSTALL4J_JAVA_HOME_OVERRIDE=/usr/lib/jvm/java-8-oracle"

confirm "Do you want to viw nexus file now?(y/n recommended yes)" && sudo vim /usr/local/nexus/bin/nexus

cd $NEXUS_HOME/bin
./nexus run | echo "Type ctrl+c to continue the installation!"

echo "run_as_user=\"$myUser\"" | sudo tee $NEXUS_HOME/bin/nexus.rc

sudo service nexus stop

sudo ln -s $NEXUS_HOME/bin/nexus /etc/init.d/nexus

cd /etc/init.d
sudo update-rc.d nexus defaults

sudo service nexus restart


echo "Installation finished! you can visit configuration UI at (defaults)localhost:8081."
echo "Also your settings.xml file updated in your home directory. to enable maven to nexus or not to use it, run changeRepo"
echo "Make sure to edit settings.xml and settings.xml.orig in the ~/.m2/ directory and put the correct values for <localrepository> and <url> vice versa."

  1. script:

sudo npm install -g bower-nexus3-resolver

# Edit file /home/user/.bowerrc and put these lines in it:
# {
#   "registry" : {
#     "search" : [ "" ]
#    },
#  "resolvers" : [ "bower-nexus3-resolver" ]
# }
  1. ConfigNPM script:

# nexus= IP of nexus 

npm config set registry http://$nexus:8081/repository/npm/

# to revert back, edit /home/user/.npmrc and delete registry line
  1. settings.xml
<settings xmlns=""
  1. settings.xml.orig
      <!--This sends everything else to /public -->
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
    <!--make the profile active all the time -->