search

Home  >  Q&A  >  body text

php - When laravel is deployed to a linux server, the image cannot be displayed. If the default path does not set the public directory, it will be OK, but the css style will be messed up.

The server environment is the LNMP environment,
the computer is the LAMP environment,

The picture directory is a sibling directory of public;

The image path can be displayed on the local machine, but when placed on the server, external access cannot display the image, unless I set the default access path of nginx to the public superior directory, but in this case, the css style path is Something went wrong;

The path of the picture is www.xxx.com/../uploads/asdads.jpg or something like this.
There is no problem in the LAMP environment, but it will not work in the server. What is the problem?

I suspect that nginx settings are missing. So I wanted to ask.


The path is fine on this machine. I found that when the browser accesses the server, it seems to ignore ../. I have placed the save folder in the public directory.

怪我咯怪我咯2755 days ago540

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-05-16 13:05:33

    Based on your description, I guess there is something wrong with the path settings. You can use the development mode in the browser to see where the paths of the images and Js point to respectively, and whether they are the same as you expected.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:05:33

    First check whether the uploads directory has read and write permissions. Secondly, if it is ignored, try the absolute path?

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 13:05:33

    • Confirm whether the file name is correct

    • Public files can directly specify the absolute path in nginx

    server {
        #忽略部分代码
        location /public/ {
            alias  "D:/www/code/public/";
        }
        
        location / { ... }
        #忽略部分代码
        
    }

    reply
    0
  • Cancelreply