Install Tomcat JDK MySQL under Linux

Tomcat service setup steps

I. Initialization of the environment (starting with the first graphical interface entered after installation)

Configure the server to work in command line mode

  • alt + ctrl + f3 temporarily enter command line mode, effective in time
  • Vim/etc/inittab Modify the bottom number 5 to 3

Close iptables and selinux

  • service iptables stop temporarily closes the firewall and takes effect in time
  • Chekconfig iptables off shutdown firewall service boot-up

Configure the local YUM source

  • a. Put the shutdown into the CD-ROM drive
  • b. Mounting CD-ROM to the system
    mount -t iso9660 /dev/cdrom /mnt/cdrom
  • c. Modifying the yum configuration file
cd /etc/yum.repos.d/
mkdir back
mv * back/
cp back/CentOS-Media.repo .
vim CentOS-Media.repo
    baseurl=file://mnt/cdrom
    enabled=1
    gpgchek=0

Restart the server to display the demo effect

reboot

2. The environment needed to install tomcat

Install gcc and lrzsz

  • Yum-y install gcc* install the software needed to compile the source package
  • Yum-y install lrzsz installation can be uploaded and downloaded through the xshell terminal

Installing JDK

  • 1. Decompress JDK package
    If there are ISO packages, mount-o loop tomcat.iso/iso/tomcat
tar -zxvf jdk.....tar.gz -C /usr/local   Unzip to the specified directory
cd /usr/local
mv jdk1.7.0_25 jdk   Modify directory name
  • 2. Configuring JDK environment variables
vim /etc/profile
        //Add at the bottom of the document:
        # JDK
        export JAVA_HOME=/usr/local/jdk
        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
        export JAVA_HOME JAVA_BIN PATH CLASSPATH
source /etc/profile Refresh environmental variables to take effect

Install Tomcat

  • 1. Unzip Tomcat package to / usr/local directory
tar -zxvf apache-tomcat....tar.gz -C /usr/local    Unzip to the specified directory
cd /usr/local
mv apache-tomcat-7.0.42 tomcat    Modify directory name
  • 2. Configuring Tomcat's environment variables
vim /etc/profile
        #TOMCAT
        export TOMCAT_HOME=/usr/local/apache-tomcat-7.0.37
        export PATH=$PATH:$TOMCAT_HOME/bin
source /etc/profile Refresh environmental variables to take effect
  • 3. Start tomcat program
chmod 777 /usr/local/tomcat/bin/*.sh
tomcat Open: /usr/local/tomcat/bin/catalina.sh start

Install MySQL

  • * Installation dependency package: yum-y install ncurses-devel
  • 1. Decompression
tar -zxvf mysql-5.1.55.tar.gz -C /tmp    
cd /tmp/mysql...
  • 2. Install mysql
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=gbk,gb2312
make
make install
cp -f support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
ln -s /usr/local/mysql/bin/* /usr/local/bin/ Simplify the call path (unchangeable)
ln -s /usr/local/mysql/lib/mysql/* /usr/lib
ln -s /usr/local/mysql/include/mysql/* /usr/include/
useradd -M -s /sbin/nologin mysql Creating database users
mysql_install_db --user=mysql Initialize the database
cd /usr/local/mysql/
chown -R root:mysql .
chown -R mysql var/
service mysqld start
mysqladmin -uroot password '123456'

Three Adding MySQL Users

  • create user `user'@'login address' identified by `password';
  • grant permission on database. Datasheet to'user'@ login address' identified by'password';
//Enter mysql administrator user
mysql -uroot -p    
//Create user subnit to allow remote login only
create user 'subnit'@'%' identified by '123456';   
//Give remote login user subnit all permissions to view all databases
grant all on *.* to 'subnit'@'%' identified by '123456'; 
//Give users the right to log in locally
grant all on *.* to 'subnit'@'localhost' identified by '123456'; 

Note: Setting the login address to'localhost'allows only local login, not remote login; setting the login address to'%' allows any remote host to login, not local login;
Note: grant all on. to'zhangsan'@'localhost' identified by'123456'; grant all permissions for Zhang San to log in locally

Four Deployment java Warpackages

1. Add in the Host area at the bottom of the / usr/local/tomcat/conf/server.xml configuration file

vim /usr/local/tomcat/conf/server.xml

Add to

<Context path="" docBase="war Package name" debug="0" privileged="true"/>
  1. Copy war into / usr/local/tomcat/webapps directory and delete ROOT directory
cp **.war /usr/local/tomcat/webapps
 rm -rf /usr/local/tomcat/webapps/ROOT
  1. Restart tomcat service
/usr/local/tomcat/bin/catalina.sh start
  1. The original tomcat uses 8080 port for access, changes the port to 80 using IP direct access, and also modifies the configuration of / usr/local/tomcat/conf/server.xml.
    Change 8080 to 80

Keywords: Tomcat MySQL JDK yum

Added by MaxD on Wed, 26 Jun 2019 01:58:12 +0300