Home>Article>Operation and Maintenance> 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:
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 reload
Restart 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!