{"id":914,"date":"2011-07-25T11:35:20","date_gmt":"2011-07-25T09:35:20","guid":{"rendered":"http:\/\/www.sbskl.com\/?p=914"},"modified":"2011-07-25T11:35:20","modified_gmt":"2011-07-25T09:35:20","slug":"php-ne-sexecute-pas-mais-se-telecharge","status":"publish","type":"post","link":"http:\/\/www.sbskl.com\/?p=914","title":{"rendered":"PHP ne s&rsquo;execute pas mais se t\u00e9l\u00e9charge&#8230;"},"content":{"rendered":"<p>Apr&egrave;s une installation rapide de <strong>Apache<\/strong>, <strong>Mysql<\/strong> et de <strong>PHP<\/strong>, vos doigts vous d&eacute;mangent &agrave; l&#39;id&eacute;e d&#39;&eacute;crire votre premier bout de code. Par pr&eacute;caution, vous avez activ&eacute; le module <strong>userdir<\/strong> pour &quot;bricoler&quot; dans&nbsp; votre r&eacute;pertoire <strong>public_html<\/strong>. Histoire de ne pas polluer le r&eacute;pertoire<strong> \/var\/www<\/strong>.<\/p>\n<p>Seulement voil&agrave;, apr&egrave;s l&#39;&eacute;criture de votre premier <strong>index.php<\/strong>, vous ouvrez votre navigateur pr&eacute;f&eacute;r&eacute; sur <strong>http:\/\/localhost\/~mon_nom\/index.php<\/strong> et surprise : une belle boite de dialogue appara&icirc;t pour vous proposer d&#39;enregistrer le fichier <strong>index.php<\/strong>&#8230;<\/p>\n<p>En clair, Apache a transf&eacute;r&eacute; directement votre fichier au navigateur sans la moindre interpr&eacute;tation de PHP&#8230; Pas bien !<\/p>\n<p><!--more--><\/p>\n<p>Tout vient de la configuration par d&eacute;faut de <strong>Apache<\/strong> et plus pr&eacute;cis&eacute;ment du module <strong>php5<\/strong>. Si vous ouvrez le fichier <strong>\/etc\/apache2\/mods-enabled\/php5.conf<\/strong>, vous y trouverez ceci :<\/p>\n<pre class=\"brush: xml\"><ifmodule mod_php5.c=\"\">\r\n    <filesmatch>\r\n    SetHandler application\/x-httpd-php\r\n    <\/filesmatch>\r\n    <filesmatch>\r\n    SetHandler application\/x-httpd-php-source\r\n    <\/filesmatch>\r\n    # To re-enable php in user directories comment the following lines\r\n    # (from <ifmodule ...=\"\"> to <\/ifmodule>.) Do NOT set it to On as it\r\n    # prevents .htaccess files from disabling it.\r\n    <ifmodule mod_userdir.c=\"\">\r\n        <directory home=\"\" public_html=\"\">\r\n            php_admin_value engine Off\r\n        <\/directory>\r\n    <\/ifmodule>\r\n<\/ifmodule>\r\n<\/pre>\n<p>Tout est dit dans le commentaire : &quot;<em>To re-enable php in user directories&#8230;<\/em>&quot;. En bon fran&ccedil;ais, il suffit de commenter avec un # les lignes 11 &agrave; 15 comme ceci :<\/p>\n<pre class=\"brush: xml; highlight: [11, 12, 13, 14, 15]\"><ifmodule mod_php5.c=\"\">\r\n    <filesmatch>\r\n    SetHandler application\/x-httpd-php\r\n    <\/filesmatch>\r\n    <filesmatch>\r\n    SetHandler application\/x-httpd-php-source\r\n    <\/filesmatch>\r\n    # To re-enable php in user directories comment the following lines\r\n    # (from <ifmodule ...=\"\"> to <\/ifmodule>.) Do NOT set it to On as it\r\n    # prevents .htaccess files from disabling it.\r\n#    <ifmodule mod_userdir.c=\"\">\r\n#        <directory home=\"\" public_html=\"\">\r\n#            php_admin_value engine Off\r\n#        <\/directory>\r\n#    <\/ifmodule>\r\n<\/ifmodule>\r\n<\/pre>\n<p>Une fois la modification effectu&eacute;e, pensez &agrave; red&eacute;marrer Apache avec un :<\/p>\n<pre class=\"brush:bash\">sudo \/etc\/init.d\/apache2 restart<\/pre>\n<p>Recharger votre page dans votre navigateur et l&#39;interpr&eacute;tation de votre premier bout de code <strong>PHP<\/strong> apparait devant vos yeux ebaillis <img loading=\"lazy\" decoding=\"async\" alt=\"cool\" height=\"20\" src=\"http:\/\/www.sbskl.com\/wp-content\/plugins\/ckeditor-for-wordpress\/ckeditor\/plugins\/smiley\/images\/shades_smile.gif\" title=\"cool\" width=\"20\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apr&egrave;s une installation rapide de Apache, Mysql et de PHP, vos doigts vous d&eacute;mangent &agrave; l&#39;id&eacute;e d&#39;&eacute;crire votre premier bout de code. Par pr&eacute;caution, vous avez activ&eacute; le module userdir pour &quot;bricoler&quot; dans&nbsp; votre r&eacute;pertoire public_html. Histoire de ne pas polluer le r&eacute;pertoire \/var\/www. Seulement voil&agrave;, apr&egrave;s l&#39;&eacute;criture de votre premier index.php, vous ouvrez votre [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[6,25,28,16],"class_list":["post-914","post","type-post","status-publish","format-standard","hentry","category-linux","tag-administration","tag-apache","tag-php","tag-ubuntu"],"_links":{"self":[{"href":"http:\/\/www.sbskl.com\/index.php?rest_route=\/wp\/v2\/posts\/914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.sbskl.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sbskl.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sbskl.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sbskl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=914"}],"version-history":[{"count":21,"href":"http:\/\/www.sbskl.com\/index.php?rest_route=\/wp\/v2\/posts\/914\/revisions"}],"predecessor-version":[{"id":960,"href":"http:\/\/www.sbskl.com\/index.php?rest_route=\/wp\/v2\/posts\/914\/revisions\/960"}],"wp:attachment":[{"href":"http:\/\/www.sbskl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sbskl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=914"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sbskl.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}