Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

preface

  • Online music poke me ah!
  • Music blog source code online!
  • In the last two months, I did not write an article for a period of time, not because I was lazy, but because I had been working overtime for the project for a week. The project manager came off work early and said that the version could not be postponed.
  • To do a thing, the most sad is that you have worked very hard, without even a little complaint, just want to hear others praise to you, the heart may be enough, the most afraid that people will not appreciate, but come to say you this is not good, that is not good.
  • Of course, I will spend some time studying in the evening. After all, time is like milk.
  • The server I used to work in Shunde was Win, so MY server was always Win. When I changed my job to Guangzhou, the server was Linx, but I found that Linx was good. Now, the space is a hard problem for me, so I decided to migrate to Linx system.
  • The following step by step, take you into the whole process | Nginx.

Unknown island.

demand

At present, music blog is deployed on Win7, and the main applications are:

  • The back-end have
    • Java As a third-party application, a Java image must be installed (👌🏻).
    • Node as the main background, you need to install a Node image
  • The database is
    • If Java connects to Oracle, you need to install an Oracle image
    • Install Mysql image (👌🏻)
  • Front-end projects deployed on Nginx require Nginx image installation (✔️)
  • The lyrics service is also deployed on Node
  • The Node connects to Mysql, and the Mysql image needs to be installed
  • Java connects to Oracle, and an Oracle image needs to be installed
  • Music files are stored on Minio

Need to migrate the above application to Linx, damn!

A lot of companies don’t let you touch the server, so now you can look at it and follow me and record the whole process from nothing to nothing on Linux. This article is mainly written to still use Win server, ready to migrate Linux friends, you can practice migrating server to Linux, Linux has many advantages, the most visible is space, fast speed… This article mainly explains the deployment of Nginx on Linux. Other applications will continue to be updated in the future, so stay tuned!

Linux install Nginx

Here’s a joke: I started by copying nginx from Windows and putting it on Linux, ready to run.

If you want to copy nginx on Linux, you have to install it via yum.

1. Install dependency packages

// One click to install the above four dependencies
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
Copy the code

Download and decompress the installation package

// Create a folder
cd /usr/local
mkdir nginx
cd nginx

// Download the tar
wget http:/ / nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.137..tar.gz
Copy the code

Install nginx

// Access the nginx directory
cd /usr/local/nginx

// Enter the directory
cd nginx-1.137.

// Execute the command
./configure

Run the make command
make

// Run make install
make install
Copy the code

Configure nginx.conf

# open configuration file/usr/local/vi nginx/conf/nginx. ConfCopy the code

Change the port number to 8089, because apeache may occupy port 80, apeache port should not be changed, we choose to change nginx port.

Change localhost to your server IP address.

5. Start nginx

/usr/local/nginx/sbin/nginx -s reload
Copy the code

If there is an error: nginx: [error] open () “/ usr/local/nginx/logs/nginx pid” failed

Is run:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Copy the code

Start again!

Check whether the nginx process is started

ps -ef | grep nginx
Copy the code

7. Disable the firewall on the VM

To use an external host to connect to a VM, disable the FIREWALL on the VM:

CentOS6 and earlier versions run the systemctl stop iptables.service centOS7 command to disable the firewall: systemctl stop firewalldCopy the code

Then access that IP to see the Nginx interface.

Nginx common commands

  • The installation directory is displayed

    • cd /usr/local/nginx/sbin
  • Start the

    • ./nginx
  • stop

    • ./nginx -s stop
  • restart

    • ./nginx -s reload
  • Check for grammar problems

    • ./nginx -t

Before restarting nginx, you are advised to use./nginx -t to check whether the syntax is incorrect

nginx.conf syntax is ok nginx.conf test is successful

The configuration file is correct!

The last

We completed one of the requirements: the front-end project was deployed on Nginx and required an Nginx image to be installed.

We love project-driven learning, don’t we?

I, too, use my personal project – online music to drive me to learn Linux system, Docker, Java, Nginx and other front-end knowledge that may not be accessible. I think this may be the “breadth” of management.

See you in the next section on Node

Related literature

LINUX install nginx detailed steps

In the past to recommend

Typora drag image generated online | Gitee figure bed

Multi-picture detailed explanation, one time to understand the prototype chain (ten thousand words)

Vue-cli3 builds the component library

Vue implements dynamic routing (and the interviewer blows project highlights)

Axios manipulation in a project you didn’t know about (Core principles of handwriting, compatibility)

VuePress builds project component documentation

Vue-typescript-admin-template background management system

The original link

Juejin. Cn/post / 702281…