linux作为java web服务器是首要选择。在工作中也会搭建服务器。今天尝试在linux上搭建tomcat服务器。

linux:suse

jdk:jre 1.8

tomat:8.0.9

mysql:5.5.39

服务器是用的阿里云服务器。2G内存,双核CPU。

1、mysql安装

下载地址可以使用sohu的镜像进行下载 ,地址:http://mirrors.sohu.com/mysql/

我下载的名称为:

-rw-r--r-- 1 root root 17715414 Jul 21 20:06 MySQL-client-5.5.39-2.linux2.6.x86_64.rpm 客户端
-rw-r--r-- 1 root root 50567146 Jul 21 20:08 MySQL-server-5.5.39-2.linux2.6.x86_64.rpm 服务端

mysql安装有四种方式:(有兴趣可以多尝试几种)

a、rpm安装

b、.tar.gz已经编译好的压缩包

c、也是压缩包,在已经安装好mysql的服务器上,把目录打包

d、下载源码,自己编译。 (最麻烦,需要编译环境)

首先安装服务端:

iZ62h6r26tgZ:/tmp # rpm -i MySQL-server-5.5.39-2.linux2.6.x86_64.rpm
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h iZ62h6r26tgZ password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
这应该就成功了,可以通过进程或者端口查看一下:
iZ62h6r26tgZ:/tmp # service mysql start
iZ62h6r26tgZ:/tmp # ps -ef | grep mysql
root 5340 1 0 13:35 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/iZ62h6r26tgZ.pid
mysql 5433 5340 1 13:35 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/iZ62h6r26tgZ.err --pid-file=/var/lib/mysql/iZ62h6r26tgZ.pid
iZ62h6r26tgZ:/tmp # netstat -antp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 5433/mysqld
然后安装客户端:
iZ62h6r26tgZ:/tmp # rpm -ivh MySQL-client-5.5.39-2.linux2.6.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:MySQL-client-5.5.39-2.linux2.6 ################################# [100%]
OK,到此就安装好了,mysql安装默认是没密码的,登陆进去看下是不是OK的。
iZ62h6r26tgZ:/tmp # mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.39 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> quit;
可以登陆,然后就需要把root的密码给改了,空密码毕竟不安全。其实安装完成mysql就已经告诉你修改了,在上面安装server端的时候,有输出的。
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h iZ62h6r26tgZ password 'new-password'

是的 就是它:

iZ62h6r26tgZ:/tmp # mysqladmin -u root password abc123
iZ62h6r26tgZ:/tmp # mysql -u root -p
Enter password: //输入abc123
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.39 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
OK,密码修改成功。到这里 mysql就安装好啦!(数据库的其他操作这里就不叙述了)

2、tomcat安装

下载地址:apache官网跳进去下载可以apache.org也可以直接到这个地址:http://tomcat.apache.org/download-80.cgi

我的下载:

iZ62h6r26tgZ:/tmp # wget http://apache.dataguru.cn/tomcat/tomcat-8/v8.0.9/bin/apache-tomcat-8.0.9.tar.gz
然后解压并且移动到需要的位置:
iZ62h6r26tgZ:/tmp # tar -zxvf apache-tomcat-8.0.9.tar.gz

3、jdk 安装

开发环境我们需要Java SE Development Kit(JDK),在正式环境可以用JDK,也可以用java runtime environment(jre)

下载地址:

32位版:
百度网盘下载:
链接:http://pan.baidu.com/s/1i3snCWH
密码:jswu
360云盘下载:
http://yunpan.cn/QIVncUcIjav4K
密码:3a90
城通网盘下载:
http://www.t00y.com/file/60441060
64位版下载:
百度网盘下载:
链接:http://pan.baidu.com/s/1qWGvUk0
密码:jxrs
360云盘下载:
http://yunpan.cn/QIVndhGu86gJ7
密码:c81b
城通网盘下载:
http://www.t00y.com/file/60441506

先下载到电脑,然后再传到服务器上,我下载的是64为rpm包(rpm会省事点。不用配置环境变量了)

iZ62h6r26tgZ:/tmp # rpm -ivh jdk-8-linux-x64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:jdk-2000:1.8.0-fcs ################################# [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
iZ62h6r26tgZ:/tmp # java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
iZ62h6r26tgZ:/tmp #

也可以下载tar.gz 包,然后解压到意向目录。然后设置java环境变量即可。

4、尝试启动tomcat

进入到tomcat的bin目录下,执行startup.sh即可

iZ62h6r26tgZ:/angel # cd apache-tomcat-8.0.9/
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9 # ls
LICENSE NOTICE RELEASE-NOTES RUNNING.txt bin conf lib logs temp webapps work
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9 # cd bin/
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9/bin # ls
bootstrap.jar catalina.bat commons-daemon-native.tar.gz configtest.bat daemon.sh digest.sh setclasspath.sh shutdown.sh startup.sh tomcat-native.tar.gz tool-wrapper.sh version.sh
catalina-tasks.xml catalina.sh commons-daemon.jar configtest.sh digest.bat setclasspath.bat shutdown.bat startup.bat tomcat-juli.jar tool-wrapper.bat version.bat
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9/bin # ./startup.sh
Using CATALINA_BASE: /angel/apache-tomcat-8.0.9
Using CATALINA_HOME: /angel/apache-tomcat-8.0.9
Using CATALINA_TMPDIR: /angel/apache-tomcat-8.0.9/temp
Using JRE_HOME: /usr
Using CLASSPATH: /angel/apache-tomcat-8.0.9/bin/bootstrap.jar:/angel/apache-tomcat-8.0.9/bin/tomcat-juli.jar
Tomcat started.
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9/bin # ps -ef | grep java
root 7918 1 45 14:39 pts/0 00:00:04 /usr/bin/java -Djava.util.logging.config.file=/angel/apache-tomcat-8.0.9/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/angel/apache-tomcat-8.0.9/endorsed -classpath /angel/apache-tomcat-8.0.9/bin/bootstrap.jar:/angel/apache-tomcat-8.0.9/bin/tomcat-juli.jar -Dcatalina.base=/angel/apache-tomcat-8.0.9 -Dcatalina.home=/angel/apache-tomcat-8.0.9 -Djava.io.tmpdir=/angel/apache-tomcat-8.0.9/temp org.apache.catalina.startup.Bootstrap start
root 7944 4443 0 14:40 pts/0 00:00:00 grep --color=auto java
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9/bin # netstat -antp| grep 8080
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 7918/java
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9/bin #
然后通过浏览器输入:http://ip:8080 就可以看到8.0.9的小猫了。

停止tomcat:

iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9/bin # ./shutdown.sh
Using CATALINA_BASE: /angel/apache-tomcat-8.0.9
Using CATALINA_HOME: /angel/apache-tomcat-8.0.9
Using CATALINA_TMPDIR: /angel/apache-tomcat-8.0.9/temp
Using JRE_HOME: /usr
Using CLASSPATH: /angel/apache-tomcat-8.0.9/bin/bootstrap.jar:/angel/apache-tomcat-8.0.9/bin/tomcat-juli.jar
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9/bin # ps -ef | grep java
root 8101 4443 0 14:43 pts/0 00:00:00 grep --color=auto java
iZ62h6r26tgZ:/angel/apache-tomcat-8.0.9/bin #

5、设置tomcat开机启动

iZ62h6r26tgZ:/ # cat /etc/inittab
id:3:initdefault:
iZ62h6r26tgZ:/ #
此表示该系统启动后会在运行级别3下运行,而3模式下运行会对应l3:3:wait:/etc/rc.d/rc 3,既会启动所有rc3.d目录中的脚本,linux运行级别一共分为7种:
0启动停止整个系统
1单用户或管理模式
2多用户模式,部分网络服务启动。
3正常操作运行模式,启动所有的网络服务
4用户自定义模式,可以用该级别来定制所需要的运行服务
5某些unix操作系统变体将其作为缺省的x-windows模式,也有些把它作为系统维护模式
6重启动

所以把tomcat下bin目录中的启动脚本startup.sh拷贝到/etc/rc.d/rc3.d/目录下就可启动tomcat了

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

tags: tomcat,apache,angel,bin,iZ62h6r26tgZ,mysql,root,sh,MySQL,jar,tmp,http,password
分页:12
转载请注明
本文标题:【Linux服务器搭建】――在linux上安装mysql5、tomcat8和jdk8并部署应用
本站链接:http://www.codesec.net/view/39213.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(680)