The project needs to be deployed to a CentOS server, which has previously installed a nginx and MySQL, runs a PHP environment, and has a project running. And our latest project is written in Java, the server is using Tomcat, so there is bound to be nginx and Tomcat to do a consolidation, but the project is still in the development phase, we first use tomcat default 8080 port, OK, the following is probably your "terminal" ( Because I am using the Mac system, the default is SSH, if the win system, please choose other corresponding tools, I believe that g God will help you ~ ~).
First step: Connecting to the server
The leased server supports SSH connections, which means that graphics are out of our way and we can enjoy the "Ace" feeling
Enter the following command at the terminal:
Copy Code code as follows:
SSH server IP address-L user name
After the carriage return, the screen displays something similar to the following:
Copy Code code as follows:
User name @ server IP address ' s password:
Directly in the back of the password is, in order to be safe, you enter the content is really invisible, do not doubt your eyes, do not doubt your keyboard, do not doubt your hand, you dare to enter the password bar, please remember, you have three times a chance Oh ~
When you see the following words, congratulations, you have logged into the server, you can do whatever you want ~ haha
Copy Code code as follows:
[User name @ server IP address ~]#
Step Two: Uninstall the open JDK
Cent OS defaults to install an open JDK for us, but we don't appreciate it, we prefer to use the sun's JDK to reduce the hassle, so we have to uninstall the open JDK first.
First, we'll use the following command to find out what we've installed. Java-related
Copy Code code as follows:
The information returned on my server is as follows:
Copy Code code as follows:
Xmlrpc-javadoc-2.0.1-3jpp.1
Gcc-java-4.1.2-48.el5
java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp.115
java-1.4.2-gcj-compat-javadoc-1.4.2.0-40jpp.115
Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
java-1.4.2-gcj-compat-src-1.4.2.0-40jpp.115
Bsh-javadoc-1.3.0-9jpp.1
java-1.4.2-gcj-compat-devel-1.4.2.0-40jpp.115
This inside we actually really want to delete is Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5 and java-1.4.2-gcj-compat-1.4.2.0-40jpp.115 on it, use the following command to be able to handle separately:
Copy Code code as follows:
RPM-E--nodeps Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
RPM-E--nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Well, finally, I'll verify that OPENJDK is really uninstalled:
Copy Code code as follows:
The system returns the following contents:
Copy Code code as follows:
-bash:/usr/bin/java:no such file or directory
Well, now that we've got the open jdk completely done, we have to thank rpm and save a lot of things.
Step three: Get Software (JDK\TOMCAT)
We go to Sun's official and Apache website to download JDK and Tomcat to the local computer, download the following address:
Jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk6-downloads-1637591.html
I choose
This version, 64-bit version, for RPM, and now the project does not use any JAVA7 advanced features, we should be honest with JDK6 bar.
Tomcat:http://labs.renren.com/apache-mirror/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz
Tomcat this decompression on the use of green software is the best, less annoying things, continue to the same old version of the document, over paragraph selected Tomcat6.
Here we are to upload these two files to my other FTP server, and then use wget this tool to download two software to the server, wget This tool is a simple and powerful download weapon, in fact, we can also choose to download directly from the official web, However, because the JDK must manually agree to a protocol, so at that time to use FTP as a transit point, the specific command line is as follows:
Copy Code code as follows:
wget ftp://ftp Server Address/jdk-6i33-linux-x64-rpm.bin
Copy Code code as follows:
wget ftp://ftp server address/<span style= "Font-family:consolas, Lucida Console, monospace;" ><span style= "WHITE-SPACE:PRE-WRAP;" >apache-tomcat-6.0.35.tar.gz</span></span>
Pay special attention here that you are executing this command in that directory and the file will be downloaded in that directory. For the students who are not familiar with Linux, still need to remember a few main folders and uses, lest waste time.
Fourth Step: Install JDK
Execute the following command directly in the directory where you just downloaded the software:
Copy Code code as follows:
./jdk-6u33-linux-x64-rpm.bin
Then the screen will show progress, after completion, or test it, enter:
Copy Code code as follows:
If the following content is displayed, congratulations, the Java environment has been done!
Copy Code code as follows:
Java Version "1.6.0_33"
Java (TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot (TM) 64-bit Server VM (build 20.8-b03, Mixed mode)
Fifth step: Install Tomcat Setup Tomcat is actually quite simple, first select a directory, usually using the/usr/local directory, use the CD command to jump:
Copy Code code as follows:
The directory is then downloaded from Tomcat's official web, and the command is:
Copy Code code as follows:
wget http://labs.mop.com/apache-mirror/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz
And then unzip this compressed package file
Copy Code code as follows:
TAR-ZXVF apache-tomcat-6.0.35.tar.gz Tomcat
This time using the LS command you can see a directory called Tomcat. So Tomcat is installed, easy. Starting Tomcat is also simple, go directly to the Tomcat/bin directory, and execute:
Copy Code code as follows:
If there is no error, congratulations, this time you directly in the browser input your IP (or domain name): 8080, you can see the three-legged cat. If you start an error, or do not see the three-legged cat, probably because of a configuration file where I was modifying the/etc/profile file on the last line added the following:
Copy Code code as follows:
Export java_home=/usr/java/jdk1.6.0_33/
Export JRE_HOME=/USR/JAVA/JDK1.6.0_33/JRE
Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH
Export lasspath=.:/ Usr/java/jdk1.6.0_33/lib:/usr/java/jdk1.6.0_33/jre/lib: $CLASSPATH
Export Tomcat_home=/usr/local/tomcat
Then go back to the command line and execute:
Copy Code code as follows:
So that we have just the configuration effective, so you can try again, should be OK, but be sure to note that the directory is correct, must!
Sixth step: Configure MySQL (for garbled)
Because I got the server, MySQL has been installed, when the thought is easy, but then the project deployment, English is no problem, but the Chinese have become hello, let me very angry, after a Google, once again sacrificed, Utf-8 Dafa, Make sure all the codes are utf-8. If you are also experiencing this problem, I believe the following content can help you.
1, log in to the database:
Copy Code code as follows:
Then enter the password, you can see the following after the return of the login success:
Copy Code code as follows:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 11218
Server version:5.0.95 Source Distribution
Copyright (c), the Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark the Oracle Corporation and/or its
Affiliates. Names may trademarks of their respective
Owners.
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql>
2 Select the database to change the encoding
Copy Code code as follows:
3 Check the current database encoding situation
Copy Code code as follows:
Show variables like "%char%";
The results returned on my machine are as follows:
Copy Code code as follows:
+--------------------------+----------------------------+
| variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | Latin1 |
| character_set_connection | Latin1 |
| Character_set_database | UTF8 |
| Character_set_filesystem | binary |
| Character_set_results | Latin1 |
| Character_set_server | UTF8 |
| Character_set_system | UTF8 |
| Character_sets_dir | /usr/share/mysql/charsets/|
+--------------------------+----------------------------+
8 rows in Set (0.00 sec)
Of these attributes, our goal is to change all those encodings to utf-8, and after I test them, the real effect should be character_set_database\character_set_server\character_set_ System this three values, especially the first one, if it is not utf-8, no matter what will be the question mark, and as the above results, Chinese is actually showing normal, which I also feel very strange also.
4 Modify the encoding of the database to Utf-8 and execute the following statement
Copy Code code as follows:
Special note, in MySQL, Utf-8 code in the middle is not a connector, this particular note!
5 Exit MySQL
Copy Code code as follows:
6 Edit MySQL configuration file
Copy Code code as follows:
7 Modify the configuration file as follows:
Copy Code code as follows:
[Mysqld]
Datadir=/var/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
Default-character-set = UTF8
# Default to using the old password format for compatibility with MySQL 3.x
# clients (those using the Mysqlclient10 compatibility package).
Old_passwords=1
# Disabling Symbolic-links is recommended to prevent assorted security risks;
# to does so, uncomment this line:
# symbolic-links=0
[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
In fact, add the following sentence:
Copy Code code as follows:
Default-character-set = UTF8
8 Restart MySQL
Copy Code code as follows:
This configuration down, the database garbled problem can be solved.
Of course, the database garbled is not only the database configuration problem, but also because of the page file itself encoding, paging file to the program coding and other places to pay attention, the current solution is in fact unified into utf-8!
Seventh Step: Deploy code
Because we only run a project, there is no directory configuration, directly to the project file packaging, extracted into the Tomcat directory under the WebApps directory can be.
Then reboot the server and fix it!
Tomcat's startup command:
Copy Code code as follows:
Tomcat's Stop command:
Copy Code code as follows:
Postscript:
In fact, the note began to be written at the end of June, when the project was first deployed to the server, a variety of problems two nights, all kinds of search, but unfortunately their knowledge management did not do well, a lot of good information so put the past, each encounter the same problem, all want to search again, desperately want to search keywords, Very mad, this is only for the deployment of the time to tidy up. Where the mistakes and omissions, welcome to point out!
Besides, I've had two problems recently.
11 times, when the Tomcat server was stopped, Tomcat was immediately turned on, then it was occupied by the http://pmfou-site.iteye.com/blog/1484447, followed by the method mentioned here:
"We ps-ef|grep Java
Find all Java process numbers
Kill-9 Process Number
Kill the process, except username xxx xxx 0 20:56 pts/0 00:00:00 grep--color=auto java "
But when I actually do it, every kill process is reported without this process, which is normal after a variety of reboots.
2 and then the next day, the server often on its own down, I suspect that the problem caused by yesterday, and then look at the log, found that the memory overflow, in fact, because I was lazy, the project backup has done WebApps, so every time you start Tomcat will be brought up, This can then cause a memory overflow, or it may be because our JVM also uses the default configuration reason. After you delete those backups, the server is functioning as it is!!