标签:maven artifactory
运行环境:
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 <settings> <localRepository>/data/maven/repo</localRepository> </settings>
编辑maven的配置文件 # vim /usr/local/maven/conf/settings.xml <?xml version="1.0" encoding="UTF-8"?> <settingsxsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0http://maven.apache.org/xsd/settings-1.1.0.xsd"xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <localRepository>/data/maven/repo</localRepository> <servers> <server> <username>admin</username> <id>central</id> </server> <server> <username>admin</username> <id>snapshots</id> </server> </servers> <mirrors> <mirror> <mirrorOf>*</mirrorOf> <name>remote-repos</name> <url>http://192.168.40.121:8081/artifactory/remote-repos</url> <id>remote-repos</id> </mirror> </mirrors> <profiles> <profile> <repositories> <repository> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>libs-release</name> <url>http://192.168.40.121:8081/artifactory/libs-release</url> </repository> <repository> <snapshots /> <id>snapshots</id> <name>libs-snapshot</name> <url>http://192.168.40.121:8081/artifactory/libs-snapshot</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <snapshots> <enabled>false</enabled> </snapshots> <id>central</id> <name>plugins-release</name> <url>http://192.168.40.121:8081/artifactory/plugins-release</url> </pluginRepository> <pluginRepository> <snapshots /> <id>snapshots</id> <name>plugins-snapshot</name> <url>http://192.168.40.121:8081/artifactory/plugins-snapshot</url> </pluginRepository> </pluginRepositories> <id>artifactory</id> </profile> </profiles> <activeProfiles> <activeProfile>artifactory</activeProfile> </activeProfiles> </settings>
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 <Server port="8015"shutdown="SHUTDOWN"> <Service name="Catalina"> <Connector port="8081"/> <!-- This is the optional AJP connector --> <Connector port="8019" protocol="AJP/1.3"/> <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost"appBase="/data/maven/webapps"/> </Engine> </Service> </Server>
修改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 <VirtualHost *:80> ServerNamerepository.langbank.org ProxyPass / ajp://repository.langbank.org:8019/ ProxyPassReverse / ajp://repository.langbank.org:8019/ ErrorLog /data/logs/apache/repository.org-error.log CustomLog /data/logs/apache/repository.org-access.log common </VirtualHost>
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
本文出自 “Linux之旅” 博客,请务必保留此出处http://openlinuxfly.blog.51cto.com/7120723/1651180
标签:maven artifactory
原文地址:http://openlinuxfly.blog.51cto.com/7120723/1651180