【Linux服务器搭建】——在linux上安装mysql5、tomcat8和jdk8并部署应用
2014-08-03 15:57
771 查看
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、下载源码,自己编译。 (最麻烦,需要编译环境)
首先安装服务端:
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/[/code]
这应该就成功了,可以通过进程或者端口查看一下: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[/code]
然后解压并且移动到需要的位置: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基于wdcp傻瓜式安装搭建discuz,Centos6.5 部署安装XAMPP1.8.3
- 在Linux安装配置Tomcat 并部署web应用 ( 三种方式 )
- 在Linux安装配置Tomcat 并部署web应用 ( 三种方式 )
- Linux应用服务器搭建手册—Weblogic服务域的创建与部署
- Memcached高速缓存服务器部署及应用(二、Memcached在Linux平台下安装与配置)
- linux下安装tomcat服务及部署web应用
- Linux下tomcat应用部署(通过Xshell+Xftp):Windows远程连接Linux服务器发布Tomcat Web应用程序
- 在Linux安装配置Tomcat 并部署web应用 ( 三种方式 )
- 在Linux安装配置Tomcat 并部署web应用 ( 三种方式 )
- linux 下安装配置jboss as7以及部署应用
- 在linux下(cents7,redhat6.5等)搭建的tomcat服务器,远程访问不到部署的应用
- Linux应用服务器搭建手册——JDK安装与配置
- Linux应用服务器搭建手册——weblogic安装
- 开发人员学Linux(3):CentOS7中安装JDK8和Tomcat8
- 如何在Linux下部署web程序(搭建vsftp服务,搭建sshd 服务器,jdk安装步骤,Tomcat安装步骤,MySQL安装步骤)
- linux下javaEE环境搭建(java6 mysql5 tomcat6 myeclipse8.0 安装过程及常见问题)
- Linux下安装Tomcat服务器和部署应用
- Linux应用服务器搭建手册——weblogic安装
- Linux下安装jdk8和tomcat8