没有得到资产symfony eb本地运行

时间:2017-10-02 19:28:02

标签: symfony amazon-web-services nginx

我正在尝试使用多容器docker配置环境,以便在amazon Web服务中部署symfony应用程序。

我正在使用Dockerrun aws json v2文件和eb本地运行

配置环境

css文件和图像在环境中不起作用。 他们被称为这样的资产。

symfony.conf

server {
server_name holdbusiness.local;
root /var/www/symfony/web;


location / {
try_files $uri @rewriteapp;
}

location @rewriteapp {
rewrite ^(.*)$ /app.php$1 last;
}

location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass php - upstream;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT '/var/www/symfony/web';

fastcgi_param REQUEST_METHOD  $request_method;
fastcgi_param CONTENT_TYPE    $content_type;
fastcgi_param CONTENT_LENGTH  $content_length;
}

error_log /var/log/nginx/symfony_error.log;
access_log /var/log/nginx/symfony_access.log;
}

nginx的Dockerfile

FROM ubuntu:14.04

MAINTAINER Coder

RUN apt - get update && apt - get install - y \
nginx

ADD nginx.conf /etc/nginx/
ADD symfony.conf /etc/nginx/sites - available/

RUN ln - s /etc/nginx/sites - available/symfony.conf /etc/nginx/sites - enabled/symfony
RUN rm /etc/nginx/sites - enabled/default

RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf

RUN usermod - u 1000 www - data

CMD ["nginx"]

EXPOSE 80
EXPOSE 443

记录如下:

  

172.17.0.1 - 172.17.0.1 - - [19 / Sep / 2017:22:20:51 +0000]" GET /bootstrap3/css/bootstrap.min.css HTTP / 1.1" 200 16134" http://holdbusiness.local/index" " Mozilla / 5.0(X11; Ubuntu; Linux x86_64; rv:50.0)Gecko / 20100101 Firefox / 50.0"

已经测试过:

资产:安装

作曲家:安装

How to make assets work with Symfony3 in subdirectory on Nginx

Nginx 403 forbidden for all files

chmod 777

1 个答案:

答案 0 :(得分:0)

我发现了什么是hapenning。这是因为我试图在亚马逊Dockerrun.aws.json中使用docker-compose.yml中的命令。

搬运工-compose.yml volumes_from:              - php

DockerRun.aws.json
"volumesFrom": [
{
    "sourceContainer": "php"
}

],

在aws中它不起作用。解决方案是将安装在php容器中的卷重新安装到nginx容器中

"mountPoints": [
    {
        "sourceVolume": "volumeSymfony",
        "containerPath": "/var/www/appSymfony"
    }
]