美文网首页Phoenix
Phoenix 使用七牛作为静态资源存储

Phoenix 使用七牛作为静态资源存储

作者: linjunpop | 来源:发表于2016-05-06 14:45 被阅读204次

在七牛新建一个空间,然后配置「镜像存储」,其中「镜像源」填入网站的地址

记得配置 robots.txt,防止搜索引擎误索引

七牛镜像存储配置图解

修改 /config/prod.exs 文件,在 Endpoint 配置里增加 static_url

 config :daka, Daka.Endpoint,
    http: [ip: {127, 0, 0, 1}, port: 4800],
    url: [scheme: "https", host: "example.com", port: 443],
+   static_url: [scheme: "https", host: "xxx.qnssl.com", port: 443],
    cache_static_manifest: "priv/static/manifest.json"
  
  # Do not print debug messages in production

修改所有的 static_pathstatic_url

     <meta name="onMenuShareTimeline" content="<%= wechat_meta(@conn, :on_menu_share_timeline) %>">
  
      <title>Hello Daka!</title>
 -    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
 +    <link rel="stylesheet" href="<%= static_url(@conn, "/css/app.css") %>">
    </head>
  
    <body>
 @@ -30,6 +30,6 @@
  
      </div> <!-- /container -->
      <script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
 -    <script src="<%= static_path(@conn, "/js/app.js") %>"></script>
 +    <script src="<%= static_url(@conn, "/js/app.js") %>"></script>
    </body>
  </html>

搞定!

相关文章

网友评论

    本文标题:Phoenix 使用七牛作为静态资源存储

    本文链接:https://www.haomeiwen.com/subject/avrjrttx.html