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)