Ubuntu 14.04 搭建Nexus Maven 私服
2017-02-07 15:50
555 查看
Ubuntu 14.04 搭建Nexus Maven 私服
安装Nexus的前提是已经安装JDK,JDK的安装这里就不再赘述,安装
JDK-1.7版本,JDK版本过低在启动Nexus的时候会报错.
Nexus 下载与启动
下载链接为http://www.sonatype.org/nexus/go/ 最新版本为 nexus-2.11.4-01,我们下载
NEXUS OSS(TGZ). 得到
nexus-2.11.4-01-bundle.tar.gz
将
nexus-2.11.4-01-bundle.tar.gz复制到
/usr/local目录下
sudo cp nexus-2.11.4-01-bundle.tar.gz /usr/local cd /usr/local
解压
nexus-2.11.4-01-bundle.tar.gz,得到
nexus-2.11.4-01和
sonatype-work两个文件夹,为了以后操作方便,我们将创建软链接
nexus指向
nexus-2.11.4-01
sudo tar -zxvf nexus-2.11.4-01-bundle.tar.gz sudo ln -s nexus-2.11.4-01 nexus
启动
Nexus
cd nexus sudo bin/nexus
输出:
Usage: bin/nexus { console | start | stop | restart | status | dump }
根据英文即可知道每个命令的意思,现在启动
Nexus
sudo bin/nexus start
结果输出:
**************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.
此时修改
bin/nexus文件设置
RUN_AS_USER
sudo vim bin/nexus 将 #RUN_AS_USER= 改成 RUN_AS_USER=root
重新启动
Nexus
sudo bin/nexus start
输出:
**************************************** WARNING - NOT RECOMMENDED TO RUN AS ROOT **************************************** Starting Nexus OSS... Started Nexus OSS.
打开
localhost:8081/nexus进行查看,启动成功.如果打不开怎么办?
查看日志
vim logs/wrapper.log
根据错误提示来修改配置文件.
修改
nexus的端口
sudo vim conf/nexus.properties 将application-port=8081 改成你想设置的端口,例如9000.
nexus.properties文件中的
nexus-work:指定构件库的存储位置
将Nexus设置为系统自启动服务
复制/usr/local/nexus/bin/nexus文件到
/etc/init.d/
sudo cp /usr/local/nexus/bin/nexus /etc/init.d/
修改
/etc/init.d/nexus
sudo vim /etc/init.d/nexus
添加修改以下变量:
NEXUS_HOME="/usr/local/nexus" RUN_AS_USER=root PIDDIR="/var/run"
启动
nexus服务
sudo service nexus start #启动 sudo service nexus stop #停止服务 sudo service nexus status #查看服务状态
启动之后,跟之前所述一样,打开
http://localhost:8081/nexus即可.
提示
默认登录用户名为admin,密码admin123
使用nginx
nginx是一个非常轻量级的HTTP服务器,nginx,它的发音为“engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服务器。nginx安装
sudo apt-get install nginx
默认
nginx安装,所有的配置文件都在
/etc/nginx下,并且每个虚拟主机已经安排在了
/etc/nginx/sites-available下,
启动程序文件在
/usr/sbin/nginx,日志放在了
/var/log/nginx中,分别是
access.log和
error.log,并已经在
/etc/init.d/下创建了启动脚本
nginx,默认的虚拟主机的目录设置在了
/usr/share/nginx/www
安装过之后,默认已经启动.查看是否启动:
sudo service nginx status #查看状态 sudo service nginx stop #停止服务 sudo service nginx start #启动服务
启动之后,打开
http://localhost/即可.如果不能访问,先不要继续,看看是什么原因,解决之后再继续。
配置
nginx
cd /etc/nginx/conf.d sudo vim nexus.conf
将下列内容复制进去
# # The default server # server { listen 80 ; server_name 127.0.0.1; #charset koi8-r; #access_log logs/host.access.log main; # Load configuration files for the default server block. location /nexus { proxy_set_header Via "nginx"; proxy_read_timeout 120; proxy_send_timeout 120; proxy_connect_timeout 120; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://127.0.0.1:8081/nexus; } location / { root /usr/share/nginx/html; index index.html index.htm; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }
重启
nginx
sudo service restart nginx
如果你的机器同时安装了
Apache,此时
nginx都可能启动不了,这是因为它们都是用了
80这个端口。两种方法:停止
apache或者将nginx的端口修改为
8080,将
nexus.conf配置文件中的
listen 80改为
listen 8080
启动成功之后,访问
http://127.0.0.1/nexus即可.
配置nexus
配置nexus开启远程索引 新搭建的
neuxs环境只是一个空的仓库,需要手动和远程中心库进行同步,
nexus默认是关闭远程索引下载,最重要的一件事情就是开启远程索引下载。登陆
nexus系统,默认用户名密码为
admin/admin123。
点击左侧的
Views/Repositories,下拉菜单中有
Repositories选项,点击
Repositories,找到右边仓库列表中的三个仓库
Apache Snapshots,
Codehaus Snapshots和
Central,然后在这三个仓库的
configuration下把
Download Remote Indexes修改为
true。然后在这三个仓库上分别右键,选择
Repair Index,这样
nexus就会去下载远程的索引文件。
建立内部仓库 新建公司的内部仓库,步骤为页面上部的
Add –> Hosted Repository,在页面的下半部分输入框中填入
Repository ID和
Repository Name即可,比如分别填入
myrepo和
my repository,另外把
Deployment Policy设置为
Allow Redeploy,点击
save就创建完成了.
修改
neuxs仓库组
nexus中仓库组的概念是
Maven没有的,在
Maven看来,不管你是
hosted也好,
proxy也好,或者
group也好,对我都是一样的,我只管根据
groupId,
artifactId,
version等信息向你要构件。为了方便
Maven的配置,
nexus能够将多个仓库,
hosted或者
proxy合并成一个
group,这样,
Maven只需要依赖于一个
group,便能使用所有该
group包含的仓库的内容。
neuxs中默认自带了一个名为
Public Repositories组,点击该组可以对他保护的仓库进行调整。同时创建一个
Group ID为
public-snapshots、
Group Name为
Public Snapshots Repositories的组,把
Apache Snapshots、
Codehaus Snapshots和
Snapshots加入其中。
到这里
neuxs的安装配置就完成了.
相关文章推荐
- ubuntu系统上,用nexus搭建maven私服
- Ubuntu server下搭建Maven私服Nexus
- Ubuntu server下搭建Maven私服Nexus
- Ubuntu server下搭建Maven私服Nexus
- Ubuntu server下搭建Maven私服Nexus
- Ubuntu下使用Nexus搭建Maven私服
- Linux(Ubuntu)上使用nexus搭建maven私服
- ubuntu14.04 搭建nexus 私服
- Ubuntu server下搭建Maven私服Nexus
- Ubuntu server下搭建Maven私服Nexus
- Sonatype Nexus 搭建Maven 私服
- 用nexus搭建maven私服(整合网上文章而成的)
- Linux安装配置maven3.0以及搭建nexus私服
- Linux安装配置maven以及搭建nexus私服(编写启动脚本)
- 用nexus搭建maven私服
- maven--私服的搭建(Nexus的使用)
- Nexus搭建Maven私服
- 使用Nexus 给maven 搭建私服
- Maven学习 (四) 使用Nexus搭建Maven私服
- 使用Nexus搭建Maven私服