2010-08-23 13:34:35 +00:00
<?xml version="1.0" encoding="utf-8"?>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "fr" xml:lang = "fr" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=UTF-8" / >
< meta name = "keywords" content = "blog" >
< link rel = "shortcut icon" type = "image/x-icon" href = "/Scratch/img/favicon.ico" / >
< link rel = "stylesheet" type = "text/css" href = "/Scratch/assets/css/main.css" / >
< link rel = "stylesheet" type = "text/css" href = "/Scratch/css/twilight.css" / >
< link rel = "stylesheet" type = "text/css" href = "/Scratch/css/idc.css" / >
< link rel = "alternate" type = "application/rss+xml" title = "RSS" href = "http://feeds.feedburner.com/yannespositocomfr" / >
2010-09-16 11:56:03 +00:00
< link rel = "alternate" lang = "fr" xml:lang = "fr" title = "Maintenant sur Heroku" type = "text/html" hreflang = "fr" href = "/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/" / >
< link rel = "alternate" lang = "en" xml:lang = "en" title = "Now hosted by heroku" type = "text/html" hreflang = "en" href = "/Scratch/en/blog/2010-08-23-Now-heberged-on-heroku/" / >
2010-08-23 13:34:35 +00:00
< script type = "text/javascript" src = "/Scratch/js/jquery-1.3.1.min.js" > < / script >
< script type = "text/javascript" src = "/Scratch/js/jquery.cookie.js" > < / script >
< script type = "text/javascript" src = "/Scratch/js/index.js" > < / script >
2010-09-16 11:56:03 +00:00
< title > Maintenant sur Heroku< / title >
2010-08-23 13:34:35 +00:00
< / head >
< body lang = "fr" >
< script type = "text/javascript" > / / < ! [ C D A T A [
document.write('< div id = "blackpage" > < img src = "/Scratch/img/loading.gif" alt = "Chargement en cours..." / > < / div > ');
// ]]>
< / script >
< div id = "content" >
2010-09-27 18:49:15 +00:00
< div id = "choix" >
< div class = "return" > < a href = "#entete" > ↓ Menu ↓ < / a > < / div >
< div id = "choixlang" >
< a href = "/Scratch/en/blog/2010-08-23-Now-heberged-on-heroku/" onclick = "setLanguage('en')" > in English< / a >
< / div >
< / div >
< img src = "/Scratch/img/presentation.png" alt = "Presentation drawing" / >
2010-08-23 13:34:35 +00:00
< div id = "titre" >
< h1 >
2010-09-16 11:56:03 +00:00
Maintenant sur Heroku
2010-08-23 13:34:35 +00:00
< / h1 >
< h2 >
Héberger un site web statique sur heroku
< / h2 >
< / div >
< div class = "flush" > < / div >
< div class = "flush" > < / div >
< div id = "afterheader" >
< div class = "corps" >
< h1 class = "first" id = "maintenant-sur-herokuhttpherokucom" > Maintenant sur < a href = "http://heroku.com" > Heroku< / a > < / h1 >
< p > J’ ai changé mon hébergeur. Mobileme n’ est absolument pas adapté à la diffusion de mon blog. C’ est pourquoi je suis passé à < a href = "http://heroku.com" > Heroku< / a > .< / p >
< p > Mais comme vous devez le savoir mon blog est un site complètement statique.
J’ utilise < a href = "http://nanoc.stoneship.org/" > nanoc< / a > pour l’ engendrer.
Avoir un site statique amène beaucoup d’ avantages par rapport à un site dynamique. Surtout en terme de sécurité.
Voici comment configurer un site statique sur heroku.< / p >
2010-08-25 10:05:23 +00:00
< p > La racine de mes fichiers est ‘ /output’ . Vous devez simplement créer deux fichiers. Un fichier < code > config.ru< / code > < sup id = "fnref:1" > < a href = "#fn:1" rel = "footnote" > 1< / a > < / sup > :< / p >
2010-08-23 13:34:35 +00:00
< div class = "code" > < div class = "file" > < a href = "/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/code/config.ru" > ➥ config.ru < / a > < / div > < div class = "withfile" >
< pre class = "twilight" >
< span class = "Keyword" > require< / span > < span class = "String" > < span class = "String" > '< / span > rubygems< span class = "String" > '< / span > < / span >
< span class = "Keyword" > require< / span > < span class = "String" > < span class = "String" > '< / span > rack< span class = "String" > '< / span > < / span >
2010-08-25 10:05:23 +00:00
< span class = "Keyword" > require< / span > < span class = "String" > < span class = "String" > '< / span > rack/contrib< span class = "String" > '< / span > < / span >
2010-08-23 13:34:35 +00:00
< span class = "Keyword" > require< / span > < span class = "String" > < span class = "String" > '< / span > rack-rewrite< span class = "String" > '< / span > < / span >
2010-08-25 10:05:23 +00:00
< span class = "Keyword" > require< / span > < span class = "String" > < span class = "String" > '< / span > mime/types< span class = "String" > '< / span > < / span >
use < span class = "Support" > Rack< / span > ::< span class = "Entity" > ETag< / span >
< span class = "Keyword" > module< / span > ::< span class = "Entity" > Rack< / span >
< span class = "Keyword" > class< / span > < span class = "Entity" > TryStatic< span class = "EntityInheritedClass" > < span class = "EntityInheritedClass" > < < / span > Static< / span > < / span >
< span class = "Keyword" > def< / span > < span class = "Entity" > initialize< / span > (< span class = "Variable" > app< span class = "Variable" > ,< / span > options< / span > )
< span class = "Keyword" > super< / span >
< span class = "Variable" > < span class = "Variable" > @< / span > try< / span > < span class = "Keyword" > =< / span > ([< span class = "String" > < span class = "String" > '< / span > < span class = "String" > '< / span > < / span > ] < span class = "Keyword" > +< / span > < span class = "Variable" > Array< / span > (options.< span class = "Entity" > delete< / span > (< span class = "Constant" > < span class = "Constant" > :< / span > try< / span > )) < span class = "Keyword" > +< / span > [< span class = "String" > < span class = "String" > '< / span > < span class = "String" > '< / span > < / span > ])
< span class = "Keyword" > end< / span >
< span class = "Keyword" > def< / span > < span class = "Entity" > call< / span > (< span class = "Variable" > env< / span > )
< span class = "Variable" > < span class = "Variable" > @< / span > next< / span > < span class = "Keyword" > =< / span > < span class = "Constant" > 0< / span >
< span class = "Keyword" > while< / span > < span class = "Variable" > < span class = "Variable" > @< / span > next< / span > < span class = "Keyword" > < < / span > < span class = "Variable" > < span class = "Variable" > @< / span > try< / span > .< span class = "Entity" > size< / span > < span class = "Keyword" > & & < / span > < span class = "Constant" > 404< / span > < span class = "Keyword" > ==< / span > (resp < span class = "Keyword" > =< / span > < span class = "Keyword" > super< / span > (< span class = "Entity" > try_next< / span > (env)))[< span class = "Constant" > 0< / span > ]
< span class = "Variable" > < span class = "Variable" > @< / span > next< / span > < span class = "Keyword" > +=< / span > < span class = "Constant" > 1< / span >
< span class = "Keyword" > end< / span >
< span class = "Constant" > 404< / span > < span class = "Keyword" > ==< / span > resp[< span class = "Constant" > 0< / span > ] < span class = "Keyword" > ?< / span > < span class = "Variable" > < span class = "Variable" > @< / span > app< / span > .< span class = "Entity" > call< / span > : resp
< span class = "Keyword" > end< / span >
< span class = "Keyword" > private< / span >
< span class = "Keyword" > def< / span > < span class = "Entity" > try_next< / span > (< span class = "Variable" > env< / span > )
env.< span class = "Entity" > merge< / span > (< span class = "String" > < span class = "String" > '< / span > PATH_INFO< span class = "String" > '< / span > < / span > => env[< span class = "String" > < span class = "String" > '< / span > PATH_INFO< span class = "String" > '< / span > < / span > ] < span class = "Keyword" > +< / span > < span class = "Variable" > < span class = "Variable" > @< / span > try< / span > [< span class = "Variable" > < span class = "Variable" > @< / span > next< / span > ])
< span class = "Keyword" > end< / span >
< span class = "Keyword" > end< / span >
2010-08-23 13:34:35 +00:00
< span class = "Keyword" > end< / span >
2010-08-25 10:05:23 +00:00
use < span class = "Support" > Rack< / span > ::< span class = "Entity" > TryStatic< / span > ,
< span class = "Constant" > < span class = "Constant" > :< / span > root< / span > => < span class = "String" > < span class = "String" > " < / span > output< span class = "String" > " < / span > < / span > , < span class = "Comment" > < span class = "Comment" > #< / span > static files root dir< / span >
< span class = "Constant" > < span class = "Constant" > :< / span > urls< / span > => < span class = "String" > < span class = "String" > %w[< / span > /< span class = "String" > ]< / span > < / span > , < span class = "Comment" > < span class = "Comment" > #< / span > match all requests < / span >
< span class = "Constant" > < span class = "Constant" > :< / span > try< / span > => [< span class = "String" > < span class = "String" > '< / span > .html< span class = "String" > '< / span > < / span > , < span class = "String" > < span class = "String" > '< / span > index.html< span class = "String" > '< / span > < / span > , < span class = "String" > < span class = "String" > '< / span > /index.html< span class = "String" > '< / span > < / span > ] < span class = "Comment" > < span class = "Comment" > #< / span > try these postfixes sequentially< / span >
errorFile< span class = "Keyword" > =< / span > < span class = "String" > < span class = "String" > '< / span > output/Scratch/en/error/404-not_found/index.html< span class = "String" > '< / span > < / span >
run lambda { [< span class = "Constant" > 404< / span > , {
< span class = "String" > < span class = "String" > " < / span > Last-Modified< span class = "String" > " < / span > < / span > => < span class = "Support" > File< / span > .< span class = "Entity" > mtime< / span > (errorFile).< span class = "Entity" > httpdate< / span > ,
< span class = "String" > < span class = "String" > " < / span > Content-Type< span class = "String" > " < / span > < / span > => < span class = "String" > < span class = "String" > " < / span > text/html< span class = "String" > " < / span > < / span > ,
< span class = "String" > < span class = "String" > " < / span > Content-Length< span class = "String" > " < / span > < / span > => < span class = "Support" > File< / span > .< span class = "Entity" > size< / span > (errorFile).< span class = "Entity" > to_s< / span >
}, < span class = "Support" > File< / span > .< span class = "Entity" > read< / span > (errorFile)] }
2010-08-23 13:34:35 +00:00
< / pre >
< / div > < / div >
< p > et un fichier < code > .gems< / code > qui liste les gems nécessaires.< / p >
< div class = "code" > < div class = "file" > < a href = "/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/code/.gems" > ➥ .gems < / a > < / div > < div class = "withfile" >
< pre class = "twilight" >
rack
rack< span class = "Keyword" > -< / span > rewrite
2010-08-25 10:05:23 +00:00
rack< span class = "Keyword" > -< / span > contrib
2010-08-23 13:34:35 +00:00
< / pre >
< / div > < / div >
< p > Maintenant il suffit de suivre l’ introduction rapide d’ heroku pour créer une nouvelle application :< / p >
< pre class = "twilight" >
git init
git add .
heroku create
git push heroku master
< / pre >
2010-09-16 11:56:03 +00:00
< p > Maintenant je peux rediriger correctement mes erreurs 404.
2010-08-23 13:34:35 +00:00
J’ espère que ça a pu vous être utile.< / p >
2010-08-25 10:05:23 +00:00
< hr / > < div class = "footnotes" >
< ol >
< li id = "fn:1" >
< p > Je me suis complètement inspiré de cet < a href = "http://gmarik.info/blog/2010/05/10/blogging-with-jekyll-and-heroku-for-free" > article< / a > .< a href = "#fnref:1" rev = "footnote" > ↩ < / a > < / p >
< / li >
< / ol >
< / div >
2010-08-23 13:34:35 +00:00
< / div >
< div id = "choixrss" >
< a id = "rss" href = "http://feeds.feedburner.com/yannespositocomfr" >
s'abonner
< / a >
< / div >
< script type = "text/javascript" >
$(document).ready(function(){
$('#comment').hide();
$('#clickcomment').click(showComments);
});
function showComments() {
$('#comment').show();
$('#clickcomment').fadeOut();
}
document.write('< div id = "clickcomment" > Commentaires< / div > ');
< / script >
< div class = "flush" > < / div >
< div class = "corps" id = "comment" >
< h2 class = "first" > commentaires< / h2 >
< noscript >
< / noscript >
< script type = "text/javascript" >
var idcomments_acct = 'a307f0044511ff1b5cfca573fc0a52e7';
var idcomments_post_id = '/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/';
var idcomments_post_url = 'http://yannesposito.com/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/';
< / script >
< span id = "IDCommentsPostTitle" style = "display:none" > < / span >
< script type = 'text/javascript' src = '/Scratch/js/genericCommentWrapperV2.js' > < / script >
< / div >
< div id = "entete" class = "corps_spaced" >
< div id = "liens" >
2010-09-17 15:15:29 +00:00
< ul > < li > < a href = "/Scratch/fr/" > Accueil< / a > < / li >
2010-08-23 13:34:35 +00:00
< li > < a href = "/Scratch/fr/blog/" > Blog< / a > < / li >
2010-09-30 13:01:14 +00:00
< li > < a href = "/Scratch/fr/softwares/" > Softwares< / a > < / li >
2010-09-28 01:00:51 +00:00
< li > < a href = "/Scratch/fr/about/" > À propos< / a > < / li > < / ul >
2010-08-23 13:34:35 +00:00
< / div >
< div class = "flush" > < / div >
< hr / >
< div id = "next_before_articles" >
< div id = "previous_articles" >
articles précédents
< div class = "previous_article" >
2010-09-28 15:10:12 +00:00
< a href = "/Scratch/fr/blog/2010-07-09-Indecidabilities/" > < span class = "nicer" > «< / span > Indécidabilités (partie 1)< / a >
2010-08-23 13:34:35 +00:00
< / div >
< div class = "previous_article" >
2010-09-28 15:10:12 +00:00
< a href = "/Scratch/fr/blog/2010-07-31-New-style-after-holidays/" > < span class = "nicer" > «< / span > Nouveau style après les vacances< / a >
2010-08-23 13:34:35 +00:00
< / div >
< div class = "previous_article" >
2010-09-28 15:10:12 +00:00
< a href = "/Scratch/fr/blog/2010-07-07-CSS-rendering-problems-by-navigator/" > < span class = "nicer" > «< / span > N'utilisez pas de gradients avec Chrome< / a >
2010-08-23 13:34:35 +00:00
< / div >
< / div >
< div id = "next_articles" >
articles suivants
2010-08-31 13:06:43 +00:00
< div class = "next_article" >
2010-09-28 15:10:12 +00:00
< a href = "/Scratch/fr/blog/2010-08-31-send-mail-from-command-line-with-attached-file/" > Envoyer un mail en ligne de commande avec un fichier attaché < span class = "nicer" > »< / span > < / a >
2010-08-31 13:06:43 +00:00
< / div >
2010-08-23 13:34:35 +00:00
2010-09-01 22:29:34 +00:00
< div class = "next_article" >
2010-09-28 15:10:12 +00:00
< a href = "/Scratch/fr/blog/2010-09-02-base64-and-sha1-on-iPhone/" > base64 et sha1 sur iPhone < span class = "nicer" > »< / span > < / a >
2010-09-01 22:29:34 +00:00
< / div >
2010-08-23 13:34:35 +00:00
2010-09-02 14:42:39 +00:00
< div class = "next_article" >
2010-09-28 15:10:12 +00:00
< a href = "/Scratch/fr/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/" > Utilisation de git pour calculer les mtimes < span class = "nicer" > »< / span > < / a >
2010-09-02 14:42:39 +00:00
< / div >
2010-08-23 13:34:35 +00:00
< / div >
< div class = "flush" > < / div >
< / div >
< / div >
< div id = "bottom" >
< div >
< a rel = "license" href = "http://creativecommons.org/licenses/by-sa/3.0/deed.fr" > Droits de reproduction ©, Yann Esposito< / a >
< / div >
< div id = "lastmod" >
2010-08-31 13:06:43 +00:00
Écrit le : 23/08/2010
2010-09-16 11:56:03 +00:00
modifié le : 16/09/2010
2010-08-23 13:34:35 +00:00
< / div >
< div >
Site entièrement réalisé avec
< a href = "http://www.vim.org" > Vim< / a >
et
< a href = "http://nanoc.stoneship.org" > nanoc< / a >
< / div >
< div >
< a href = "/Scratch/fr/validation/" > Validation< / a >
< a href = "http://validator.w3.org/check?uri=referer" > [xhtml] < / a >
.
< a href = "http://jigsaw.w3.org/css-validator/check/referer?profile=css3" > [css] < / a >
.
< a href = "http://validator.w3.org/feed/check.cgi?url=http%3A//yannesposito.com/Scratch/fr/blog/feed/feed.xml" > [rss]< / a >
< / div >
< / div >
< div class = "clear" > < / div >
< / div >
< / body >
< / html >