0

Now, laravel 5.6 on my server so its open to the public "deployment". Thing is when I configure nginx to use the public directory of laravel and I restart everything all I can see is the test of index.php with option download and save.

Access log for nginx:

162.158.22.173 - - [21/Jun/2018:23:18:39 +0000] "GET / HTTP/1.1" 500 175902 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"

/etc/nginx/sites-available/laravel:

server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/lib/jenkins/workspace/ytl/public;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name 157.32.4.241;

#location / {
        try_files $uri $uri/ /index.php;

location ~ \.php$ {
    #try_files $uri /index.php =404;
try_files $uri $uri/ /index.php?$args;

    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

    location ~ /\.ht {
        deny all;
    }

location ~ /git(/.*) {
    client_max_body_size 0; # Git pushes can be massive, just to make sure nginx doesn't suddenly cut the connection add this.
    auth_basic "Git Login"; # Whatever text will do.
    auth_basic_user_file "/var/www/html/git/htpasswd";
    include /etc/nginx/fastcgi_params; # Include the default fastcgi configs
    fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; # Tells fastcgi to pass the request to the git http backend executable
    fastcgi_param GIT_HTTP_EXPORT_ALL "";
    fastcgi_param GIT_PROJECT_ROOT /var/www/html/git; # /var/www/git is the location of all of your git repositories.
    fastcgi_param REMOTE_USER $remote_user;
    fastcgi_param PATH_INFO $1; # Takes the capture group from our location directive and gives git that.
    fastcgi_pass  unix:/var/run/fcgiwrap.socket; # Pass the request to fastcgi
}

NOW : When I open url : its give me index.php file.

  • first, check your PHP version.`laravel 5.6` needs `PHP >= 7.1.3` . – Alihossein shahabi Jun 21 '18 at 22:31
  • check `directory Permissions` .. . Directories within the `storage` and the `bootstrap/cache` directories should be writable by your web server – Alihossein shahabi Jun 21 '18 at 22:34
  • Yes @Alihosseinshahabi i have 7.2 php installed now... its giving me another` error` on web brower... I am going post in question –  Jun 21 '18 at 22:50
  • @Alihosseinshahabi When I open url : its give me index.php file. –  Jun 21 '18 at 22:52
  • have you seen this topic? : https://stackoverflow.com/questions/25591040/nginx-serves-php-files-as-downloads-instead-of-executing-them – Alihossein shahabi Jun 21 '18 at 22:58
  • yes i followed it @Alihosseinshahabi –  Jun 21 '18 at 23:06
  • @KinnariPrajapati follow this tutorial: https://devmarketer.io/learn/deploy-laravel-5-app-lemp-stack-ubuntu-nginx/ – Rutvij Kothari Jun 21 '18 at 23:11
  • i have digital Ocean `Ubuntu` server. i had 5.3 and i have removed it and installed fresh laravel 5.6. i have checked your link @RutvijKothari –  Jun 21 '18 at 23:13
  • Just follow the tutorial it is detailed one. In the blog there is a configuration file. Try to figure out what's wrong with your configuration file. – Rutvij Kothari Jun 21 '18 at 23:19
  • 1
    Storage folder is not writable by nginx, try `chmod 777 path/to/storage` – Walid Ammar Jun 21 '18 at 23:32
  • I have done 777 now its give me another error: `"file_put_contents(/var/lib/jenkins/workspace/ytl/storage/framework/views/c7dab4be95fb56152e018ed53253393e65bb28c0.php): failed to open stream: Permission denied"` –  Jun 21 '18 at 23:34
  • 1
    its worked @MohammadWalid .. if you answered, then i can thump up ... –  Jun 21 '18 at 23:38

1 Answers1

1

Storage folder is not writable by nginx, try chmod 777 path/to/storage

Walid Ammar
  • 4,038
  • 3
  • 25
  • 48