Implementation of multi-site configuration of Nginx on Mac M1

Implementation of multi-site configuration of Nginx on Mac M1

Note: nginx installed via brew

Website root directory: /opt/homebrew/var/www

nginx configuration directory: /opt/homebrew/etc/nginx/

Assumption: There is a project named TestProject and the domain name is bd.testproject.com

Step 1: Set up IP and domain name mapping (that is, add hosts)

# Terminal vim /etc/hosts 
 
# Add and save 127.0.0.1 bd.testproject.com

Step 2: Create a new site configuration file directory

# Terminal mkdir /opt/homebrew/etc/nginx/vhosts

Step 3: Create a new site configuration file

Create a new configuration file named bd.testproject.com_80.conf in the /opt/homebrew/etc/nginx/vhosts directory. The content of the configuration file is (you can change the configuration content as needed):

server {
    listen 80;
    server_name bd.testproject.com;
    root "/opt/homebrew/var/www/bd.testproject.com";
    location / {
      index index.php index.html error/index.html;
 
      autoindex off;
    }
    location ~ \.php(.*)$ {
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
      include fastcgi_params;
    }
}

Step 4: Introduce site configuration in nginx default configuration file

# Terminal vim /opt/homebrew/etc/nginx/nginx.conf
 
# Add server_names_hash_bucket_size 64 in the file http{}; # Modify the server name length, which can only be a multiple of 32 include /opt/homebrew/etc/nginx/vhosts/*; # Introduce site configuration

Step 5: Restart nginx

# Terminal nginx -s reload

Please ignore me and start fastcgi

/usr/local/php/bin/php-cgi -b 9000

This is the end of this article about the implementation of Mac M1 Nginx multi-site configuration. For more relevant Mac M1 Nginx multi-site content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to install Homebrew on Mac M1
  • Mac M1 installs mnmp (Mac+Nginx+MySQL+PHP) development environment
  • Detailed explanation of Mac M1 Java development environment configuration
  • The whole process of installing python/anaconda on Macbook air m1 (picture and text)
  • Temporary replacement for Anaconda on M1 chip Mac (miniforge)
  • MacbookM1 python environment configuration essay
  • Detailed method of installing JDK and IDEA on Mac M1 in 2020
  • How to install MySQL 8.0 database on M1 chip (picture and text)
  • Implementation of installing python3.9.1 on M1 chip

<<:  The difference between ID and Name attributes of HTML elements

>>:  Example code for implementing hexagonal borders with CSS3

Recommend

Implementation of CSS equal division of parent container (perfect thirds)

The width of the parent container is fixed. In or...

Summary of some HTML code writing style suggestions

Omit the protocol of the resource file It is reco...

JavaScript canvas to achieve raindrop effect

This article example shares the specific code for...

Using HTML web page examples to explain the meaning of the head area code

Use examples to familiarize yourself with the mean...

A brief description of the relationship between k8s and Docker

Recently, the project uses kubernetes (hereinafte...

How to draw special graphics in CSS

1. Triangle Border settings Code: width: 300px; h...

Detailed explanation of CentOS configuration of Nginx official Yum source

I have been using the CentOS purchased by Alibaba...

Flex layout realizes left text overflow and omits right text adaptation

I want to achieve a situation where the width of ...

How to quickly modify the table structure of MySQL table

Quickly modify the table structure of a MySQL tab...

How to view MySQL links and kill abnormal links

Preface: During database operation and maintenanc...

Mysql string interception and obtaining data in the specified string

Preface: I encountered a requirement to extract s...