Java Notes---Deploying code to Cloud Servers via Nginx and FileZilla

Source: Internet
Author: User
Tags filezilla ftp protocol

First, preface

In the previous article, you learned how to Telnet to a cloud host using SECURITYCRT, so now it's the play: How do we deploy our Java Web project to a cloud host? Please look down ...

Second, the use of Nginx

Brief introduction

To put it simply:
1. Nginx is a lightweight Web server/reverse proxy server and e-mail (IMAP/POP3) proxy Server
2. The feature is that the memory is small and the concurrency ability is strong. In the case of high connection concurrency, Nginx is a good substitute for Apache server


We use Yum to install Nginx and execute the command yum install Nginx . After installation, we try to start the Nginx, execute the command service nginx start.


Now that Nginx has successfully installed and turned on the service, should we be able to test it for normal operation? Execute command * wget *, you can see the following display:

Now that you can connect to using wget, what happens when we try to request that address on the browser? If the nginx installed on the local machine, the address is entered directly on the browser, if installed on the cloud server, then use http://Cloud Server public network IP. The results are as follows:

With these two Tests, the Nginx installation configuration is successful and can be run correctly

Deploying local Code

Just displayed on the browser side is the Nginx default index.html display interface, and the Tomcat default display is similar. The index.html is in the HTML folder under the Nginx installation directory (/usr/share/nginx/html). If we want to deploy an HTML file, we can put the file into the HTML directory and then access the on the browser side. As follows:
1. Go to the HTML directory under nginx: command * cd/usr/share/nginx/html *

2. New HTML page:* VI index.htm *, the content is as follows

3. Visit this page locally: The results are as follows

Third, the FTP service

In order to deploy the code to a remote server, we need to install the FTP service and FileZilla. This allows the code on the local Windows machine to be transferred to the remote server via the FTP protocol.

Install FTP

Under root privileges, install vsftpd via yum: Execute the command yum install vsftpd. Note: It is vsftpd, not install ftp!


After installation, we also need to modify the configuration file vsftpd.conf to disable anonymous login. Execute the command vim/etc/vsftpd/vsftpd.confand add the # number to the "anonymous_enable=yes" in line 11th to disable anonymous login. Why disable anonymous logons? Later, please look down ...

Check Configuration

Once configured, let's check to see if the configuration is in effect, does not contain anonymous_enable=yes, executes the command cat/etc/vsftpd/vsftpd.conf |grep ^[^#]

Start the FTP service

Once configured, we will start the FTP service. Execute command:service vsftpd start .

Note: For convenience, we'd better also let the FTP service boot. Execute command: Chkconfig vsftpd on

Configuring an FTP Account

Just configured vsftpd.conf One step, we will log on anonymously to disabled. What is this for? The reason is to be safe . After disabling anonymous login, we can configure the FTP account and password, configure the account password, connect to the remote server, and then transfer the files. Otherwise, if you use anonymous login, then as long as you know the public network IP, you can transfer files, that much bad!

Start now to configure the user name and password for the FTP account. Its command format is as follows:

① 设置账号的命令:useradd -d /home/username -s /sbin/nologin username ② 设置对应的密码:passwd username

Let's use the following example to illustrate:

# 账号为“xiaoming”,目录为/home/xiaoming,且设置不允许通过ssh登录useradd -d /home/xiaoming -s /sbin/nologin xiaoming # 设置账号对应的密码为 123456passwd xiaomingNew password:123456     # 这是在执行 passwd xiaoming 后会出现的

Modify Pam

Once the account password has been configured, we need to modify the VSFTPD Pam so that the user can connect to the cloud server via the FTP user account and password that they set up. We can look at the contents of the/etc/pam.d/directory first: Execute the command ls/etc/pam.d/

EDIT: Executes the command vim/etc/pam.d/vsftpd, the original content is as follows:

We will modify it to the following content:

#%PAM-1.0 auth required /lib64/security/ item=user sense=deny file=/etc/ftpusers onerr=succeed auth required /lib64/security/ shadow nullok auth required /lib64/security/ account required /lib64/security/ session required /lib64/security/

Once modified, restart the FTP service. Execute command:service vsftpd Restart

Installing FileZilla

After we install the FTP service, how can we submit the local code to the remote server via the FTP protocol? It is very simple, we can use FileZilla to help us finish the work. Of course you can also choose other third-party FTP software. After downloading and installing the FileZilla on the local machine, we tried to use FileZilla for file transfer.

Test FileZilla File Transfer

Now that the preparation is complete, try transferring a local test.html file to the remote server. We found the test.html directly on the local site, then dragged to the remote site or right-click to select the transmission , so that the test.html transferred to the FTP account directory.

Of course it doesn't work just in that directory, because we need to put it in the/usr/share/nginx/html directory so we can access our deployed code through the extranet. Use SECURECRT to telnet to the cloud server, go to the FTP user directory, and then use the CP command to copy the file just uploaded to/usr/share/nginx/html, and the access is OK.

Iv. Summary

So far, we've tried to deploy code on a cloud server. Although it is simply a static HTML file that has been deployed, it has been harvested a lot. In the next section, we begin to learn how to deploy Javaweb projects on cloud servers.
Note: Nginx can be used not only in this, but also interested in self-learning.

Java Notes---Deploying code to Cloud Servers via Nginx and FileZilla

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: 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.