A simple tutorial for installing JDK, MySql, Tomcat under Linux


JDK installation

Install JDK with yum
1. Check which jdk versions are in the yum library (only openjdk has been found for the time being)

[root@localhost ~]# yum search java|grep jdk

2. Select the version to install
//Select version 1.8 to install

[root@localhost ~]# yum -y install java-1.8.0-openjdk

//After installation, the default installation directory is:

/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64

3. Set environment variables

 [root@localhost ~]# vi /etc/profile

Add the following to the profile file

#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效
[root@localhost java]# source /etc/profile

MySQL installation


If you don't have wget, please use the following command to install

yum -y install wget

1. Download the repo source of mysql

$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. Install the mysql-community-release-el7-5.noarch.rpm package After
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
installing this package, you will get two mysql yum repo sources:
/etc/yum.repos.d/mysql-community.repo,
/etc/ yum.repos.d/mysql-community-source.repo.
3. You can install mysql
$ sudo yum install mysql-server
according to the prompts, but there is no password after the installation, you need to reset the password
4. Reset the mysql password
$ mysql -u root
login may report such an error:
ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘
(2), the reason is /var Access permission issues for /lib/mysql. The following command changes the owner of /var/lib/mysql to the current user:
$ sudo chown -R root:root /var/lib/mysql
Restart the mysql service
$ service mysqld restart
Then log in to reset the password:
$ mysql -u root //Enter the mysql console directly

mysql > use mysql;
mysql > update user set password = password('root')  where `user` = 'root';//注意字符串要加单引号,否则会出错
mysql > FLUSH PRIVILEGES;//更新权限

Finally, attach the command to create a user who can log in to the database remotely
(% means that you can log in from the external network)

CREATE USER 'username'@'%' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'username'@'%';

Or increase root account permissions

grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;

Finally, remember to update the permissions and make sure that the 3306 port is not blocked by the Linux firewall


Tomcat installation (9.0.6)


1. First download apache-tomcat-9.0.6.tar.gz from the Tomcat official website
2. Unzip it in the current folder using the command

tar zxf filename

3. vim /etc/profileAdd tomcat path configuration

#set Tomcat
TOMCAT_HOME='/root/apache-tomcat-9.0.6 '
PATH=$PATH:$TOMCAT_HOME/bin
export TOMCAT_HOME  PATH

4.startup.sh starts, pay attention to the firewall. . . . . . Be sure to add port 8080 (default). The Tmocat installed by the blogger is version 9.0. It starts very fast, but it takes a long time to load when you first enter the website. . . . normal operation after that. . . . . . .
5. However, the blogger found the reason. . Startup is slow because time is mostly spent instantiating the SecureRandom object. The detailed content of the blogger is not very understood at present, but it is because of it that the startup is too slow


Workaround: use vim $JAVA_HOME/jre/lib/security/java.security
find a line called securerandom.source=file:/dev/random
and change it tosecurerandom.source=file:/dev/./urandom


Linux supports Chinese

1. First use locale to check whether the Chinese package is installed. If the following content appears, it means it has been installed

zh_CN
zh_CN.gb18030
zh_CN.gb2312
zh_CN.gbk
zh_CN.utf8

If not, use yum groupinstall "fonts"install

2. Modify the locale.conf file and add LANG=”zh_CN.UTF-8”

vim /etc/locale.conf

3. If you use third-party software to remotely log in to the cloud host, please set support for UTF-8 in the settings of the software you are using, otherwise the terminal will still be garbled


.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325386018&siteId=291194637