搭建本地maven库

搭建本地maven库

本次实验所需环境

[root@mysql-server-01 ~]# lsb_release  -a
LSB Version:  :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:  CentOS Linux release 7.7.1908 (Core)
Release:  7.7.1908
Codename: Core

安装包

apache-maven-3.6.3-bin.zip  jdk1.8.0_162.tar.gz  nexus-2.11.2.tar.gz

配置Java环境

解压jdk
tar zxvf jdk1.8.0_162.tar.gz -C /usr/ && mv /usr/java/jdk1.8.0_162 /usr/jdk
添加环境变量
vim /etc/profile
  export JAVA_HOME=/usr/jdk
  export JRE_HOME=${JAVA_HOME}/jre
  export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
  export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
[root@VM_0_44_centos lib]# java -version
[root@VM_0_44_centos server]# java -version
java version "1.8.0_162-ea"
Java(TM) SE Runtime Environment (build 1.8.0_162-ea-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b01, mixed mode)

配置maven库

unzip apache-maven-3.6.3-bin.zip -C /usr/local/
vim /etc/profile
export MAVEN_HOME=/root/server/apache-maven-3.6.3
export PATH=${PATH}:${MAVEN_HOME}/bin
source /etc/profile

附上maven库的配置,其实要改的没多少,懒癌发作干脆全贴出来,如果版本和我的一样的话可以全部复制了自个儿用,看不懂的可以看看其他博客

cat /root/server/apache-maven-3.6.3/conf/settings.xml



  
  /data/maven-data
  
  
    
  
  
    
  
  
    
​
    
    
  
    
      ylh-releases
      tech
      123456
    
    
    
      ylh-snapshots
      tech
      123456
    
  
  
    
    
      nexus-123456
      central
      Nexus 123456
      http://maven.123456.cn/nexus/content/groups/public
    
  
          nexus
    *
    Human Readable Name for this Mirror.
    http://maven.aliyun.com/nexus/content/groups/public/
  
  
  
    
    
    jdk-1.8  
      
      true  
      1.8  
      
      
      1.8  
      1.8  
      1.8  
      
   
    
  

解压并修改配置文件

tar zxvf nexus-2.11.2.tar.gz -C /root/server/
vim /root/server/nexus-2.11.2-03/conf/nexus.properties
......
application-port=8900   //端口不冲突的默认就好
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
​
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus  //相对路径
runtime=${bundleBasedir}/nexus/WEB-INF

启动nexus

/root/server/nexus-2.11.2-03/bin/nexus start

启动后是这样的

如果想用域名访问的话再附上一份nginx配置

yum install epel-release
yum install -y nginx

maven的配置文件

[root@maven ~]# cat /etc/nginx/conf.d/maven.123456.cn.conf 
server {
  listen 80;
  server_name maven.123456.cn;
  index index.html index.htm index.jsp;#设定访问的默认首页地址
  access_log /var/log/nginx/maven.123456.com.access.log;
  error_log /var/log/nginx/maven.123456.com.error.log;
​
  location /nexus/ {
      proxy_pass  http://127.0.0.1:8900; 
      proxy_redirect off;
      proxy_set_header Host $host;
      proxy_set_header  X-Real-IP  $remote_addr;
      client_max_body_size    1000m;
       }
   location / {
        rewrite ^(.*)$ http://maven.123456.cn/nexus permanent;
        }
    }

启动nginx并访问

systemctl start nginx.service
systemctl enable nginx.service  //开机自启

搭建本地maven库_第1张图片

如果不能访问记得关闭防火墙

  1. 关闭selinux和防火墙

[root@mysql-server-01 ~]# getenforce
Enforcing
[root@mysql-server-01 ~]# setenforce 0
[root@mysql-server-01 ~]# getenforce
Permissive
[root@mysql-server-01 ~]# firewall-cmd --state
running
[root@mysql-server-01 ~]# systemctl stop firewalld.service
[root@mysql-server-01 ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@mysql-server-01 ~]# firewall-cmd --state
not running

更新系统时间

[root@mysql-server-01 ~]# yum -y install ntp ntpdate
[root@mysql-server-01 ~]# ntpdate 0.asia.pool.ntp.org
25 Apr 16:17:54 ntpdate[2056]: step time server 203.107.6.88 offset 3699663.834363 sec
[root@mysql-server-01 ~]# hwclock --systohc
[root@mysql-server-01 ~]# date
2020年 04月 25日 星期六 16:18:07 CST

你可能感兴趣的:(运维)