How To Install Java, MySQL, Nginx, Tomcat On CentOS 7
rpm -ivh jdk-8u311-linux-x64.rpm
Install OpenJDK 8
Install OpenJDK 8 JRE
sudo yum install java-1.8.0-openjdk
Install OpenJDK 8 JDK
sudo yum install java-1.8.0-openjdk-devel
Verify Java is Installed
java -version
javac -version
Find Java’s Path
update-alternatives --config java
Setting Java’s Path in Your Environment
vi .bash_profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
export PATH=$JAVA_HOME/bin:$PATH
source .bash_profile
echo $JAVA_HOME
output:
/usr/lib/jvm/java-1.8.0-openjdk
which java
readlink -f $(which java)
which javac
readlink -f $(which javac)
Installing MySQL on Linux Using the MySQL Yum Repository
Steps for a Fresh Installation of MySQL
1. Adding the MySQL Yum Repository
- Go to the Download MySQL Yum Repository page (https://dev.mysql.com/downloads/repo/yum/) in the MySQL Developer Zone.
- Select and download the release package for your platform.
- Install the downloaded release package with the following command.
For an EL7-based system:
sudo yum install mysql80-community-release-el7-{version-number}.noarch.rpm
For an EL8-based system:
sudo yum install mysql80-community-release-el8-{version-number}.noarch.rpm
You can check that the MySQL Yum repository has been successfully added by the following command:
yum repolist enabled | grep "mysql.*-community.*"
2. Selecting a Release Series
yum repolist all | grep mysql
3. Disabling the Default MySQL Module
(EL8 systems only) EL8-based systems such as RHEL8 and Oracle Linux 8 include a MySQL module that is enabled by default. Unless this module is disabled, it masks packages provided by MySQL repositories. To disable the included module and make the MySQL repository packages visible, use the following command:
sudo yum module disable mysql
4. Installing MySQL
Install MySQL by the following command:
sudo yum install mysql-community-server
This installs the package for MySQL server (mysql-community-server) and also packages for the components required to run the server, including packages for the client (mysql-community-client), the common error messages and character sets for client and server (mysql-community-common), and the shared client libraries (mysql-community-libs).
5. Starting the MySQL Server
sudo service mysqld start
sudo service mysqld status
At the initial start up of the server, the following happens, given that the data directory of the server is empty:
- The server is initialized.
- SSL certificate and key files are generated in the data directory.
- validate_password is installed and enabled.
- A superuser account 'root'@'localhost is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
sudo grep 'temporary password' /var/log/mysqld.log
Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:
mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Java2Spring!';
Installing Additional MySQL Products and Components with Yum
sudo dnf install mysql-workbench-community
Install Nginx
sudo yum install -y gcc-c++
sudo yum install -y pcre pcre-devel
sudo yum install -y zlib zlib-devel
sudo yum install -y openssl openssl-devel
Add Nginx Repository
sudo yum install epel-release
Install Nginx
sudo yum install nginx
Start Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
Install Tomcat
unzip ~/Downloads/apache-tomcat-8.5.56.zip
mv ~/Downloads/apache-tomcat-8.5.56 ~
sudo ln -s ~/apache-tomcat-8.5.56 ~/tomcat
sudo chown -R <username> ~/tomcat
sudo chmod +x ~/tomcat/bin/*.sh
~/tomcat/bin/startup.sh
~/tomcat/bin/shutdown.sh
参考
https://www.liquidweb.com/kb/install-java-8-on-centos-7/
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7
https://wolfpaulus.com/tomcat/