Maven_Nexus_install

来源:互联网 发布:vue.js dotnet core 编辑:程序博客网 时间:2024/05/16 01:34
ref: http://www.cnblogs.com/dingyingsi/p/3776557.html

Centos 基础开发环境搭建之Maven私服nexus

1、 软件
a) 下载Nexus 地址:http://www.sonatype.org/downloads/nexus-2.1.2-bundle.tar.gz
b) 如无特殊说明,本文档操作用户为nexus
c) nexus默认的管理员用户名密码是:admin/admin123

2、 安装
a) 解压
 $ tar zxvf nexus-2.1.2-bundle.tar.gz
b) 移动到其他目录
 $ mv nexus-2.1.2 /home/nexus/nexus
可以编辑$NEXUS_HOME/conf/nexus.properties自定设置参数,包括端口号等。

c) 设置为系统自启动服务(使用root用户)
 # cd /etc/init.d/
 # cp /home/nexus/nexus/bin/jsw/linux-x86-64/nexus nexus

编辑/etc/init.d/nexus文件,添加以下变量定义:
 NEXUS_HOME=/home/nexus/nexus
 PLATFORM=linux-x86-64
 PLATFORM_DIR="${NEXUS_HOME}/bin/jsw/${PLATFORM}"

修改以下变量:
1 WRAPPER_CMD="${PLATFORM_DIR}/wrapper"
2 WRAPPER_CONF="${PLATFORM_DIR}/../conf/wrapper.conf"
3 PIDDIR="${NEXUS_HOME}"

修改如下变量,设置启动用户为nexus:
 RUN_AS_USER=nexus(可设为root)
授于nexus脚本有可执行的权限:
chmod 755 /etc/init.d/nexus

执行命令添加nexus自启动服务
 # chkconfig --add nexus
 # chkconfig --levels 345 nexus on
ps:
Red Hat, Fedora, CentOS增加nexus服务:
cd /etc/init.d
chkconfig --add nexus
chkconfig --levels 345 nexus on
Ubuntu and Debian增加nexus服务 
cd /etc/init.d
update-rc.d nexus defaults
chkconfig --levels 345 nexus on

执行如下命令启动、停止nexus服务
 # service nexus start
 # service nexus stop

2.3.4 配置nexus的防火墙(视情况,可能不需加)
将nexus默认端口 在防火墙里开启
执行 vi /etc/sysconfig/iptables
插入以下两行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 18080 -j ACCEPT

最后重启防火墙
ps:
iptables 所在目录 /etc/sysconfig/iptables
service iptables status 查看iptables状态
service iptables restart iptables服务重启
service iptables stop iptables服务禁用

至此,Nexus-Maven的服务端已经安装启动完毕,接下来可以通过其提供的web界面进行配置管理

2.4管理配置nexus-maven服务器

1)通过浏览器打开此URL:
http://192.168.0.249:8081/nexus ,出现管理主页面
2)点击页面右上角的Log In 进行登录
默认用户密码为admin/admin123,登录后即显示管理菜单:
3)进行Repositories仓库配置
点开Repositories管理项,可看到nexus当前管理的仓库列表
管理配置都可通过此web界面实现,非常方便,比如要想开启central
仓库在本私服上的代理,只要点击该仓库,出现管理选项:
在此页面根据需求设置即可,简单来说,只要将其中的
“Download Remote Indexes” 选项置为True,然后对该仓库进行update,该代理仓库即可启用,客户端通过配置即可使用该仓库的jar包构件;其他仓库的管理亦非常方便;

-----------------------------------------------------------------
ref: http://my.oschina.net/stevenleesmart/blog/160515

2.2 MAVEN安装步骤

2.2.1 解压Maven安装包

1. 将下载好的apache-maven-3.0.5-bin.tar.gz包,用FTP工具传至服务器上。

2. 解压安装包
tar -zvxf apache-maven-3.0.5-bin.tar.gz
移至/usr/local下:
mv apache-maven-3.0.5 /usr/local
maven装在/usr/local目录下。

2.2.2 配置环境变量

1. 编辑/etc/profile,在末尾添加如下:
export MAVEN_HOME=/usr/local/apache-maven-3.0.5
export PATH=$PATH:$MAVEN_HOME/bin
让系统重新执行下/etc/profile,命令:
source /etc/profile
2. 验证是否安装成功
mvn --version
ps:
对于初学者在安装配置好maven之后,发现目录下不存在.m2文件夹,其原因是因为没有执行任何maven相关的命令,之后执行之后maven才会自动去创建.m2文件夹。
执行mvn help:system命令,即可
0 0
原创粉丝点击