Detailed steps to install nginx on Apple M1 chip and deploy vue project

Detailed steps to install nginx on Apple M1 chip and deploy vue project

brew install nginx

Apple Mac uses brew to install. If brew is not installed, please search elsewhere.
Execute Command

The first step is of course to update our brew library, which can be considered a software warehouse, similar to the Android Market and Apple AppStore.

brew update

The second step is to directly find out whether there is nginx in our brew library

brew search nginx

Normally, the following situation will occur

If it appears, it proves that the library is already there, and you can directly run the installation command

brew install nginx

As long as there is no error after the installation, your nginx has been installed successfully. . .

Nginx corresponding path in mac environment

First of all, we must know the common paths of our nginx. I have listed them

illustrate path
nginx configuration path (conf and other files) /usr/local/etc/nginx
The package address of the project deployed on nginx /usr/local/etc/nginx/servers
Logs in nginx /usr/local/var/log/nginx
Access the default homepage address in nginx /usr/local/var/www

Edit the nginx.conf file corresponding to nginx, corresponding to the configuration path we mentioned above

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
    worker_connections 1024;
}


http {
    include mime.types;
    default_type application/octet-stream;



    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;
	client_body_buffer_size 10m;
	client_max_body_size 20m;
    #gzip on;

    server {
        listen 80;
        server_name localhost;
        location / {
            root /usr/local/etc/nginx/servers/html;
            index index.html;
            try_files $uri $uri/ /index.html;
        }
        location /api {
           proxy_pass http://localhost:18080/api;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           set $Real $http_x_forwarded_for;
           if ( $Real ~ (\d+)\.(\d+)\.(\d+)\.(\d+),(.*) ){
                set $Real $1.$2.$3.$4;
          }
          proxy_set_header X-Real-Ip $Real;
        }
}

There is one detail that needs special attention. If your root is not an absolute path, you may not be able to access it.

insert image description here

Most of the paths on the Internet are relative. I don't know what the problem is. It doesn't work locally. I have to use an absolute path. The server/html thing in the path above is the dist package of your vue project after the npm run build command. Just unzip it and put it in this path. The name must correspond to the path of your nginx configuration file.

The final ending

Finally, start nginx and enter the terminal command directly

nginx

If you want to specify the nginx.conf file you started

nginx -c / followed by the path

Stop nginx

nginx -s stop

Restart nginx

nginx -s reload

This is the end of this article about installing nginx on Apple M1 chip and deploying vue project. For more information about installing nginx on Apple M1 chip and deploying vue project, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  Two usages of iFrame tags in HTML

>>:  A brief discussion on whether CSS animation will be blocked by JS

Blog    

Recommend

Summary of MySQL lock knowledge points

The concept of lock ①. Lock, in real life, is a t...

Vue implements fuzzy query-Mysql database data

Table of contents 1. Demand 2. Implementation 3. ...

Let's talk about bitwise operations in React source code in detail

Table of contents Preface Several common bit oper...

Detailed steps to configure MySQL remote connection under Alibaba Cloud

Preface As we all know, by default, the MySQL ins...

How to use CSS counters to beautify ordered lists of numbers

In web design, it is very important to use an org...

MySQL compression usage scenarios and solutions

Introduction Describes the use cases and solution...

CentOS 6 uses Docker to deploy redis master-slave database operation example

This article describes how to use docker to deplo...

WEB standard web page structure

Whether it is the background image or the text siz...

How to invert the implementation of a Bezier curve in CSS

First, let’s take a look at a CSS carousel animat...

In-depth understanding of the use of CSS clear:both

clear:both is used to清除浮動This is the impression I...

Design of pop-up windows and floating layers in web design

In the trend of gradual transition from tradition...

How to set Nginx to forward the domain name to the specified port

Enter /usr/local/nginx/conf sudo cd /usr/local/ng...