Difference between revisions of "Nexus"

(Created page with "Category:Development Category:Linux This page explains how to setup and configure NEXUS Maven repositories. =Requirements= a) You need to setup Maven b) You need...")
 
 
(7 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
 
This page explains how to setup and configure NEXUS Maven repositories.
 
This page explains how to setup and configure NEXUS Maven repositories.
 +
 +
For Nexus clients see [[Nexus Maven configuration]]
 +
  
  
Line 10: Line 13:
  
  
b) You need to create a root folder to host all the artifacts
+
 
 +
=Installation=
 +
 
 +
 
 +
==Create user / group==
 +
 
 +
<syntaxhighlight lang="bash">
 +
# Create group
 +
addgroup --system "nexus"
 +
 +
# Create Nexus user (home directory must be Nexus)
 +
adduser --home /opt/nexus --disabled-login --disabled-password nexus
 +
</syntaxhighlight>
 +
 
 +
 
 +
==Prepare work folder==
 +
 
 +
You need to create a root folder to host all the artifacts. !!! This will be bigger and bigger over time !!!
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
mkdir -p /home/nexus
 
mkdir -p /home/nexus
 
chmod -R 777 /home/nexus
 
chmod -R 777 /home/nexus
 +
chown -R nexus:nexus /home/nexus
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
 
+
==Get binaries==
=Installation=
 
  
 
Download '''Nexus OSS''' as ''Nexus Open-Source Server'' - take the ZIP format
 
Download '''Nexus OSS''' as ''Nexus Open-Source Server'' - take the ZIP format
Line 33: Line 53:
  
  
=Configuration=
+
==Set rights==
 +
 
 +
<syntaxhighlight lang="bash">
 +
chown -R nexus:nexus /opt/nexus
 +
chown -R nexus:nexus /opt/nexus-2.11.4-01
 +
</syntaxhighlight>
 +
 
  
 
==Set nexus parameters==
 
==Set nexus parameters==
Line 47: Line 73:
 
<syntaxhighlight lang="apache">
 
<syntaxhighlight lang="apache">
 
application-port=9081
 
application-port=9081
 +
application-host=127.0.0.1
 
nexus-webapp-context-path=/nexus
 
nexus-webapp-context-path=/nexus
  
 
## Nexus section
 
## Nexus section
# nexus-work == folders where the artifacts are going to be saved. You must choose a folder with a lot of disk!
+
## nexus-work ==>> folders where the artifacts are going to be saved. You must choose a folder with a lot of disk!
nexus-work=${bundleBasedir}/../sonatype-work/nexus
+
nexus-work=/home/nexus
 
runtime=${bundleBasedir}/nexus/WEB-INF
 
runtime=${bundleBasedir}/nexus/WEB-INF
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
==Log symlink==
 +
 +
<syntaxhighlight lang="bash">
 +
ln -s /opt/nexus/logs/wrapper.log /var/log/nexus.log
 +
</syntaxhighlight>
 +
 +
 +
==Set Nexus user and rights==
 +
 +
<syntaxhighlight lang="bash">
 +
vim /opt/nexus/bin/nexus
 +
</syntaxhighlight>
 +
 +
 +
<syntaxhighlight lang="apache">
 +
# Set the correct home
 +
NEXUS_HOME="/opt/nexus"
 +
 +
#uncomment and adjust
 +
RUN_AS_USER="nexus"
 +
#The PID directory must be a directory where you the runtime user can Read/Write
 +
PIDDIR="/opt/nexus"
 +
</syntaxhighlight>
 +
 +
 +
==Start / stop server==
 +
 +
To start|stop the server:
 +
 +
<syntaxhighlight lang="bash">
 +
/opt/nexus/bin/nexus start
 +
</syntaxhighlight>
 +
 +
 +
 +
==ERROR Fix==
 +
 +
If you encounter the <code>Failed to start Nexus OSS</code> error, then you need to:
 +
 +
<syntaxhighlight lang="bash">
 +
chown -R nexus:nexus /opt/sonatype-work
 +
</syntaxhighlight>
 +
  
  
Line 67: Line 139:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
 +
==Start Nexus on boot==
 +
 +
 +
<syntaxhighlight lang="bash">
 +
vim /opt/nexus/bin/nexus
 +
</syntaxhighlight>
 +
 +
 +
Add the following declaration after the first line <code>#!/bin/sh</code> :
 +
 +
<syntaxhighlight lang="bash">
 +
### BEGIN INIT INFO
 +
# Provides:            Nexus
 +
# Required-Start:      $all
 +
# Required-Stop:
 +
# Default-Start:        2 3 4 5
 +
# Default-Stop:        0 1 6
 +
# Short-Description:    Nexus
 +
### END INIT INFO
 +
</syntaxhighlight>
 +
 +
 +
Register the program to the boot sequence:
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
NEXUS_HOME="/opt/nexus"
+
cd /etc/init.d/
 +
update-rc.d nexus defaults
 +
</syntaxhighlight>
 +
 
 +
 
 +
 
 +
 
 +
=Apache2 proxy=
 +
 
 +
Put the following lines into your Apache2 proxy configuration:
 +
 
 +
 
 +
<syntaxhighlight lang="apache">
 +
  ## Proxy to NEXUS
 +
  <Location /nexus/ >
 +
      ProxyPass http://localhost:9081/nexus/
 +
      ProxyPassReverse http://localhost:9081/nexus/
 +
      Require all granted
 +
      satisfy any
 +
  </Location>
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
 +
=Nexus server access=
 +
 +
You can access your server on http://myServer/nexus/  (Don't forget the end '/')
 +
 +
The default users and passwords are:
 +
 +
 +
{| class="wikitable"
 +
|-
 +
! login !! password
 +
|-
 +
| admin || admin123
 +
|-
 +
| deployment || deployment123
 +
|-
 +
| anonymous ||
 +
|}
 +
 +
 +
To change the password go to NEXUS > log-in > Security menu (left) > Users

Latest revision as of 10:53, 12 September 2015


This page explains how to setup and configure NEXUS Maven repositories.

For Nexus clients see Nexus Maven configuration


Requirements

a) You need to setup Maven


Installation

Create user / group

# Create group
addgroup --system "nexus"
 
# Create Nexus user (home directory must be Nexus)
adduser --home /opt/nexus --disabled-login --disabled-password nexus


Prepare work folder

You need to create a root folder to host all the artifacts. !!! This will be bigger and bigger over time !!!

mkdir -p /home/nexus
chmod -R 777 /home/nexus
chown -R nexus:nexus /home/nexus


Get binaries

Download Nexus OSS as Nexus Open-Source Server - take the ZIP format

cd /opt
wget http://www.sonatype.org/downloads/nexus-latest-bundle.tar.gz
tar xzvf nexus-latest-bundle.tar.gz
rm nexus-latest-bundle.tar.gz
ln -s /opt/nexus-2.11.4-01/ /opt/nexus


Set rights

chown -R nexus:nexus /opt/nexus
chown -R nexus:nexus /opt/nexus-2.11.4-01


Set nexus parameters

Adjust the port number and root context path, if required

vim /opt/nexus/conf/nexus.properties


Set:

application-port=9081
application-host=127.0.0.1
nexus-webapp-context-path=/nexus

## Nexus section
## nexus-work ==>> folders where the artifacts are going to be saved. You must choose a folder with a lot of disk!
nexus-work=/home/nexus
runtime=${bundleBasedir}/nexus/WEB-INF


Log symlink

ln -s /opt/nexus/logs/wrapper.log /var/log/nexus.log


Set Nexus user and rights

vim /opt/nexus/bin/nexus


# Set the correct home
NEXUS_HOME="/opt/nexus"

#uncomment and adjust
RUN_AS_USER="nexus"
#The PID directory must be a directory where you the runtime user can Read/Write
PIDDIR="/opt/nexus"


Start / stop server

To start|stop the server:

/opt/nexus/bin/nexus start


ERROR Fix

If you encounter the Failed to start Nexus OSS error, then you need to:

chown -R nexus:nexus /opt/sonatype-work


Run Nexus from anywhere

Set the NEXUS_HOME into the start script. Without it you cannot run Nexus as a service!

ln -s /opt/nexus/bin/nexus /usr/bin/nexus
ln -s /opt/nexus/bin/nexus /etc/init.d/nexus

vim /opt/nexus/bin/nexus


Start Nexus on boot

vim /opt/nexus/bin/nexus


Add the following declaration after the first line #!/bin/sh :

### BEGIN INIT INFO
# Provides:             Nexus
# Required-Start:       $all
# Required-Stop:
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Nexus
### END INIT INFO


Register the program to the boot sequence:

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



Apache2 proxy

Put the following lines into your Apache2 proxy configuration:


   ## Proxy to NEXUS
   <Location /nexus/ >
       ProxyPass http://localhost:9081/nexus/
       ProxyPassReverse http://localhost:9081/nexus/
       Require all granted
       satisfy any
   </Location>


Nexus server access

You can access your server on http://myServer/nexus/ (Don't forget the end '/')

The default users and passwords are:


login password
admin admin123
deployment deployment123
anonymous


To change the password go to NEXUS > log-in > Security menu (left) > Users