Laravel EC2 Nginx PHP 7 scripts baixados em vez de executados

2

Os scripts php são baixados no servidor Amazon ec2 com o nginx instalado, em vez de serem executados.

Este é o meu arquivo conf nginx:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    index index.php index.html index.htm;

    server {
        listen       80;
        server_name  appwarded.com www.appwarded.com;
        root         /var/www/appwarded;
        index index.php index.html index.htm;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        location ~* \.(gif|jpg|jpeg|png|js|css)$ {
        }

        location /app {
            alias /var/www/appwarded/app;

            expires -1;
            add_header Pragma "no-cache";
            add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";

            try_files $uri $uri/ /index.html =404;   
       }

        location ^~ /app/api {
            alias /var/www/appwarded/app/api/public;
            try_files $uri $uri/ @api;
        }   

        location ~ \.php {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

        location @api {
            rewrite /app/api/(.*)$ /app/api/index.php?/$1 last;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

}
    
por fflorin 26.04.2016 / 13:25

1 resposta

0

Eu substitui o seguinte bloco:

location ^~ /app/api {
    alias /var/www/appwarded/app/api/public;
    try_files $uri $uri/ @api;
} 

Com:

location ^~ /app/api {
        alias /var/www/appwarded/app/api/public;
        try_files $uri $uri/ @api;

        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass   127.0.0.1:9000;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /path/to/laravel/public/index.php;
        }
}

Esta alteração resolveu o problema.

    
por 26.04.2016 / 15:56