Docker& nginx - 内部链接不起作用

时间:2016-11-11 18:54:20

标签: css codeigniter nginx docker

我正在使用docker-compose来加载lemp堆栈并运行在传统堆栈中工作的codeigniter分发,但是在使用docker时我的资产没有加载。

我的电脑上有以下目录结构

logs
  -nginx-access.log
  -nginx-error.log
nginx
  -default
public
  -application
  -assets
    -css
    -js
  -system
  -tests
  -index.php
  -etc etc etc etc

我的nginx配置文件如下

    server {
    listen  80;

    # this path MUST be exactly as docker-compose.fpm.volumes,
    # even if it doesn't exists in this dock.
    root /usr/share/nginx/html;
    index index.php index.html index.html;

    server_name 192.168.0.6;

    location / {
        try_files $uri /index.php$is_args$args;
    }

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

这是我的docker-compose.yml文件

  nginx:
    image: tutum/nginx
    ports:
        - "80:80"
    links:
        - phpfpm
    volumes:
        - ./nginx/default:/etc/nginx/sites-available/default
        - ./nginx/default:/etc/nginx/sites-enabled/default

        - ./logs/nginx-error.log:/var/log/nginx/error.log
        - ./logs/nginx-access.log:/var/log/nginx/access.log
phpfpm:
    image: php:fpm
    ports:
        - "9000:9000"
    volumes:
        - ./public:/usr/share/nginx/html
mysql:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: admin
phpmyadmin:
  image: phpmyadmin/phpmyadmin
  restart: always
  links:
    - mysql
  ports:
    - 8183:80
  environment:
    MYSQL_USERNAME: admin
    MYSQL_ROOT_PASSWORD: admin
    PMA_ARBITRARY: 1

使用

时,知道为什么css文件链接不起作用
<?php echo assets_url('css/bootstrap.min.css'); ?>

上述命令在虚拟服务器上的LAMP堆栈中正常工作。

0 个答案:

没有答案