项目使用 PHP 开发,打包成镜像,部署到服务器后,接口使用都没什么问题,但是访问静态资源文件访问不了,在项目根目录下有个资源文件目录 resource,我的访问地址例如:xxx.com/resource/images/xxxx.png
我在本地开发环境是可以访问成功资源文件,本地也是 Docker 运行的,只是是使用 Docker-compose 编排了 PHP 容器和 Nginx 容器。
服务器上是直接运行了 PHP 容器,暴露 9000 端口。
求大神们看看该怎么配置!!!
Nginx 配置如下:
server { listen 80; server_name xxx.com; root /var/www/app; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/app; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } 