在linux服务器上用nexus安装maven私服

本文详细指导如何在Linux服务器上安装Nexus并配置为Maven私有仓库,包括上传Nexus、解压、权限调整、端口修改及安全设置,确保Maven私服顺利运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在linux服务器上用nexus安装maven私服

1.上传或者下载nexus到linux服务器

2.在linux服务器上新建nuxes目录,并移动到nuxes目录下

[root@Jenkins ~]# cd /usr/local/
[root@Jenkins local]# mkdir nexus
[root@Jenkins local]# ls
bin  etc  games  include  lib  lib64  libexec  nexus  python2  python3  sbin  share  src
[root@Jenkins local]# cd nexus/
[root@Jenkins nexus]# 

3.使用mv命令移动nuxes文件到nuxes目录下

[root@Jenkins nexus]# mv /root/nexus-3.23.0-03-unix.tar.gz /usr/local/nexus/
[root@Jenkins nexus]# ls
nexus-3.23.0-03-unix.tar.gz
[root@Jenkins nexus]# 

4.将nuxes压缩包解压

[root@Jenkins nexus]# tar -zxvf nexus-3.23.0-03-unix.tar.gz
[root@Jenkins nexus]# ll
总用量 149852
drwxr-xr-x. 9 root root       163 1222 16:29 nexus-3.23.0-03
-r--------. 1 root root 153445934 1222 16:18 nexus-3.23.0-03-unix.tar.gz
drwxr-xr-x. 3 root root        20 1222 16:29 sonatype-work

nexus-3.23.0-03:是nexus的核心文件
sonatype-work :maven下载jar存放地址

5.编辑nexus文件,修改root权限

vi ./bin/nexus

6.修改run_as_root为false

# user to execute as; optional but recommended to set
run_as_user=''

# load optional configuration
rc_file="$prg_dir/${progname}.rc"
if [ -f "$rc_file" ]; then
  . "$rc_file"
fi

# detect if execute as root user
run_as_root=false
user_id=`id -u`
user_name=`id -u -n`
if [ -z "$run_as_user" -a $user_id -ne 0 ]; then
Type  :qa!  and press <Enter> to abandon all changes and exit Vim

7.按下esc从插入模式跳回命令行模式,输入命令退出

:wq

8.运行nexus,并查看状态

[root@Jenkins nexus-3.23.0-03]# ./bin/nexus start
Starting nexus
[root@Jenkins nexus-3.23.0-03]# ./bin/nexus status
nexus is running.
[root@Jenkins nexus-3.23.0-03]# 

9.查看linux服务器端口占用情况

[root@Jenkins nexus-3.23.0-03]# netstat -anp |grep 8081
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      163123/java 

有LISTEN表示已经被占用,被java占用了

10.查看所有端口占用情况

[root@Jenkins nexus-3.23.0-03]# netstat -nultp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8081            0.0.0.0:*               LISTEN      163123/java         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1145/sshd           
tcp        0      0 127.0.0.1:45833         0.0.0.0:*               LISTEN      163123/java         
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      25297/systemd-resol 
tcp6       0      0 :::8080                 :::*                    LISTEN      5872/java           
tcp6       0      0 :::22                   :::*                    LISTEN      1145/sshd           
tcp6       0      0 :::5355                 :::*                    LISTEN      25297/systemd-resol 

11.cd到/usr/local/nexus/nexus-3.23.0-03/etc/找到nexus-default.properties修改nexus默认端口号为为占用的端口号

[root@Jenkins nexus-3.23.0-03]# cd ./etc
[root@Jenkins etc]# ls
fabric  jetty  karaf  logback  nexus-default.properties  ssl
[root@Jenkins etc]# 

[root@Jenkins etc] vi nexus-default.properties

12.修改application-port端口号

## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8082
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
 nexus-pro-feature

nexus.hazelcast.discovery.isEnabled=true
-- INSERT --

13.保存退出

:wq

14.重新启动nuxes

[root@Jenkins etc]# cd ../
[root@Jenkins nexus-3.23.0-03]# cd ./bin
[root@Jenkins bin]# ./nexus start
Starting nexus
[root@Jenkins bin]# ./nexus states
Usage: ./nexus {start|stop|run|run-redirect|status|restart|force-reload}
[root@Jenkins bin]# 

15.查看设置的端口是否开放

[root@Jenkins bin]# lsof -i:8082
[root@Jenkins bin]# 

没有消息,说明没有开放

16.开放端口,并保存

[root@Jenkins bin]# iptables -I INPUT -i eth0 -p tcp --dport 8082 -j ACCEPT
[root@Jenkins bin]# iptables -I OUTPUT -o eht0 -p tcp --sport 8082 -j ACCEPT
[root@Jenkins bin]# /etc/rc.d/init.d/iptables save

17.浏览器输入设置好的ip+port,登录nexus

http://192.168.4.107:8082/

18.linux服务器获取初始密码

[root@Jenkins nexus-3.23.0-03]# cd /usr/local/nexus/sonatype-work/nexus3
[root@Jenkins nexus3]# vi admin.password
[root@Jenkins nexus3]# 

69165e26-fbf4-4683-b626-37c77b2ff61f

初始密码

19.登录浏览器会提示修改初始密码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值