I
I
Ilya Beloborodov2016-07-20 10:14:09
PHP
Ilya Beloborodov, 2016-07-20 10:14:09

Why does nginx output php as text?

On the server there is such a path to the script /var/www/example/sites/example.com/parser
There is this in nginx.conf

location ~*/parser/ {
    root /var/www/example/sites/example.com;
    error_log /var/www/example/sites/logs/nginx_error_parser.log;
    index index.php;
}

when you go to example.com/parser/ - displays the source code of the index.php file. What needs to be added to make the interpreter work?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya Beloborodov, 2016-07-20
@kowap

location /parser/ { 
     rewrite ^(.*)$  /parser/index.php permanent; 
}

 location ~ /parser/.+\.php$ {
     error_log /var/www/theinsider/sites/logs/nginx_error_parser.log;
     root /var/www/theinsider/sites/theinsider.ua;
     fastcgi_split_path_info ^(.+\.php)(/.+)$;
     include fastcgi_params;
     fastcgi_index index.php;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_intercept_errors on;
     fastcgi_buffers 64 64k;
     fastcgi_buffer_size 256k;
     fastcgi_pass unix:/var/run/php5-fpm.sock;
}

E
Eugene, 2016-07-20
@Nc_Soft

Where is the handler? fastcgi_pass

A
Ainur Shakirov, 2016-07-20
@Fqyeh29

How do you write opening php tags? If a

<? 
/*Code*/
?>

then by default php does not know such tags, and does not consider them as code => is not executed. It is necessary to specify in the config (I don’t remember exactly, but it seems to be there, you just need to uncomment it)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question