Home > Operation and Maintenance > Nginx > How to deploy web project with nginx

How to deploy web project with nginx

步履不停
Release: 2019-06-20 17:04:24
Original
10186 people have browsed it

How to deploy web project with nginx

The Nginx installation process is relatively simple, so I won’t go into details again. The article starts with deploying your own website after coming out of Nginx's default page.
The latest version of nginx configuration is composed of 4 files. In Ubuntu, the paths of these files are: /etc/nginx Under:

  1. conf.d : User-defined conf configuration file
  2. sites-available: Configuration file of system default settings sites-available: Configuration file of system default settings
  3. sites-enabled: By sites-available Configuration file conversion generates sites-enabled: Configure the configuration file in sites-available to generate
  4. nginx.conf: Summarize the contents of the above three configuration files, and configure the parameters we need at the same time nginx.conf: Summarize the above The contents of the three configuration files, and configure the parameters we need at the same time

When deploying the required web services, we can copy the default file in sites-enabled to conf.d and change the name to * *.conf, and then configure:

server {
    #服务启动时监听的端口
    listen 80 default_server;
    listen [::]:80 default_server;
    #服务启动时文件加载的路径
    root /var/www/html/wordpress;
    #默认加载的第一个文件
    index index.php index.html index.htm index.nginx-debian.html;
    #页面访问域名,如果没有域名也可以填写_
    server_name www.xiexianbo.xin;

    location / {
        #页面加载失败后所跳转的页面
        try_files $uri $uri/ =404;
    }
    
      
    #以下配置只服务于php
    # 将PHP脚本传递给在127.0.0.1:9000上监听的FastCGI服务器
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        # With php7.0-cgi alone:
        #fastcgi_pass 127.0.0.1:9000;
        # With php7.0-fpm:
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    # 如果Apache的文档为root,则拒绝访问.htaccess文件
    location ~ /\.ht {
        deny all;
    }
}
Copy after login

After the configuration is completed, delete the default file in sites-enabled, and then execute the command: sudo nginx -s reload Restart Nginx.

For more Nginx related technical articles, please visit the Nginx Tutorial column to learn!

The above is the detailed content of How to deploy web project with nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template