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

How to deploy web project with nginx

步履不停
步履不停 Original
2019-06-20 17:04:24 10023browse

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/nginxUnder:

  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; } }

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

For more Nginx related technical articles, please visit theNginx Tutorialcolumn 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!

Statement:
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
Previous article:How to view nginx logs Next article:How to view nginx logs