I have the following files structure:
var ####################################
└── www ##############################
#####└── html ##########################
########## ├── include ##################
########## │######└── DB_tools.php ######
########## └── index.php ################
I want to put require_once('/include/DB_tools.php'); in index.php file so that it includes the DB_tools.php. Currently it gives me the following error:
Fatal error: Uncaught Error: Failed opening required '/include/DB_tools.php' (include_path='/var/www/html/') in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3
default.conf:
server {
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
My question in Stackoverflow - https://stackoverflow.com/questions/76638623/how-to-configure-root-include-path-for-dockerized-php-with-nginx