Answer the question
In order to leave comments, you need to log in
Why does Nginx give the original php code to index.php but execute the rest of the php files?
I configured the server using Vagrant and PUPHPET.
I copied the vhost settings from the combat server (deleting locations that are not important for this problem).
When you go to:
site.dev
site.dev/index.php
nginx gives you the source code of the index.php file.
In this case, if you go, for example, to site.dev/page_doesnt_exist, then index.php is executed.
nginx config
user www-data;
worker_processes 1;
worker_rlimit_nofile 1024;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
server_tokens on;
types_hash_max_size 1024;
types_hash_bucket_size 512;
server_names_hash_bucket_size 64;
server_names_hash_max_size 512;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
server {
listen 192.168.56.101:80;
server_name site.dev;
set $yii_bootstrap "index.php";
root /var/www/site.ru;
access_log /var/log/nginx/site.dev.access.log;
error_log /var/log/nginx/site.dev.error.log;
charset utf-8;
index index.php index.html;
location / {
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
include fastcgi_params;
}
sendfile off;
}
}
phpinfo();location / {
index index.php;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
Answer the question
In order to leave comments, you need to log in
1. Perhaps there is a line in .htaccess that is responsible for this behavior of index.php?
2. Perhaps you have a typo and the file format does not match .php?
3. Perhaps, point 1 is only in configs at the server level?
And "fastcgi_index" nginx.org/ru/docs/http/ngx_http_fastcgi_module.htm...
location ~ \.php$ {
.....
fastcgi_index index.php;
.....
}
>> 2. Perhaps you have a typo and the file format does not match .php?
this can be explained.
I once had the same thing. It turned out that the php file
started with <?
instead of the prescribed ones
. It can also be treated in the php config with the short_open_tag directive <?php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question