Home  >  Article  >  Backend Development  >  How to modify the nginx configuration of the default access file on a PHP website - example analysis

How to modify the nginx configuration of the default access file on a PHP website - example analysis

墨辰丷
墨辰丷Original
2018-05-22 10:20:431563browse

This article mainly introduces the nginx configuration of the PHP website to modify the default access file. Friends who need it can refer to it

After setting up lnmp, sometimes there is no need to directly access index.php to configure other Default access files such as index.html. At this time, you need to configure nginx to access the file you want to set.

Directly enter the code. The following is a simple nginx to php-fpm site that I configured. The site accesses the directory /ecmoban/www/index.html by default

server {
listen 80;
location / {
root /ecmoban/www;
index index.html index.php index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /ecmoban/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.html;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Related recommendations:

nginxDetailed explanation of the steps to dynamically crop images in php

##php nginxDetailed explanation of the steps to achieve real-time output

Nginx PHP-FPM optimization tips

The above is the detailed content of How to modify the nginx configuration of the default access file on a PHP website - example analysis. 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