Linux下搭建Tomcat服务器

时间:2021-04-28 19:13:30
在Linux主机上,安装上传下载工具包rz及sz


如果不知道你要安装包的具体名称,可以使用yum provides */name 进行查找系统自带软件包的信息;


[root@localhost src]# yum provides */rz


lrzsz-0.12.20-27.1.el6.i686 : The lrz and lsz modem communications programs


Repo        : base


Filename    : /usr/bin/rz
一般会列出软件包的名称及版本,还有安装路径;查询到软件包名后,使用yum install -y 包名 进行安装。


lrzsz包安装完成后包括上传rz、下载sz命令;只需要安装这个包即可。


[root@localhost src]# yum install -y lrzsz


下面要用到rz命令,把你下载的tar.gz包上传到linux上,下载资源将在文章最后分享
=================================jdk安装配置=======================================
------------------------安装开始----------------------------------
[root@VM_33_67_centos ~]# mkdir -p user/local/java//创建文件夹
[root@VM_33_67_centos ~]# cd user/local/java
[root@VM_33_67_centos java]# rz
[root@VM_33_67_centos java]# ls
jdk-7u76-linux-x64.tar.gz
[root@VM_33_67_centos java]# tar -zxvf jdk-7u76-linux-x64.tar.gz //解压jdk,安装
[root@VM_33_67_centos java]# ls
jdk1.7.0_76  jdk-7u76-linux-x64.tar.gz//解压完成后得到一个文件夹
[root@VM_33_67_centos java]# ln -s jdk1.7.0_76 default//创建快捷方式 default
[root@VM_33_67_centos java]# ls
default jdk1.7.0_76  jdk-7u76-linux-x64.tar.gz


-----------------------配置环境变量开始----------------------------------


[root@VM_33_67_centos ~]#vi /etc/profile //这里是打开profile文件配置环境变量 文件如下
#/etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc


# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.


pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}




if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`id -u`
        UID=`id -ru`
    fi
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi


# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
    pathmunge /sbin after
fi


HOSTNAME=`/bin/hostname 2>/dev/null`
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi


export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL


# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
else
    umask 022
fi


for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null 2>&1
        fi
    fi
//按insert添加环境变量
export JAVA_HOME=/root/user/local/java/default
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JRE_HOME=$JAVA_HOME/jre
done


unset i
unset -f pathmunge


//按Esc然后按":wq"保存退出
[root@VM_33_67_centos ~]# source /etc/profile //回车使配置的环境变量生效


[root@VM_33_67_centos ~]# java -version //验证jdk配置是否成功,如果出现如下,配置成功
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)

Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)


================================================================================================================================

=============================安装tomcat服务器==================================


[root@VM_33_67_centos ~]# mkdir -p user/local/tomcat
[root@VM_33_67_centos ~]# cd user/local/tomcat
[root@VM_33_67_centos tomcat]# rz
[root@VM_33_67_centos tomcat]# ls
apache-tomcat-7.0.52.tar.gz
[root@VM_33_67_centos tomcat]#tar -zxvf apache-tomcat-7.0.52.tar.gz
[root@VM_33_67_centos tomcat]# ln -s apache-tomcat-7.0.52 server //创建符号链接 
[root@VM_33_67_centos tomcat]# cd server/bin
----开启tomcat服务器,在浏览器中输入主机ip:8080会出现下图代表安装成功-------

Linux下搭建Tomcat服务器

[root@VM_33_67_centos bin]# sh startup.sh 
Using CATALINA_BASE:   /root/user/local/tomcat/server
Using CATALINA_HOME:   /root/user/local/tomcat/server
Using CATALINA_TMPDIR: /root/user/local/tomcat/server/temp
Using JRE_HOME:        /root/user/local/java/default/jre
Using CLASSPATH:       /root/user/local/tomcat/server/bin/bootstrap.jar:/root/user/local/tomcat/server/bin/tomcat-juli.jar
Tomcat started.
[root@VM_33_67_centos bin]# 
----关闭tomcat服务器-----
[root@VM_33_67_centos bin]# sh shutdown.sh
Using CATALINA_BASE:   /root/user/local/tomcat/server
Using CATALINA_HOME:   /root/user/local/tomcat/server
Using CATALINA_TMPDIR: /root/user/local/tomcat/server/temp
Using JRE_HOME:        /root/user/local/java/default/jre
Using CLASSPATH:       /root/user/local/tomcat/server/bin/bootstrap.jar:/root/user/local/tomcat/server/bin/tomcat-juli.jar

================================================================================================================================

=============================安装mysql=================================

 [root@VM_33_67_centos ~]# rpm -qa | grep mysql //查看当前有没有安装Mysql


[root@VM_33_67_centos ~]# yum search mysql //通过yum查找mysq资源
已加载插件:fastestmirror, security
Loading mirror speeds from cached hostfile
epel                                                             | 4.3 kB     00:00     
extras                                                           | 3.4 kB     00:00     
os                                                               | 3.7 kB     00:00     
updates                                                          | 3.4 kB     00:00     
================================== N/S Matched: mysql ==================================
...
mysql.x86_64 : MySQL client programs and shared libraries
mysql++.i686 : C++ wrapper for the MySQL C API
mysql++.x86_64 : C++ wrapper for the MySQL C API
mysql++-devel.i686 : MySQL++ developer files (headers, examples, etc.)
mysql++-devel.x86_64 : MySQL++ developer files (headers, examples, etc.)
mysql++-manuals.x86_64 : MySQL++ user and reference manuals
mysql-bench.x86_64 : MySQL benchmark scripts and data
mysql-connector-java.noarch : Official JDBC driver for MySQL
mysql-connector-odbc.x86_64 : ODBC driver for MySQL
mysql-connector-python.noarch : MySQL Connector for Python 2
mysql-devel.i686 : Files for development of MySQL applications
mysql-devel.x86_64 : Files for development of MySQL applications
mysql-embedded.i686 : MySQL as an embeddable library
mysql-embedded.x86_64 : MySQL as an embeddable library
mysql-embedded-devel.i686 : Development files for MySQL as an embeddable library
mysql-embedded-devel.x86_64 : Development files for MySQL as an embeddable library
mysql-libs.i686 : The shared libraries required for MySQL clients
mysql-libs.x86_64 : The shared libraries required for MySQL clients
mysql-mmm.noarch : Multi-Master Replication Manager for MySQL
mysql-proxy.i686 : A proxy for the MySQL Client/Server protocol
mysql-proxy.x86_64 : A proxy for the MySQL Client/Server protocol
mysql-proxy-devel.i686 : Development files for mysql-proxy
mysql-proxy-devel.x86_64 : Development files for mysql-proxy
mysql-server.x86_64 : The MySQL server and related files //这是服务端,我们只要安装服务端就可以了
mysql-test.x86_64 : The test suite distributed with MySQL
mysql-utilities.noarch : MySQL Utilities
....
[root@VM_33_67_centos ~]# yum install mysql-server.x86_64
------------安装中--------------------


Complete!完成
[root@VM_33_67_centos ~]# service mysqld start
---------------启动中--------------------




====================设置密码=================================
[root@VM_33_67_centos ~]# /usr/bin/mysqladmin -u root -password '123456'


[root@VM_33_67_centos ~]# mysql -u root -p //登录数据库
Enter password: 


mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cz_web             |
| mysql              |
+--------------------+
3 rows in set (0.03 sec)
========设置mysql允许远程访问=========
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A


Database changed
mysql> select Host,User from user;
+-----------+--------+
| Host      | User   |
+-----------+--------+
| %         | mysqld |
| %         | root   |
| %         | server |
| 127.0.0.1 | root   |
+-----------+--------+
4 rows in set (0.01 sec)


mysql> update user set Host = '%' where User = 'root' limit 1;




mysql> exit;//退出
===================================================================================================

资源下载请到http://pan.baidu.com/s/1i5sMurj