Install Nginx + Tomcat + MySQL server in CentOS

Source: Internet
Author: User
& Nbsp; linux has been around for a long time and has never been used. Recently I want to deploy some small applications I have developed on linux servers. By the way, I also want to learn about linux servers. Then I configured a host (a common pc, and now I feel that the stability of the pc is still good, and it is not a big project), and then I put the server

Linux has been around for a long time and has never been used. Recently I want to deploy some small applications I have developed on linux servers. By the way, I also want to learn about linux servers. Then I configured a host (a common pc, and now I feel that the stability of the pc is still good, and it is not a big project), and then I put the server in their office, then install CentOS5.2 and you will be ready to use it. The installation process is relatively simple. the installation process is basically smooth. only the driver of the NIC is not found, and I downloaded one from the internet and press OK.

After installing the system, set the IP address of the server. because my server is in the office, I need remote control. Select the IP address and DNS, and then let the server run there.
 
Go back to my laptop and install a very small but very useful tool for remote linux control using PUTTY. then install WINSCP and use ssh to implement file transfer between windows and linux servers. In the next step, you can use the remote control server to install other servers.
 
I use linux here mainly to use it as a WEB server, and I generally use java for development, that is, the CentOS + nginx + tomcat + MySQL architecture. The benefits of using CentOS are everywhere on the Internet, and of course there are also their shortcomings. I am not very proficient in this, but just use it as a tool. If you select nginx but not apache, nginx is faster in processing static files, responds to a larger number of concurrent requests, and consumes less resources, nginx can only take advantage of the linux operating system. it is not recommended to use nginx on Windows, and nginx can also be used for load balancing and configuration is quite convenient. In fact, tomcat has always been intended to be replaced, but from the very beginning Learning java development, tomcat is used, and others are not very familiar. However, some data shows that tomcat is relative to servers such as jboss, the speed will be slightly advantageous. of course, this is also caused by the more powerful jboss functions. because JBOSS's advanced functions were not used at the time, it was temporarily set to tomcat, the java B/S program that is not familiar with the SSH structure still runs smoothly. More importantly, the advantages of MySQL.
 
First, upload the installation source files or RPM of nginx, jdk, tomcat, and mysql to the linux server using winscp. Then install these servers separately.
 
1. install nginx:
 
This installation should be the simplest, directly tar-xzvf Nignx-0.8.31.tar.gz to expose nginx, and then enter the directory after decompression
 
./Configure -- prefix =/usr/local/nginx
 
Make
 
Make install
 
Now nginx is installed. Start it,
 
/Usr/local/nginx/sbin/nginx startup is complete.
 
Http: // 127.0.0.1. if you try welcome Nginx, install OK.
 
2. install jdk
 
I downloaded the jdk binfile and run it directly.
 
. /Usr/local/jdk1.6 .*. after running bin, you can find that a jdk1.6. * directory is added under the/usr/local directory, so that jdk installation is complete, and then set the jdk environment variable, data in the remote Black window of linux is java-version. if the correct version is displayed, you will succeed.
 
3. install tomcat
 
This is also the installation of .tar.gz, which is similar to nginx installation.
 
Tar-zxvf tomcat-5.0 .*
 
./Configure
 
Make
 
Make install
 
4. install mysql
 
The rpm format is used here. There are two files in total, one server and one client.
 
Installation is complete. if you enter
 
Mysql. if it works properly, it indicates that the installation is successful. add the user name to the root user.
 
Mysql-u root-p and enter your password.
 
There is a big difference between installing mysql on linux and using it on windows.
 
First cp a my. cnf file to/etc, and then modify the encoding (UTF-8 or GB2312 ......), Otherwise, Chinese characters are not supported.
 
Mysql can be used on the server, but it may not be allowed to log on to mysql using a remote client because remote logon is not allowed when linux is installed on linux by default. grant select, insert, updata, delete *. * on * @ ** upgrade the permission of your machine.
 
When I first installed these software in linux, there were many differences with the installation on windons.
 
The rest is to modify the configuration, boot automatically, and then optimize the server. during installation, there will still be a lot of detours, making it easier to write.
 
After installing the above server, I want to install another subversion server and manage the version of my program. At first I thought it would be very simple, but I did not expect it to take me two days.
 
In the first use of the system's built-in apache, and then use the yum-installed subversion, do not know why, use a file conflict, there is no way, had to unload apache and subversion, we recommend that you install the subversion server on your own and install the source file. If it is not easy to install, it is difficult to solve problems later.
 
Then download the httpd and subversion installation files again,
 
1. install apache
 
Tar-xzvf httpd-2.3. * .tar.gz
 
 
 
./Configure -- enable-MoD-shared = all
-- With-mpm = worker
-- Enable-nonportable-atomics = yes
-- Enable-static-support
 
Make
 
Make install
 
After the installation, nginx has occupied Port 80 and does not allow apache to use it. then, modify the apache configuration file and change the port to port 81. at this time, nginx is not allowed,
 
Semanage port-a-t http_port_t-p tcp 81
 
The above is a command that has been found for a long time to grant it Port 81.
 
2. install the subversion server
After decompression, decompress SQLITE first (sqlite is also required here because I am prompted that my version is insufficient) and create a folder named sqlite-amalgamation in subversion, copy one of the sqlite3.c files to this folder. /configure -- prefix =/usr/local/subversion -- with-apr =/usr/local/apache -- with-apr-util =/usr/local/apache -- with-apxs = /usr/local/apache/bin/apxs
Makemake install is installed in this way. The subversion installed in this way will automatically add the load modules to apache as httpd. conf .... You can use it with a slight modification...
 
As a result, subversion can also be used. The rest is to continue to complete my program, run, test ....
 
---------------
 
How can Nginx be associated with tomcat?
 
 
Location ~ ^/Shoplist.shtml {
Proxy_set_header Host $ host;
Proxy_set_header X-Forwarded-For $ remote_addr;
Proxy_pass http: // localhost: 5080;
Expires 1d;
}
 
As long as dynamic content is transferred to tomcat, nginx will send a proxy request to respond to dynamic content and then return it to the client ..

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.