`

Ubuntu Kylin 14.04下安装开发环境

 
阅读更多

        准备在Ubuntu Kylin 14.04上安装一套开发环境,有JDK、SVN、Maven、Groovy、Eclipse、MariaDB、MySQL Workbench、Nginx、Redis、Scala、Go、Haproxy、MongoDB等。

 

一: JDK

 1. 下载jdk-8u25-linux-x64.tar.gz

 2. 在/usr/local目录下新建jdk目录:sudo mkdir /usr/local/jdk

 3. 将压缩包解压到/usr/local/jdk:sudo tar -zxvf jdk-8u25-linux-x64.tar.gz -C /usr/local/jdk

 4. 配置环境变量:vi ~/.bashrc

     在末尾加上:

     export JAVA_HOME=/usr/local/jdk/jdk1.8.0_25
     export PATH=$PATH:${JAVA_HOME}/bin

 5. 使用source更新下.bashrc:source ~/.bashrc

 6. 如果之前系统里面已经安装了openjdk,可以使用如下方法将默认jdk更改过来:

     sudo update-alternatives --install /usr/bin/java java /usr/local/jdk/jdk1.8.0_25/bin/java 300
     sudo update-alternatives --install /usr/bin/javac javac /usr/local/jdk/jdk1.8.0_25/bin/javac 300

     sudo update-alternatives --config java

     sudo update-alternatives --config javac

 

二:SVN

 1. 下载subversion-1.8.10.tar.gz

 2. 解压subversion-1.8.10.tar.gz:tar -zxvf subversion-1.8.10.tar.gz -C ~/software

 3. 进入~/software/subversion-1.8.10目录:cd ~/software/subversion-1.8.10

 4. 执行:./configure --prefix=/usr/local/subversion

     结果出现:

www@kylin:~/software/subversion-1.8.10$ ./configure --prefix=/usr/local/subversion
configure: Configuring Subversion 1.8.10
configure: creating config.nice
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking if gcc accepts -std=c90... yes
checking if gcc accepts -Werror=unknown-warning-option... no
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking if g++ accepts -std=c++98... no
checking if g++ accepts -Werror=unknown-warning-option... no
checking how to run the C preprocessor... gcc -E
checking for a sed that does not truncate output... /bin/sed
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking whether ln -s works... yes
checking for a BSD-compatible install... /usr/bin/install -c
configure: Apache Portable Runtime (APR) library configuration
checking for APR... no
configure: WARNING: APR not found
The Apache Portable Runtime (APR) library cannot be found.
Please install APR on this system and configure Subversion
with the appropriate --with-apr option.

You probably need to do something similar with the Apache
Portable Runtime Utility (APRUTIL) library and then configure
Subversion with both the --with-apr and --with-apr-util options.

configure: error: no suitable APR found
     应该是g++和apr没有安装,执行:sudo apt-get install g++,(还执行了sh get-deps.sh)

 

     然后下载apr-1.5.1.tar.gz和apr-util-1.5.4.tar.gz

     分别执行:./configure --prefix=/usr/local/apr && make && sudo make install

     ./configure --prefix=/usr/local/apr --with-apr=/usr/local/apr && make && sudo make install

     然后下载zlib-1.2.8.tar.gz

     执行:./configure && make && sudo make install

     然后cd ~/software/subversion-1.8.10

     执行:./configure --prefix=/usr/local/subversion --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr

     终于成功

 5. 执行:make && sudo make install

 6. 配置环境变量:vi ~/.bashrc

     在末尾加上:

     export PATH=$PATH:/usr/local/subversion/bin

 7. 测试是否安装成功:svn --version

 8. 配置:

     a. 用户名和密码的保存
     编辑~/.subversion/config,找到store-passwords = no,将其以#注释掉,或者将no改为yes
     #store-passwords = no 改为 store-passwords = yes
     找到store-auth-creds = no,修改方法同上
     b. 更改本地用户名
     如果需要更改本地已保存的svn帐号,只需删除.subversion目录下的auth目录
      rm -rf ~/.subversion/auth
      这时再执行与svn有交互的命令(如svn ls),就会提示输入帐户名及密码。输过之后,新的账户就被保存下来了。

     c. 创建版本库:/usr/local/subversion/bin/svnadmin create REPOS_PATH

     d. 启动svn服务器:/usr/local/subversion/bin/svnserve -d -r REPOS_PATH

         其中 -d 表示守护进程, -r 表示在后台执行

9. 补充:我在Ubunty Kylin 16.04里安装subversion 1.9.4的时候执行./configure时出现:   

 

configure: checking sqlite library
checking sqlite amalgamation... no
checking sqlite amalgamation... no
checking sqlite3.h usability... no
checking sqlite3.h presence... no
checking for sqlite3.h... no
checking sqlite library version (via pkg-config)... no

An appropriate version of sqlite could not be found.  We recommmend
3.7.15.1, but require at least 3.7.12.
Please either install a newer sqlite on this system

or

get the sqlite 3.7.15.1 amalgamation from:
    http://www.sqlite.org/sqlite-amalgamation-3071501.zip
unpack the archive using unzip and rename the resulting
directory to:
/home/www/software/subversion-1.9.4/sqlite-amalgamation

configure: error: Subversion requires SQLite

     a. 根据提示下载:http://www.sqlite.org/sqlite-amalgamation-3071501.zip 

     b. 解压sqlite-amalgamation-3071501.zip:unzip sqlite-amalgamation-3071501.zip

     c. 将sqlite解压文件放在subversion解压目录下,在subversion解压目录下执行:mv ../sqlite-amalgamation-3071501 sqlite-amalgamation

     d. 接着执行./configure --prefix=/usr/local/subversion --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr && make && sudo make install

     e. 这么安装的svn客户端无法处理http和https

10. svn服务器开机启动:

     a. 配置svn服务器启动脚本:sudo vi /etc/init.d/svnd

         

#!/bin/sh

### BEGIN INIT INFO
# Provides:          svnd
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Should-Start:      slapd cups
# Should-Stop:       slapd cups
# Short-Description: start Svnserve daemon
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/subversion/bin

case "$1" in
  start)
    svnserve -d -r /home/www/svnrepository
    ;;  
  stop)
    killall svnserve
    echo "SVN Server Has Been Stoped"
    ;;  
  restart|force-reload)
    ;;  
  status)
    svnport=`netstat -natp | grep svnserve | awk '{print $4}' | awk -F: '{print $2}' | awk 'NR==1'`
    svnpid=`ps -aux | grep svnserve | grep -v 'grep' | awk '{print $2}'`
    if [ $svnport ]  && [ $svnport -eq 3690 ]
    then
        echo "SVN Server (pid:$svnpid) 正在运行..."
    else
        echo "SVN Server 停止运行..."
    fi  
    ;;  
  *)  
    echo "Usage: $0 {start | stop | restart | status}"
    ;;  
esac

exit 0

     b. 设置开机启动:sudo update-rc.d svnd defaults 95

 

三:Maven

 1. 下载apache-maven-3.2.3-bin.tar.gz

 2. 在/usr/local目录下新建maven目录:sudo mkdir /usr/local/maven

 3. 将压缩包解压到/usr/local/maven:sudo tar -zxvf apache-maven-3.2.3-bin.tar.gz -C /usr/local/maven

 4. 配置环境变量:vi ~/.bashrc

     在末尾加上:

     export MAVEN_HOME=/usr/local/maven/apache-maven-3.2.3
     export PATH=$PATH:${MAVEN_HOME}/bin

 5. 使用source更新下.bashrc:source ~/.bashrc

 6. 测试是否安装成功:mvn -v

 

四:Groovy

 1. 下载groovy-binary-2.3.7.zip

 2. 在/usr/local目录下新建groovy目录:sudo mkdir /usr/local/groovy

 3. 解压压缩包并移动到/usr/local/groovy:unzip groovy-binary-2.3.7.zip && sudo mv groovy-2.3.7 /usr/local/groovy

 4. 配置环境变量:vi ~/.bashrc

     在末尾加上:

     export GROOVY_HOME=/usr/local/groovy/groovy
     export PATH=$PATH:${GROOVY_HOME}/bin

 5. 使用source更新下.bashrc:source ~/.bashrc

 6. 测试是否安装成功:groovy -v

 

五:Eclipse

 1. 下载eclipse-jee-luna-SR1-linux-gtk-x86_64.tar.gz

 2. 将压缩包解压到/usr/local:sudo tar -zxvf eclipse-jee-luna-SR1-linux-gtk-x86_64.tar.gz -C /usr/local

 3. 启动eclipse:/usr/local/eclipse/eclipse

 4. 锁定到启动器:在启动器上选择“锁定到启动器”,就可以通过启动器运行了

 5. 安装groovy插件:http://dist.springsource.org/release/GRECLIPSE/e4.2/ (luna还没有对应的groovy插件,可以使用4.2的)

 

六:MariaDB

 1. 执行:sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db

 2. 执行:sudo vi /etc/apt/sources.list.d/MariaDB.list,加入下面几行:

                  # MariaDB 10.0 repository list - created 2014-11-04 07:46 UTC
                  # http://mariadb.org/mariadb/repositories/
                  deb http://mirrors.neusoft.edu.cn/mariadb/repo/10.0/ubuntu trusty main
                  deb-src http://mirrors.neusoft.edu.cn/mariadb/repo/10.0/ubuntu trusty main

 3. 执行:sudo apt-get update

 4. 执行:sudo apt-get install mariadb-server

 5. 安装过程中会让你输入root用户的密码

 6. 测试是否安装成功:mysql --version

 7. 设置参数:sudo vi /etc/mysql/my.cnf

#设置字符集 utf8mb4
[client]
default-character-set = utf8mb4

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'

[mysql]
default-character-set = utf8mb4

 8. 重启MariaDB:sudo service mysql restart (sudo /etc/init.d/mysql restart)

 

七:MySQL Workbench

 1. mysql-workbench-community-6.2.3-1ubu1404-amd64.deb

 2. 双击,使用Ubuntu软件中心安装

 3. 在这个环境6.2.3好像有问题,后来我装的是软件中心里带的6.0.8版

 

八:Nginx

 1. 下载pcre-8.36.tar.gz、nginx-1.6.2.tar.gz (还需zlib和ssl,zlib上面svn时已安装,ssl这次不装)

 2. 解压pcre-8.36.tar.gz:tar -zxvf pcre-8.36.tar.gz -C ~/software

 3. 进入~/software/pcre-8.36目录:cd ~/software/pcre-8.36 (无需执行)

 4. 执行:./configure --prefix=/usr/local/pcre(无需执行)

 5. 执行:make && sudo make install(无需执行)

 6. 解压nginx-1.6.2.tar.gz:tar -zxvf nginx-1.6.2.tar.gz -C ~/software

 7. 进入~/software/nginx-1.6.2目录:cd ~/software/nginx-1.6.2

 8. 执行:./configure --prefix=/usr/local/nginx  --with-pcre=~/software/pcre-8.36

 8.2 如果要安装echo模块,请下载并执行:./configure --prefix=/usr/local/nginx --add-module=/home/www/software/echo-nginx-module-0.61 --with-pcre=~/software/pcre-8.38

 9. 执行:make && sudo make install

10.测试是否安装成功:sudo /usr/local/nginx/sbin/nginx,然后打开浏览器,输入http://localhost:80

 

九:Redis

 1. 下载redis-2.8.17.tar.gz

 2. 解压redis-2.8.17.tar.gz:sudo tar -zxvf redis-2.8.17.tar.gz -C /usr/local/src

 3. 进入/usr/local/src/redis-2.8.17目录:cd /usr/local/src/software/redis-2.8.17

 4. 执行:make && sudo make install

 5. 复制配置文件:sudo mkdir /etc/redis && sudo cp redis.conf /etc/redis

 6. 修改配置文件:sudo vi /etc/redis/redis.conf

 7. 启动redis:redis-server /etc/redis/redis.conf

 8. 关闭redis:用redis-cli连接服务器,然后发送shutdown命令

 

十:Scala

 1. 下载scala-2.11.6.tgz

 2. 在/usr/local/src目录下新建scala目录:sudo mkdir /usr/local/src/scala

 3. 将压缩包解压到/usr/local/src/scala:sudo tar -zxvf scala-2.11.6.tgz -C /usr/local/src/scala

 4. 配置环境变量:vi ~/.bashrc

     在末尾加上:

     export SCALA_HOME=/usr/local/src/scala
     export PATH=$PATH:${SCALA_HOME}/bin

 5. 使用source更新下.bashrc:source ~/.bashrc

 6. 测试是否安装成功:scala

 

十一、Go

1. 下载go1.6.2.linux-amd64.tar.gz

2. 将压缩包解压到/usr/local/src:sudo tar -zxvf go1.6.2.linux-amd64.tar.gz -C /usr/local/src

3. 修改目录名:sudo mv /usr/local/src/go /usr/local/src/go-1.6.2

4. 做一个软连接:sudo ln -s /usr/local/src/go-1.6.2 /usr/local/go(配置好环境变量后,换go版本只需替换这个软连接)

5. 配置环境变量:vi ~/.bashrc

     在末尾加上:

     export GOROOT="/usr/local/go"

     export GOPATH="/home/www/code/go/learngo:/home/www/code/go/calcproj"
     export PATH=$PATH:$GOROOT/bin

6. 测试是否安装成功:go version

 

十二:Haproxy

1. 下载haproxy-1.6.7.tar.gz

2. 安装在Ubuntu 16.04下

3. 解压压缩包:tar -zxvf haproxy-1.6.7.tar.gz -C ~/software

4. 进入解压目录:cd ~/software/haproxy-1.6.7

5. 查询内核版本: uname -r ,通过cat README 可以知道编译平台的版本号,Ubuntu 16.04为linux2628

6. 执行:sudo make TARGET=linux2628 PREFIX=/usr/local/haproxy

7. 执行:sudo make install PREFIX=/usr/local/haproxy

8. 编写配置文件:

     a. sudo mkdir /etc/haproxy

     b. cp ~/software/haproxy-1.6.7/examples/option-http_proxy.cfg /etc/haproxy/haproxy.cfg

     c. sudo vi /etc/haproxy/haproxy.cfg

          修改:ulimit-n    16384 为 ulimit-n    44011 (因为配置的最大连接数20000导致这里设置的文件描述符数量不够,需加大)

          修改:bind        192.168.200.10:8080 为 bind        127.0.0.1:8080 

9. 启动haproxy:sudo /usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg

10. 查看进程:ps -aux | grep haproxy

11. 查看端口:sudo netstat -nlp | grep 8080

12. 关闭haproxy:sudo killall haproxy

13. 热加载配置文件:sudo /usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p pid-file -sf $(cat pid-file)

 

十三:MongoDB

1. 下载mongodb-linux-x86_64-3.2.10.tgz

2. 将压缩包解压到/usr/local/src:sudo tar -zxvf mongodb-linux-x86_64-3.2.10.tgz -C /usr/local/src

3. 做一个软连接:sudo ln -s /usr/local/src/mongodb-linux-x86_64-3.2.10 /usr/local/mongodb(配置好环境变量后,换mongodb版本只需替换这个软连接)

5. 配置环境变量:vi ~/.bashrc

     在末尾加上

     export PATH=$PATH:/usr/local/mongodb/bin

6. 测试是否安装成功:mongod --version

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics