Tomcat服务器搭建步骤
一、 环境初始化
关闭防火墙以及Selinux
# service iptables stop/iptables -F 临时关闭防火墙
# chkconfig iptables off 关闭防火墙开机自启
# setenforce 0 临时关闭selinux
# sed -I ‘s/ SELINUX=enabled/ SELINUX=disabled/’ /etc/selinux/config 永久关闭selinux 重启后生效
配置本地yum源
# mount -o loop RHEL_6.8_64bit.iso /mnt/cdrom/ // 重启后会需要重新挂载 需要将文件传入服务器,如果是虚拟机可以将盘挂载.
# yum clean all
# vim /etc/yum.repos.d/rhel-source.repo
[local]
name=local_source
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
# yum makecache //使用之前的配置生效
二、 安装mariadb所需环境
安装maridb依赖文件
# yum install -y binutils binutils-devel gcc gcc-c++ glibc glibc-devel-* make libgcc libstdc++ libstdc++-devel autoconf automake unixODBC unixODBC-devel readline readline-devel mysql-connector-odbc
安装MariDB需要升级glibc、升级gcc,gcc升级依赖(mpfr、mpc、gmp)。
# mkdir /usr/local/glibc
# mkdir /usr/local/gcc
升级glibc
# tar -xvf glibc-2.15.tar.gz -C /usr/local/glibc
# tar -xvf glibc-ports-2.15.tar.gz -C /usr/local/glibc
# mv /usr/local/glibc/glibc-ports-2.15 /usr/local/ glibc/glibc-2.15/ports
# mkdir /usr/local/glibc/glibc-build-2.15
# cd /usr/local/glibc/glibc-build-2.15
# ../glibc-2.15/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
# make -j4
# make install
升级gcc
安装gmp(gcc依赖文件)
# tar jxvf gmp-4.3.2.tar.bz2 -C /usr/local/gcc
# cd /usr/local/gcc/gmp-4.3.2
# ./configure && make -j4 && make install
安装mpfr(gcc依赖文件)
# cd /usr/local/gcc-4.8.0
# tar jxvf mpfr2.4.2.tar.bz2
# cd mpfr-2.4.2
# ./configure && make -j4 && make install
安装mpc(gcc依赖文件)
# cd /media
# tar -xvf mpc-0.8.1.tar.gz -C /usr/local/gcc
# cd /usr/local/gcc/mpc-0.8.1
# ./configure && make -j4 && make install
添加环境变量
# vi /etc/profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
# source /etc/profile
安装gcc
# tar jxvf gcc-4.8.0.tar.bz2 -C /usr/local/gcc
# mkdir /usr/local/gcc/gcc-build
# cd /usr/local/gcc/gcc-build
# ../gcc-4.8.0/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib && make -j4 && make install
# rm -rf /usr/lib64/libstdc++.so.6
# cp /usr/local/lib64/libstdc++.so.6.0.18 /usr/lib64
# ln -s libstdc++.so.6.0.18 libstdc++.so.6
安装Maridb
# groupadd mysql
# useradd -g mysql mysql
# tar -zxvpf mariadb-10.1.19-linux-glibc_214-x86_64.tar.gz -C /usr/local
# cd /usr/local
# ln -s /usr/local/mariadb-10.1.19-linux-glibc_214-x86_64 /usr/local/mysql
# /usr/local/mysql/scripts/mysql_install_db --user=mysql //MariaDB初始化
# chown -R root.root /usr/local/mysql
# chown -R mysql.root /usr/local/mysql/data
# ./bin/mysqld_safe --user=mysql & // 启动的时候有可能会卡死界面
添加环境变量
# vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin/
# source /etc/profile
配置服务管理文件文件
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
修改配置文件
# vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysql]
default-character-set = utf8
port = 3306
[mysql.server]
user=mysql
basedir=/usr/local/mysql
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
socket=/var/lib/mysql/mysql.sock
# vi /etc/odbc.ini
[test]
Description = Data Source to MySQL
Driver = MySQL
Server = 127.0.0.1
port = 3306
启动服务
# service mysql.server start
# chkconfig mysql.server on
安装Tomcat所需环境
解压JDK
# tar -xvf jdk-8u111-linux-i586.tar.gz -C /usr/local
创建软链接
# ln -s /usr/local/jdk1.8.0_111 /usr/local/jdk
配置环境变量
# vim /etc/profile
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=$JAVA_HOME/jre
export JAVA_BIN=/usr/local/jdk/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
# source /etc/profile //刷新环境变量
安装tomcat
解压tomcat
# tar -xvf apache-tomcat-8.5.24.tar.gz -C /usr/local
创建软链接
# ln -s /usr/local/ apache-tomcat-8.5.24 /usr/local/tomcat
配置环境变量
# vim /etc/profile
export CATALINA_BASE=/usr/local/tomcat
export CATALINA_HOME=/usr/local/tomcat
export PATH=$PATH:$TOMCAT_HOME/bin
启动tomcat
# /usr/local/tomcat/bin/startup.sh 或 /usr/local/tomcat/bin/catalina.sh start
停止tomcat
# /usr/local/tomcat/bin/shutdown.sh 或 /usr/local/tomcat/bin/catalina.sh stop