运行环境:

CentOS release 6.6
# uname -sr
Linux 2.6.32-504.el6.x86_64

#java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

# ./apachectl -v
Server version: Apache/2.2.29 (Unix)
Server built:   Apr 29 2015 14:30:50

1.安装maven

# cd /opt/
# wget -chttp://mirrors.cnnic.cn/apache/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
# tar xf apache-maven-3.3.3-bin.tar.gz -C/usr/local/
# ln -sv /usr/local/apache-maven-3.3.3/usr/local/maven
 
# vim /etc/profile.d/maven.sh
export MAVEN_HOME=/usr/local/maven
exportPATH=${PATH}:${MAVEN_HOME}/bin

# source/etc/profile.d/maven.sh


2.配置本地仓库

# mkdir -p /data/maven/repo
# mkdir -p  ~/.m2/repository
# vim ~/.m2/settings.xml

   /data/maven/repo


编辑maven的配置文件
# vim /usr/local/maven/conf/settings.xml


 
 
 /data/maven/repo
 
  
    
     admin
     central
    
    
     admin
     snapshots
    
  
  
    
     *
     remote-repos
     http://192.168.40.121:8081/artifactory/remote-repos
     remote-repos
    
  
  
   
     
       
         
           false
         
         central
         libs-release
         http://192.168.40.121:8081/artifactory/libs-release
       
       
         
         snapshots
         libs-snapshot
         http://192.168.40.121:8081/artifactory/libs-snapshot
       
     
     
       
         
           false
         
         central
         plugins-release
         http://192.168.40.121:8081/artifactory/plugins-release
       
       
         
         snapshots
         plugins-snapshot
         http://192.168.40.121:8081/artifactory/plugins-snapshot
       
     
     artifactory
   
 
 
   artifactory
 


3.安装maven仓库(artifactory

# cd /opt/
# wget -chttp://ncu.dl.sourceforge.net/project/artifactory/artifactory/3.6.0/artifactory-3.6.0.zip
# unzip artifactory-3.6.0.zip
# mv artifactory-3.6.0 /usr/local/
# ln -sv /usr/local/artifactory-3.6.0/usr/local/artifactory
# chown -R web.users /usr/local/artifactory/
# vim /etc/profile.d/artifactory.sh
exportARTIFACTORY_HOME=/usr/local/artifactory
export PATH=$PATH:$ARTIFACTORY_HOME/bin
# source /etc/profile.d/artifactory.sh
 
# sed -i's/ARTIFACTORY_USER=artifactory/ARTIFACTORY_USER=web/g'/usr/local/artifactory/bin/installService.sh
# cd /usr/local/artifactory/
安装artifactory服务
#  ./bin/installService.sh


4.配置Maven仓库(artifactory

编辑default文件
# vim etc/default
#!/bin/sh
#Default values
export ARTIFACTORY_HOME=/usr/local/artifactory
export ARTIFACTORY_USER=web
export JAVA_HOME=/usr/local/java
export TOMCAT_HOME=/usr/local/artifactory/tomcat
export ARTIFACTORY_PID=$ARTIFACTORY_HOME/run/artifactory.pid
export CATALINA_PID=/usr/local/artifactory/tomcat/run/tomcat.pid
export JAVA_OPTIONS="-server -Xms512m -Xmx2g -Xss256k-XX:PermSize=128m -XX:MaxPermSize=256m -XX:+UseG1GC"
export JAVA_OPTIONS="$JAVA_OPTIONS-Djruby.compile.invokedynamic=false -Dfile.encoding=UTF8"
修改artifactory自带的Tomcat的server.xml
# vim /usr/local/artifactory/tomcat/conf/server.xml

 
   
       
 
       
       
 
       
         
       
 
   
修改apache配置文件连接至tomcat,启用ajp连接器
# vim /usr/local/apache/conf/httpd.conf
         LoadModule       jk_module        modules/mod_jk.so
httpd-vhosts.conf增加如下一行
# vim /usr/local/apache/conf/extra/httpd-vhosts.conf
Include conf/extra/vhost/repository.conf
 
# vim /usr/local/apache/conf/extra/vhost/repository.conf

        ServerNamerepository.langbank.org
        ProxyPass / ajp://repository.langbank.org:8019/
        ProxyPa***everse / ajp://repository.langbank.org:8019/
        ErrorLog /data/logs/apache/repository.org-error.log
        CustomLog /data/logs/apache/repository.org-access.log common


5.配置完成,启用maven仓库服务

$  cd /usr/local/artifactory/bin
 
# /etc/init.d/httpd -kgraceful
# su - web
$  ./artifactory.sh start
$  exit
将数据目录迁移至data/maven/
# cd ../
# mv data /data/maven/data
# ln -sv  /data/maven/data data
# mkdir -p /data/maven/webapps
# chown -R web.web /data/maven/webapps

帐号:admin  密码:password

maven实战_第1张图片

maven实战_第2张图片