{"id":1662,"date":"2017-09-12T10:03:49","date_gmt":"2017-09-12T08:03:49","guid":{"rendered":"https:\/\/blog.alwaysdata.com\/?p=1662"},"modified":"2020-04-17T15:18:44","modified_gmt":"2020-04-17T13:18:44","slug":"heberger-une-application-lua-chez-alwaysdata","status":"publish","type":"post","link":"https:\/\/blog.alwaysdata.com\/fr\/2017\/09\/12\/heberger-une-application-lua-chez-alwaysdata\/","title":{"rendered":"H\u00e9berger une application Lua chez alwaysdata"},"content":{"rendered":"<p>Deuxi\u00e8me billet de blog de notre s\u00e9rie consacr\u00e9e aux nouveaux langages, cette fois d\u00e9di\u00e9 \u00e0&nbsp;<a href=\"https:\/\/www.lua.org\">Lua<\/a>. Si la popularit\u00e9 de ce langage dans le monde web reste modeste (compar\u00e9 \u00e0&nbsp;des poids lourds comme <a href=\"https:\/\/www.python.org\/\">Python<\/a> ou <a href=\"https:\/\/nodejs.org\">Node.js<\/a>), nous voulons justement vous montrer qu\u2019il est possible d\u2019h\u00e9berger des sites dans des technologies tr\u00e8s vari\u00e9es.<\/p>\n<h3>Lua 5.1 \u00e0&nbsp;5.3<\/h3>\n<p>Nous avions expliqu\u00e9 dans notre <a href=\"https:\/\/blog.alwaysdata.com\/fr\/2017\/09\/05\/heberger-une-application-node-js-chez-alwaysdata\/\">pr\u00e9c\u00e9dent billet<\/a> que Node.js devenait le quatri\u00e8me langage majeur support\u00e9 chez alwaysdata. Lua, de par sa notori\u00e9t\u00e9 moindre (pour le moment), n\u2019a pas encore ce statut. Cela ne change toutefois pas grand&nbsp;chose&nbsp;:<\/p>\n<ul>\n<li>Les versions 5.1, 5.2 et 5.3 sont install\u00e9es, vous pouvez utiliser la version de votre choix en utilisant la commande <em>lua5.X<\/em>, par exemple <em>lua5.1<\/em>. La commande <em>lua<\/em> d\u00e9marre la version 5.2 \u00e0&nbsp;l\u2019heure actuelle, mais cela pourrait changer \u00e0&nbsp;l\u2019avenir, il est donc pr\u00e9f\u00e9rable de sp\u00e9cifier la version d\u00e9sir\u00e9e&nbsp;;<\/li>\n<li><a href=\"https:\/\/luarocks.org\">Luarocks<\/a>&nbsp;(pour installer des paquets) et <a href=\"http:\/\/luajit.org\/\">LuaJIT<\/a> sont \u00e9galement pr\u00e9install\u00e9s.<\/li>\n<\/ul>\n<h3>Exemple&nbsp;: d\u00e9ployer une application Sailor<\/h3>\n<p>Voyons comment&nbsp;d\u00e9ployer une application web avec Lua en utilisant le framework <a href=\"http:\/\/sailorproject.org\/\">Sailor<\/a>. Installons tout d\u2019abord Sailor en SSH&nbsp;puis cr\u00e9ons&nbsp;notre application&nbsp;:<\/p>\n<pre class=\"lang:default decode:true\">$ eval $(luarocks path --bin)\n$ luarocks --local install sailor\n$ sailor create hello\n$ cd hello\n$ nano start-server.lua<\/pre>\n<p>Nous&nbsp;\u00e9ditons le fichier <em>start-server.lua<\/em>&nbsp;de mani\u00e8re \u00e0&nbsp;modifier la&nbsp;ligne&nbsp;:<\/p>\n<pre class=\"lang:default decode:true\">server = {host = \"*\", port = 8080},<\/pre>\n<p>par&nbsp;:<\/p>\n<pre class=\"lang:default decode:true  \">server = {host = os.getenv(\"IP\"), port = os.getenv(\"PORT\")},<\/pre>\n<p>Enfin, dans l\u2019administration alwaysdata, cr\u00e9ons un site de type&nbsp;<em>Programme utilisateur<\/em>, en indiquant&nbsp;:<\/p>\n<ul>\n<li>commande&nbsp;:&nbsp;<em>lua5.1 ~\/hello\/start-server.lua<\/em><\/li>\n<li>r\u00e9pertoire de travail&nbsp;: <em>hello<\/em><\/li>\n<li>environnement&nbsp;: indiquez ce que vous renvoie, en SSH, la commande&nbsp;: <em>echo $(env | grep ^LUA_)<\/em><em><br>\n<\/em><\/li>\n<\/ul>\n<p>Et voil\u00e0,&nbsp;nous acc\u00e9dons d\u00e9sormais \u00e0&nbsp;notre application par le&nbsp;web.<em><br>\n<\/em><\/p>\n<p>Le troisi\u00e8me billet de notre s\u00e9rie s\u2019attardera sur un langage compil\u00e9, pour une fois&nbsp;: <a href=\"https:\/\/golang.org\/\">Go<\/a>&nbsp;!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Deuxi\u00e8me billet de blog de notre s\u00e9rie consacr\u00e9e aux nouveaux langages, cette fois d\u00e9di\u00e9 \u00e0&nbsp;Lua. Si la popularit\u00e9 de ce langage dans le monde web \u2026 <a class=\"read-more\" href=\"https:\/\/blog.alwaysdata.com\/fr\/2017\/09\/12\/heberger-une-application-lua-chez-alwaysdata\/\">Keep reading<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"wp_typography_post_enhancements_disabled":false,"footnotes":""},"categories":[1],"tags":[118,104],"class_list":["post-1662","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-languages","tag-lua"],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/posts\/1662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/comments?post=1662"}],"version-history":[{"count":0,"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/posts\/1662\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/media?parent=1662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/categories?post=1662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alwaysdata.com\/fr\/wp-json\/wp\/v2\/tags?post=1662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}