Home > headlines > body text

How to modify the nginx configuration of the default access file for a PHP website

无忌哥哥
Release: 2018-06-27 15:24:29
Original
3638 people have browsed it

After setting up lnmp, sometimes you don’t need to access index.php directly. You need 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.

Go directly to the code. The following is a simple nginx to php-fpm site configured by me. The site defaults to accessing the directory /ecmoban/www/index.html

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;
}
}
Copy after login

The above is what the editor gives you The introduced PHP website modifies the nginx configuration of the default access file. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time.

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