**1. Project Essential Software and Basic Ideas**
Project prerequisites:
Virtual machine: VMware Workstation (CentOS 6.5 with Linux installed)
Project: Java web project (after local deployment, you must select the project's webRoot, rename it to ROOT, which contains four key files, then place it under the webapps directory of Tomcat, because Tomcat releases a project by compiling all Java files except JSPs, so you need to compile them locally first).
Java environment configuration: Install JDK
Server: Tomcat
Database: MySQL
Basic idea: (pay attention to coding settings throughout the process)
1. Configure the Java environment (download JDK and set environment variables)
2. Download and install Tomcat (set Tomcat encoding)
3. Install MySQL and import SQL (note: set encoding on both client and server side before importing SQL, this step can take time)
4. Import the project and modify the database connection configuration
5. Start MySQL, start Tomcat, and access the project!
A small introduction to VMware Tools:
VMware Tools is now installed in CentOS (to enable file dragging between host and virtual machine). The rest of the project is not installed. Only after installing VMware Tools in the VMware virtual machine can you achieve file sharing between the host and the virtual machine, support drag-and-drop functionality, allow the mouse to move freely between the host and the virtual machine (no need to press Ctrl + Alt), and also enable full-screen display for the virtual machine.

**2. Specific Operations**
1. Check if you can connect to the network
(I use NAT mode; as long as the host has internet access and DNS is configured, the virtual machine can only access the local network. To access the internal project from the host, switch to DHCP bridge mode. See [this guide](http://blog.csdn.net/heirenheiren/article/details/17795951)).
Use `ifconfig` to find the IP address of the virtual machine (eth0 indicates the current network card).
Use `ping` to check if the network is connected.
How to set up CentOS online? See details at [this link](http://combined).
[More info here](http://jingyan.baidu.com/article/fc07f9891d186512ffe51935.html).
2. Update CentOS YUM source to Alibaba Cloud source (for downloading software packages)
Step 1: Back up the original CentOS-Base.repo file.
`mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup`
Step 2: Download the new CentOS-Base.repo file to `/etc/yum.repos.d/`
For CentOS 6:
`wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo`
Step 3: Run `yum makecache` to generate the cache.
`yum clean all`
`yum makecache`
3. Download Java environment (Java runtime environment)
(1) If installing OpenJDK, no need to configure JAVA_HOME or CLASSPATH PATH (we use this method):
`yum search java`
`yum install java-1.7.0-openjdk.x86_64`
`java -version` //Should show success
(2) Install jdk-7u21-linux-i586.rpm (install directory: `/usr/java/jdk1.6.0_21`)
`rpm -ivh jdk-7u21-linux-i586.rpm`
Configure environment variables by adding the following to `/etc/profile`:
`JAVA_HOME=/usr/java/jdk1.6.0_21`
`CLASSPATH=.:$JAVA_HOME/lib/tools.jar`
`PATH=$PATH:$JAVA_HOME/bin`
`export JAVA_HOME CLASSPATH PATH`
If OpenJDK was previously installed, additional steps may be needed.
4. Download Tomcat 7.0 (free installation version)
(1) Open Firefox, search for Tomcat, download to desktop, extract to `/usr/local`
`tar –xzf apache-tomcat-7.0.29.tar.gz`
`mkdir /usr/local/tomcat`
`cp –rf apache-tomcat-7.0.29 /usr/local/tomcat`
(2) Set Tomcat encoding and configure UTF-8:
Open `conf/server.xml` in the Tomcat installation directory (around line 69)
Set the connector tag for port 8080 to `URIEncoding="UTF-8"`
Example:
` `
(3) Start Tomcat:
`./startup.sh`
Access `http://localhost:8080` in a browser to confirm successful installation.
Small knowledge review:
After placing the project under `webapps` in the Tomcat folder,
*.tar.gz: A file compressed using tar and gzip.
Options:
- `-c` compress
- `-x` decompress
- `-t` view contents
- `-v` show file names during compression
- `-f` specify filename
- `-z` compress with gzip

5. Download and install MySQL
(1) Install MySQL:
`yum search mysql`
`yum install mysql.x86_64 mysql-server.x86_64`
(2) Set MySQL password (see [this guide](http://blog.knowsky.com/193552.htm)):
By default, MySQL has no password.
Check if MySQL is running by checking if port 3306 is open:
`netstat -anp|grep 3306`
Start MySQL:
`service mysqld start`
Login:
`mysql -uroot -p`
Edit `/etc/my.cnf` to skip authentication table:
`--skip-grant-tables`
Restart MySQL:
`service mysqld restart`
Login again and set password:
`mysql -uroot -proot`
Remove `--skip-grant-tables` from `/etc/my.cnf`, restart again.
(3) Set the database encoding format (very important):
Edit `/etc/my.cnf`:
Under `[client]`, add: `default-character-set=utf8`
Under `[mysqld]`, add:
`collation_server=utf8_general_ci`
`character_set_server=utf8`
Save and restart `mysqld`.
Check the effect:
`SHOW VARIABLES LIKE 'character_set_%';`
You should see `utf8` for most entries.
(4) Create database `dh_test` and import `dh.sql`:
`CREATE DATABASE dh_test;`
`SHOW DATABASES;`
`mysql -uroot -p dh_test < dh.sql`
`SHOW TABLES;`
`SELECT * FROM user;`
Check if Chinese characters are displayed correctly.
6. Deploy the web project and configure the database connection settings
After compiling the project locally, place all files in the `webroot` under `webapps` in `/usr/local/tomcat` on Linux, and rename `webroot` to `ROOT`.
Navigate to:
`cd ROOT/WEB-INF/classes/config/properties/database.properties`
Modify the database name to `dh`, and set the username and password according to your MySQL configuration.
7. Start MySQL and Tomcat
`service mysqld start`
`./startup.sh`
Monitor logs:
`tail -fn 300 ../logs/catalina.out`
If everything is working, the project is successfully deployed.
In the Linux Firefox browser, access the project via `localhost`.
However, ensure that the `server.xml` file in the Tomcat installation directory is properly configured (see [this article](http://blog.csdn.net/defonds/article/details/4192953)).

**Three Related Linux Commands**
Wget, RPM, and Yum: Understanding the Differences and Uses
Wget is used when you know the exact URL to download a file.
RPM is mainly used to check if a package is already installed (`rpm -qa | grep package_name`).
Yum is used to automatically find and install packages from the repository, handling dependencies automatically.
(1) **Wget**: A free tool for automatically downloading files from the web, supporting HTTP, HTTPS, and FTP protocols.
Example:
`wget http://mirrors.aliyun.com/repo/Centos-6.repo`
`wget -O wordpress.zip http://example.com/file.zip`
(2) **RPM (Red Hat Package Manager)**: Used to install, remove, and update software packages.
Examples:
`rpm -qa` – list all installed packages
`rpm -qa | grep yum` – find packages containing "yum"
`rpm -qf file_name` – check which package a file belongs to
`rpm -ql package_name` – view where a package is installed
`rpm -qi package_name` – view package information
`rpm -vih package.rpm` – install a new RPM package
(3) **Yum (Yellowdog Updater Modified)**: A front-end package manager for Fedora, Red Hat, and SUSE. It automates package management and handles dependencies.
Examples:
`yum install foo.rpm` – install a package
`yum remove foo.rpm` – remove a package
`yum upgrade foo` – upgrade a package
`yum search foo` – search for packages
`yum deplist foo` – show package dependencies

Cathodic Protection Cable,Hmwpe Cable,Cathodic Cable,Cathodic Wire
HENAN QIFAN ELECTRIC CO., LTD. , https://www.hnqifancable.com