Linux deployment project (Java project + Tomcat + mysql) Tomcat
After the project is finished, it will be released. one of Java's specialties is good portability. in the face of Microsoft's XP service stop, Windows system's "dictatorship ", more and more merchants choose open-source free linux systems as servers. Because the linux system also has a graphical interface (although very different from Windows), it is relatively easy to operate in the graphic interface. this is like deploying a project on Windows, most people use small cases. However, in real work, servers are deployed in a fixed data center, and there is usually only one host. the larger part is the use of single-chip microcomputer, which is placed on the machine rack of the data center like a book, the most common method we use to operate on it becomes remote access. Just like using the console for command input control, so that people can operate their computers back to dozens of years ago (I don't know when this approach will be reformed ), so we still need some technologies. This blog briefly describes precautions and common commands for deploying projects in linux.
Well, let's briefly deploy the Java project + Tomcat + mysql.
First, how to remotely connect to the linux system:
1. create users in linux that support remote access;
2. use the corresponding remote access software: SecureFXPortable (window) + SecureCRTPortable (console) or PUTTY (console) + RealVNCsetup (window.
3. in one piece, there are various port protocols such as ssh. a large piece of knowledge needs to be studied and will not be given here. I just got in touch with it. Search for information on the Internet.
II. MySql problems
1. if the server does not have MySql, you need to install it. you can download the green version for decompression or install it online.
A. decompress:
Zip:
Zip-r myfile.zip ./*
Compress all files and folders in the current directory into myfile.zip files.-r indicates recursively compressing all files in the subdirectory.
Unzip-q myfile.zip decompress the myfile.zip package.-q does not show the decompression process.
Tar:
The tar command can be used to compress and package a single file, multiple files, a single directory, and multiple directories.
Common formats:
Compress a single file and package tar czvf my.tar file1
Compress multiple files and package tar czvf my.tar file1 file2 ,...
Compressing and packaging a single directory tar czvf my.tar dir1
Compress multiple directories and package tar czvf my.tar dir1 dir2
Unpackage to current directory: tar xzvf my.tar
Explanation:
Tar command
[Root @ linux ~] # Tar [-cxtzjvfpPN] file and directory ....
Parameters:
-C: create a parameter command for the compressed file );
-X: Unlock the parameter command of a compressed file!
-T: view the files in the tarfile!
Note that c/x/t can only exist under the parameter! Cannot exist at the same time!
Because it is impossible to simultaneously compress and decompress.
-Z: does it have the gzip attribute at the same time? That is, do I need to use gzip for compression?
-J: does it have bzip2 attributes at the same time? That is, do I need to use bzip2 for compression?
-V: The file is displayed during compression! This is common, but it is not recommended to use it in the background execution process!
-F: use the file name. please note that the file name should be followed immediately after f! Do not add parameters!
For example, using "tar-zcvfP tfile sfile" is an incorrect method.
"Tar-zcvPf tfile sfile" is correct!
-P: use the original attributes of the original file (the attributes will not be changed based on the user)
-P: absolute paths can be used for compression!
-N: a new date (yyyy/mm/dd) will be packed into the new file!
-- Exclude FILE: Do not pack the FILE during compression!
B. install sudo apt-get installmysql-server online. during installation, you will be prompted to enter the Root password and password for confirmation.
2. of course, you also need to add roles, write configuration files, create databases, create tables, backup, and restore. each operation has a lot of corresponding code, which is not provided here, see this link: install and use MySQL in Linux
III. Tomcat usage,
1. install Tomcat by using unzip or tar commands.
A. We may create folders using Mkdir, create directories, and create folders in the front:
B. common commands such as copy, paste, and move
Cp copy:
Sudo cp ~ /ToInstall/apache-tomcat-6.0.37.tar.gz./administrator copy to current directory
Mv move [option] source file or directory target file or directory
-B: If you need to overwrite the file, back up the file before overwriting.
-F: force indicates that if the target file already exists, it is overwritten without asking;
-I: if the destination file (destination) already exists, you will be asked if it is overwritten!
-U: update is performed only when the target file already exists and the source file is updated)
-T: -- target-directory = DIRECTORYmove all SOURCE arguments into DIRECTORY, that is, the target directory of the specified music video. this option is applicable when multiple SOURCE files are moved to one DIRECTORY, after the source file is located.
2. enable and disable Tomcat:
Enabled: shstartup. sh
Close: sh shutdown. sh
View the process: ps-ef | grep tomcat (process name)
Kill process: kill-9 process no.
3. enable some auxiliary services, such as nginx:
Server nginx (service name) start
Server nginx (service name) stop
And so on. it is also implemented by linux commands. we previously clicked to implement the function.
4. during project deployment, you can directly copy the project to the Tomcat webapps Root directory or decompress the project under the specified directory, but you still need to modify some configuration files here, supporting mysql + tomcat + various auxiliary services (nginx) + Java programs.
Here we will mention the modification of the file. the Tomcat directory can be used remotely in the window to download and modify the upload overwrite form for simple operations. if you have to modify the operation file on the linux remote interface, you can use the VI editor command for implementation. simple commands:
: Set nu display row number
: Dd: delete the current row
: Wq save and exit
: Q exit
: Q! Force exit
I start editing files
Exit editing from esc
To sum up the general process of deploying a linux system project, we just sorted out the following ideas. the specific knowledge is not detailed enough. we also need to search more online. The content is not rich enough. I hope you can include more ......