首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Octopress未加载css

Octopress未加载css
EN

Stack Overflow用户
提问于 2014-09-09 00:16:40
回答 1查看 171关注 0票数 0

我在Nginx上配置Octopress时遇到问题

当我运行rake preview时,一切都运行正常,我可以访问http://xxx:4000,博客看起来也很好

当我运行rake deploy时,我仍然可以在http://xxxx/octopress上访问博客,但看起来没有css/js

当我浏览代码并尝试访问screen.css时,指向css的链接是http://xxxx/stylesheets/screen.css,但它必须是http://xxxx/octopress/stylesheets/screen.css

下面是关于Rakefile和_config.yml的摘录

会议

代码语言:javascript
复制
# ----------------------- #
#      Main Configs       #
# ----------------------- #

url: http://xxxxx/octopress/
title: Lux Baptiste
subtitle: Moui Moui
author: Lux
simple_search: https://www.google.com/search
description:

瑞克

代码语言:javascript
复制
## -- Rsync Deploy config -- ##
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
ssh_user       = "root@XXXX"
ssh_port       = "22"
document_root  = "/var/www/octopress/"
rsync_delete   = false
rsync_args     = ""  # Any extra arguments to pass to rsync
deploy_default = "rsync"

我加入了我的nginx serverblock,不知道它是否能帮上忙

代码语言:javascript
复制
server {
    ### This setting tells Nginx to use this configuration if it gets a request for
    ### yourblog.com
    server_name _;

    ### This is the location on the web server where your Octopress files are
    ### published. Setting this here means you don't have to set it for any of the
    ### individual locations you define below.
    root /var/www/octopress;

    ### This tells Nginx to use "index.html" as the default index page everywhere
    index index.html;

    ### This disables automatic directory index creation, since no one will be
    ### browsing your directories anyway
    autoindex off;

    ### Here we define the root location...
    location / {
    ### ...and then work some magic with "try_files", telling Nginx that for every
    ### request that comes in to /, it should first try to serve the URI exactly
    ### as it is, and if it doesn't find anything by that name to then try and
    ### serve the URI as a directory, and if it doesn't find a directory by that
    ### name to then spit out a 404 error and give up.
        try_files $uri $uri/ =404;
    }

    ### This location definition prevents Nginx from serving any files which begin
    ### with a dot, and further to not log any access attempts or 404s for files
    ### which begin with dots, to keep your access and error logs clean.
    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;
    }

    ### This location definition prevents Nginx from serving any files which begin
    ### with a dollar sign, so Nginx will refuse to serve out a temp file if you
    ### are doing any editing inside a web-available directory
    location ~ ~$ {
        access_log off;
        log_not_found off;
        deny all;
    }
    ### These next two locations simply prevent Nginx from logging every time the
    ### favicon & robots.txt files are accessed, to keep the logs clean
    location = /robots.txt {
        access_log off;
        log_not_found off;
    }

    location = /favicon.ico {
        access_log off;
        log_not_found off;
    }
}
EN

回答 1

Stack Overflow用户

发布于 2014-09-09 00:28:12

修复了它,只需要在_config.yml中更改这些行

代码语言:javascript
复制
# ----------------------- #
#    Jekyll & Plugins     #
# ----------------------- #

# If publishing to a subdirectory as in http://xxx/project set 'root: /project'
root: /octopress/public
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25728635

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档