Building a java web test environment in linux environment

**1. Project Essential Software and Basic Ideas** Project prerequisites: Virtual machine: VMware Workstation (CentOS 6.5 with Linux installed) Project: Java web project (you must select the project's webRoot after local deployment, change it to ROOT, which contains the following four key files), place it under the webapps folder of Tomcat, because Tomcat releases a project, including all compiled Java files, so you can only deploy locally to generate the class files). Java environment configuration: Configure JDK Server: Tomcat Database: MySQL Basic idea: (pay special attention to coding settings throughout) 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: MySQL client and server-side encoding settings; you must set them up before importing SQL, this step takes time) 4. Import the project and modify the database connection configuration 5. Start MySQL, start Tomcat, and access it! A brief introduction to VMware Tools: Now CentOS has installed VMware Tools (to enable file dragging between host and virtual machine), and the rest of the project is not installed. Only when VMware Tools is installed in the VMware virtual machine can the host and virtual machine share files. It also supports free drag and drop, and the mouse can move freely between the host and the virtual machine (no need to press Ctrl + Alt), and the virtual machine screen can be fully displayed. ![Building a Java Web Test Environment in Linux Environment](http://i.bosscdn.com/blog/pI/YB/AF/pxmhOAU9t4AAB6Tj3OocE899.jpg) **2. Specific Operations** 1. Check if you can connect to the network (I use NAT mode; as long as the host has network access, DNS is configured, this allows access within the virtual machine, but the host cannot access the internal project. Switch to DHCP bridge mode for external access. See [this guide](http://blog.csdn.net/heirenheiren/article/details/17795951)) > ifconfig (find the virtual machine's IP address) eth0 indicates the current network card name > ping (check if the network is connected) How to configure CentOS online? See details at [this link](http://combined). [This guide](http://jingyan.baidu.com/article/fc07f9891d186512ffe51935.html) provides more information. 2. Update CentOS YUM source to Alibaba Cloud Step 1: Backup the original repository file to avoid errors > mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup Step 2: Download the new CentOS-Base.repo 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: Generate 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) > yum search java (look for java-1.7.0-openjdk.x86_64) > yum install java-1.7.0-openjdk.x86_64 > java -version //shows success (2) Install jdk-7u21-linux-i586.rpm (installation path: /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 previously installed OpenJDK, additional steps may be required. 4. Download Tomcat 7.0 (free version) (1) Start Firefox browser, 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 server.xml to UTF-8 (very important!!) Open conf/server.xml and add URIEncoding="UTF-8" to the connector tag on port 8080. (3) Start Tomcat > ./startup.sh Access http://localhost:8080 in a browser; if the default page appears, installation is successful. Small knowledge review: Place the project under webapps in the Tomcat folder. *.tar.gz: Data packaged by tar and compressed with gzip. -c: compress -x: decompress -t: view tar file -v: display filenames during compression -f: specify filename -z: compress with gzip ![Building a Java Web Test Environment in Linux Environment](http://i.bosscdn.com/blog/pI/YB/AF/pxmj6AGej5AABou2_TgOI516.jpg) 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) for details) Default password is empty. Check if MySQL is running: > netstat -anp | grep 3306 Start service: > service mysqld start Login: > mysql -uroot -p Edit /etc/my.cnf to skip grant tables: > vim /etc/my.cnf Add --skip-grant-tables Restart service: > service mysqld restart Login again and set password: > mysql -uroot -proot Remove --skip-grant-tables from my.cnf Restart service: > service mysqld restart (3) Set database encoding format (very important) Edit /etc/my.cnf: Under [client], add default-character-set=utf8 Under [mysqld], add collation_server=utf8_general_ci and character_set_server=utf8 Save and restart mysqld. Check the effect: > show variables like 'character_set_%'; (4) Create database dh_test and import dh.sql > create database dh_test > use dh_test > source dh.sql > show tables > select * from user 6. Deploy the web project and configure database connection After compiling locally, place all webroot files under webapps in Tomcat, and rename webroot to ROOT. > cd ROOT/WEB-INF/classes/config/properties/database.properties Modify database name to dh, username and password match MySQL settings. 7. Start MySQL and Tomcat > service mysqld start > ./startup.sh > tail -fn 300 ../logs/catalina.out If startup is successful, the project is deployed. Access the project via Firefox browser at localhost. Note: Ensure you have modified Tomcat's server.xml first. See [this article](http://blog.csdn.net/defonds/article/details/4192953). ![Building a Java Web Test Environment in Linux Environment](http://i.bosscdn.com/blog/o4/YB/AF/pxmlGARQjUAAAohc6uyPA876.jpg) **Three Related Linux Commands** Wget, RPM, and YUM are commonly used in Linux. Wget is used to download files from a specific URL. RPM is used to manage software packages. YUM is a tool that automatically handles dependencies and installs packages. (1) Wget: A command-line utility for downloading files over HTTP, HTTPS, and FTP. Example: > wget http://mirrors.aliyun.com/repo/Centos-6.repo > wget -O wordpress.zip http://example.com/wordpress.zip (2) RPM: Red Hat Package Manager. Used for installing, removing, and updating software. Examples: > rpm -qa | grep yum > rpm -vih package.rpm (3) YUM: A package manager that automatically resolves dependencies. Examples: > yum install foo-xxxrpm > yum remove foo-xxxrpm > yum update foo ![Building a Java Web Test Environment in Linux Environment](http://i.bosscdn.com/blog/o4/YB/AF/pxmmmAWaF1AABkoCwHrZ0416.jpg)

All Aluminum Alloy Conductor

All Aluminum Alloy Conductor,Aaac Conductor,Aluminum Alloy Wire,All Aluminum Alloy Wire

HENAN QIFAN ELECTRIC CO., LTD. , https://www.hnqifancable.com