DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

tangdoudou
tangdoudou

Posted on

Host your website with Nginx for Front-end Developers on CentOS

@Host your website with Nginx for Front-end Developers on CentOS

English | ็ฎ€ไฝ“ไธญๆ–‡

Introduction

  • The purpose of this paper is to solve the static resource deployment requirements of the front end by using the simplest and fastest method.
  • The company usually uses tomcat to deploy a lot of static resources. I bought a server in March this year. I've been busy working overtime and haven't started using it yet. I just used it today.

Precondition

ou have a server~~ just like this

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

Step 1: link the server

1. Find public IP

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

2. Change Password

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

3. Download FinalShell, install and open

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

4. Open FinalShell

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

You can fill in the name at will, you can create a server name which is convenient for later link use.

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

5. Linked server

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

Step 2: Install Nginx

### 1. Download Nginx package
Click here to download Nginx compression package
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
### 2. Find the path and drag in the compressed package you just downloaded.
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
### 3. Decompression files, Refresh directories

 tar -zxvf nginx-1.18.0.tar.gz

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
### 4. Installation dependency

yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
### 5. Enter directory, execute command

cd nginx-1.18.0

./configure

make install

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

6.Configure

To configure this item, you can operate according to the demand or not, and use the default port number

# Open configuration file
vi /usr/local/nginx/conf/nginx.conf

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
Open the configuration file, use the down arrow of the keyboard to search for the port number and modify it.

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

Edit and save files nuder Linux

  1. Using the CD command to enter the file directory ; such as : cd xxx/xxx
  2. Use vi command to enter the file to be edited and enter normal mode to view the file content; such as : vi xxx
  3. Enter lowercase 'i' to enter editing mode and start editing text.
  4. After editing, press 'ESC' to exit to normal mode.
  5. In normal mode, you can enter ':' to enter command mode.
  6. Enter ':wq' or 'wq' in command mode to save and exit.

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

7.Start Nginx

/usr/local/nginx/sbin/nginx -s reload

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

8.Check whether Nginx process is started

ps -ef | grep nginx

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

Step 3: Test

1. Enter the server management interface and configure the security group.

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
### 2. Visit the website
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

Step 4: Deploy other projects

### 1. Enter the static resource directory of the server, drag the packed project to put.

Directory address๏ผš/usr/local/nginx/html

ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ
### 2. Visit
ๅœจ่ฟ™้‡Œๆ’ๅ…ฅๅ›พ็‰‡ๆ่ฟฐ

Colclusion

The purpose of this tutorial is to quickly complete the project deployment. Other configuration problems are not listed..Configuration articles will be added later if I have time...
Welcome to point out the article needs to be corrected~

If there is a better way, please come up with it and make progress together~~

Top comments (0)

๐ŸŒš Life is too short to browse without dark mode