在Ubuntu配置开发与测试服务器
一、连接远程服务器
通过ssh连接成功后就可以看出,linux是Ubuntu 14.04.3 LTS版本的
$ wanghaifengdeiMac:Jmeter_api_test chinaskin$ ssh 192.168.63.234
chinaskin@192.168.63.234's password: 123456
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64)
如果远程连接之后,一段时间不操作,会自动断开连接,
那么编辑服务器 /etc/ssh/sshd_config,最后增加
ClientAliveInterval 60
ClientAliveCountMax 1
这样,SSH Server 每 60 秒就会自动发送一个信号给 Client,而等待 Client 回应
二、安装yum命令
$ sudo apt-get install yum
三、切换到root用户
$ wangcityboy@s3:/$ su
Password:
root@s3:/# ls
切换到其它用户可以用:su - wangcityboy
四、查看已安装软件
查看已安装软件:
dpkg -l *apache*
dpkg -l *php*
dpgk -l *mysql*
"uu"为未安装,“ii”为已安装。
五、安装gradle
unzip gradle-2.2.1-bin.zip
root@s3:~# vi .bash_profile
GRADLE_HOME=/home/wanghaifeng/gradle/gradle-2.2.1
export PATH=$PATH:$GRADLE_HOME/bin
六、安装tomcat
apt-cache search tomcat
tar zxvf apache-tomcat-8.0.29.tar.gz
tomcat7.0.5的端口(一般tomcat7.0.5的端口默认为8080),如果发生冲突,则可以在以下文件修改。
tomcat7/conf/server.xml 文件里的:
protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
改成8888,或者其它均可(这里用8888吧)。
root@s3:/home/chinaskin/tomcat/apache-tomcat-8.0.29/bin# ./startup.sh
Using CATALINA_BASE: /home/wanghaifeng/tomcat/apache-tomcat-8.0.29
Using CATALINA_HOME: /home/wanghaifeng/tomcat/apache-tomcat-8.0.29
Using CATALINA_TMPDIR: /home/wanghaifeng/tomcat/apache-tomcat-8.0.29/temp
Using JRE_HOME: /usr
Using CLASSPATH: /home/wanghaifeng/tomcat/apache-tomcat-8.0.29/bin/bootstrap.jar:/home/wanghaifeng/tomcat/apache-tomcat-8.0.29/bin/tomcat-juli.jar
Tomcat started.
七、安装apache
root@s3:/# sudo apt-get install apache2
sudo: unable to resolve host s3.yn.com
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
aspectj bsh fop java-wrappers junit junit4 libaether-java
libaopalliance-java libasm3-java libaspectj-java libasync-http-client-java
libatinject-jsr330-api-java libbatik-java libbsf-java libbsh-java
修改端口号
root@s3:/etc/apache2# vi ports.conf
八、安装mysql
root@s3:~# apt-get install mysql-client-core-5.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
aspectj bsh fop java-wrappers junit junit4 libaether-java
libaopalliance-java libasm3-java libaspectj-java libasync-http-client-java
libatinject-jsr330-api-java libbatik-java libbsf-java libbsh-java
……..
九、安装maven
tar zxvf apache-maven-3.3.9-bin.tar.gz
MAVEN_HOME=/home/wanghaifeng/maven/apche-maven-3.3.9
export PATH=$PATH:$MAVEN_HOME/bin
root@s3:~# mvn -v
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_91, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-25-generic", arch: "amd64", family: "unix"
十、安装ant
tar zxvf apache-ant-1.9.6-bin.tar.gz
ANT_HOME=/home/wanghaifeng/ant/apache-ant-1.9.6
export PATH=$PATH:$ANT_HOME/bin
root@s3:~# ant -version
Apache Ant(TM) version 1.9.3 compiled on April 8 2014
十一、安装git
$ tar zxvf git-2.7.0.tar.gz
$ ./configure --prefix=/usr/bin
$ make出现错误,提示“/bin/sh: msgfmt: not found”执行以下命令安装gettext
$ sudo aptitude install gettext
然后再跑make.
$ make
一般这里不会出错了,最后
$ sudo make install
运行成功后,check下git的版本,这里要注意的是其实系统之前就已经自带安装了git,版本未1.7.1,现在由于版本过低,所以我才重新安装git,多次重试发现使用apt-get无法更新,所以才使用这种方法
$ root@s3:/home/wanghaifeng/git/git-2.7.0# git --version
git version 1.9.1
十二、安装unrar
苹果操作系统中不自带解压rar格式的压缩文件,所以要另外安装
wanghaifengdeiMac:Downloads ~$ brew install unrar
十三、安装mongodb
2、tar -zxvf mongodb-linux-x86_64-3.0.6.tgz
3、sudo mv mongodb-linux-x86_64-3.0.6/ /usr/local/mongodb
4、添加环境变量,
vi /etc/profile
增加, export PATH=/root/tools/mongodb/bin:$PATH
然后, source /etc/profile
5、启动数据库
$ mongod --dbpath ./data
十四、安装nodejs
1、sudo apt-get update
2、sudo apt-get install nodejs
3、sudo apt-get install npm
4、添加node别名,
增加,
nano (edit / vim) the file ~/.bashrc and add the line: alias node="nodejs"
然后,source ~/.bashrc
5、测试nodes环境
$ touch test.js
$ vi test.js 并输入 console.log(“Hello world”)
$ node test.js
十五、如果nodejs版本太低,需要升级的话
$ sudo wget http://nodejs.org/dist/v6.3.1/node-v6.3.1.tar.gz
$ tar -zvxf node-v6.3.1.tar.gz
$ ./configure
$ make
$ make install
十六、安装其他环境
$ sudo apt-get install python
$ sudo apt-get install build-essential
$ sudo apt-get install gcc
$ sudo apt-get install g++
$ sudo apt-get install libssl-dev
$ sudo apt-get install curl
$ sudo apt-get install apache2-utils
十七、打开防火墙,开放端口号
$ iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT #允许 8080 端口
$ iptables-save
十八、其他命令
1、设置nam以及node
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm config set registry http://registry.npmjs.org/
curl -L https://npmjs.org/install.sh | sh
ln -s /usr/local/bin/node /usr/bin/nodejs
2、升级nodejs
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo n 0.12.17
3、设置环境变量
export NODE_HOME=/usr/local/n/versions/node/0.12.17
export PATH=$PATH:${NODE_HOME}/bin
export NODE_PATH=${NODE_HOME}/lib/node_module
4、卸载nodejs
sudo apt-get remove nodejs
正文到此结束