Suite à de nombreux messages sur le forum concernant l’installation de Drupal sur Free.fr et la spécificité de cet hébergeur, voici une documentation relatant pas à pas la mise en place d’un site Drupal chez Free.
Ce document est un wiki, vous pouvez donc y apporter des modifications.
ToDo: - la procédure qui suit oblige de “mettre les mains dans le cambouis”, je pense qu’il serait peut être utile de stocker quelque part tous les fichiers modifiés. Cependant, il s’agit de voir si c’est réellement une bonne solution sachant que cela impliquerait une certaine maintenance (mise à jour lors des nouvelles versions) et une certaine confiance vu qu’il s’agirait de télécharger des sources depuis un site autre que Drupal.org. - analyser plus en détails les fichiers .htaccees pour permettre leur usage.
Remerciements: Ce document est principalement le fruit du fil Drupal 5.0 sur free.fr ? auquel ont apporté leur aide mccricri, koda, francisXV, qwerkus, gemac et votre humble serviteur.
deny from all. Notons également que les options suivantes du fichier .htaccess de drupal fonctionnent très bien chez free:
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Customized error messages.
ErrorDocument 404 /index.php# Set the default handler.
DirectoryIndex index.phpincludes/file.inc pour éviter l’exécution du code qui se trouve entre les lignes 115 et 126 <?php
/* if ((file_directory_path() == $directory || file_directory_temp() == $directory) && !is_file("$directory/.htaccess")) {
$htaccess_lines = "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006\nOptions None\nOptions +FollowSymLinks";
if (($fp = fopen("$directory/.htaccess", 'w')) && fputs($fp, $htaccess_lines)) {
fclose($fp);
chmod($directory .'/.htaccess', 0664);
}
else {
$message = t("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", array('%directory' => $directory, '!htaccess' => '<br />'. nl2br(check_plain($htaccess_lines))));
form_set_error($form_item, $message);
watchdog('security', $message, WATCHDOG_ERROR);
}
} */
?>modules/system/system.install ligne 40, remplacer REQUIREMENT_ERROR par REQUIREMENT_WARNING:
<?php
case 'Apache':
if (version_compare($version, DRUPAL_MINIMUM_APACHE) < 0) {
$requirements['webserver']['description'] = $t('Your Apache server is too old. Drupal requires at least Apache %version.', array('%version' => DRUPAL_MINIMUM_APACHE));
$requirements['webserver']['severity'] = REQUIREMENT_WARNING;
}
?>LOCK TABLES lors de l’installationincludes/install.mysql.inc lignes 90 à 109 en remplaçant ce bloc par:
<?php
// Test LOCK.
/*$query = 'LOCK TABLES drupal_install_test WRITE';
$result = mysql_query($query);
if ($error = mysql_error()) {
drupal_set_message(st('We were unable to lock a test table on your MySQL database server. We tried locking a table with the command %query and MySQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
$err = TRUE;
}
else {*/
$success[] = 'LOCK';
//}
// Test UNLOCK.
/*$query = 'UNLOCK TABLES';
$result = mysql_query($query);
if ($error = mysql_error()) {
drupal_set_message(st('We were unable to unlock a test table on your MySQL database server. We tried unlocking a table with the command %query and MySQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
$err = TRUE;
}
else {*/
$success[] = 'UNLOCK';
//}
?>LOCK TABLES lors de l’utilisationincludes/database.mysql.inc de la manière suivante:
Ligne 261 à 269: il faut commenter les 2 appels aux fonctions LOCK:
<?php
function db_next_id($name) {
$name = db_prefix_tables($name);
//db_query('LOCK TABLES {sequences} WRITE');
$id = db_result(db_query("SELECT id FROM {sequences} WHERE name = '%s'", $name)) + 1;
db_query("REPLACE INTO {sequences} VALUES ('%s', %d)", $name, $id);
//db_query('UNLOCK TABLES');
return $id;
}
?><?php
/**
* Lock a table.
*/
function db_lock_table($table) {
//db_query('LOCK TABLES {'. db_escape_table($table) .'} WRITE');
db_query('SELECT 1');
}
/**
* Unlock all locked tables.
*/
function db_unlock_tables() {
//db_query('UNLOCK TABLES');
db_query('SELECT 1');
}
?>index.php en index.php5.
[mise à jour 18/02] : cela ne suffit pas, il faut modifier le .htaccess comme indiqué en bas de cette page (paragraphe “passer free en php5”). Du coup, le renommage en php5 est inutile.[/maj]
Warning: mysql_real_escape_string(): 10749672 is not a valid MySQL-Link resource in /mnt/.../includes/database.mysql.inc on line 400.
Suite à de nombreuses réactions sur le forum (et une expérience personnelle), il semblerait que l’installation ne se déroule pas très très bien. Cela est peut être du à un temps d’execution maximum des scripts PHP qui serait trop faible.
En allant sur la page d’accueil, l’utilisateur se voit présenter un horrible message: Fatal error: Call to undefined function: filter_xss_bad_protocol() in /mnt/.../includes/common.inc on line 837.
Ceci est dû à une insertion incomplète des données de la table system (entre autres).
Pour palier à ce problème, il faut réinsérer (cliquer sur le nom de votre BDD, puis onglet SQL) les données par défaut. Le script suivant réalise cela:
- effacement des tables
- insertion des données par défaut permettant le bon fonctionnement de Drupal
NB: Il faut penser à rajouter à la main le préfixe des tables si la BDD a été installée avec un préfixe.
-- Delete all datas
TRUNCATE `blocks`;
TRUNCATE `cache`;
TRUNCATE `cache_menu`;
TRUNCATE `filter_formats`;
TRUNCATE `filters`;
TRUNCATE `menu`;
TRUNCATE `node_access`;
TRUNCATE `node_type`;
TRUNCATE `permission`;
TRUNCATE `role`;
TRUNCATE `system`;
TRUNCATE `users`;
TRUNCATE `variable`;
-- Dumping data for table `blocks`
INSERT INTO `blocks` VALUES ('user', '0', 'garland', 1, 0, 'left', 0, 0, 0, '', '');
INSERT INTO `blocks` VALUES ('user', '1', 'garland', 1, 0, 'left', 0, 0, 0, '', '');
-- Dumping data for table `filter_formats`
INSERT INTO `filter_formats` VALUES (1, 'Filtered HTML', ',1,2,', 1);
INSERT INTO `filter_formats` VALUES (2, 'PHP code', '', 0);
INSERT INTO `filter_formats` VALUES (3, 'Full HTML', '', 1);
-- Dumping data for table `filters`
INSERT INTO `filters` VALUES (1, 'filter', 3, 0);
INSERT INTO `filters` VALUES (1, 'filter', 0, 1);
INSERT INTO `filters` VALUES (1, 'filter', 2, 2);
INSERT INTO `filters` VALUES (2, 'filter', 1, 0);
INSERT INTO `filters` VALUES (3, 'filter', 3, 0);
INSERT INTO `filters` VALUES (3, 'filter', 2, 1);
-- Dumping data for table `menu`
INSERT INTO `menu` VALUES (2, 0, '', 'Primary links', '', 0, 115);
-- Dumping data for table `node_access`
INSERT INTO `node_access` VALUES (0, 0, 'all', 1, 0, 0);
-- Dumping data for table `node_type`
INSERT INTO `node_type` VALUES ('page', 'Page', 'node', 'If you want to add a static page, like a contact page or an about page, use a page.', '', 1, 'Title', 1, 'Body', 0, 1, 1, 0, 'page');
INSERT INTO `node_type` VALUES ('story', 'Story', 'node', 'Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extended by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.', '', 1, 'Title', 1, 'Body', 0, 1, 1, 0, 'story');
-- Dumping data for table `permission`
INSERT INTO `permission` VALUES (1, 'access content', 0);
INSERT INTO `permission` VALUES (2, 'access comments, access content, post comments, post comments without approval', 0);
-- Dumping data for table `role`
INSERT INTO `role` VALUES (1, 'anonymous user');
INSERT INTO `role` VALUES (2, 'authenticated user');
-- Dumping data for table `system`
INSERT INTO `system` VALUES ('themes/engines/phptemplate/phptemplate.engine', 'phptemplate', 'theme_engine', '', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('themes/garland/page.tpl.php', 'garland', 'theme', 'themes/engines/phptemplate/phptemplate.engine', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/system/system.module', 'system', 'module', 'Handles general site configuration for administrators.', 1, 0, 0, 1021, 0);
INSERT INTO `system` VALUES ('modules/aggregator/aggregator.module', 'aggregator', 'module', 'Aggregates syndicated content (RSS, RDF, and Atom feeds).', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/block/block.module', 'block', 'module', 'Controls the boxes that are displayed around the main content.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/blog/blog.module', 'blog', 'module', 'Enables keeping easily and regularly updated user web pages or blogs.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/blogapi/blogapi.module', 'blogapi', 'module', 'Allows users to post content using applications that support XML-RPC blog APIs.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/book/book.module', 'book', 'module', 'Allows users to collaboratively author a book.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/color/color.module', 'color', 'module', 'Allows the user to change the color scheme of certain themes.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/comment/comment.module', 'comment', 'module', 'Allows users to comment on and discuss published content.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/contact/contact.module', 'contact', 'module', 'Enables the use of both personal and site-wide contact forms.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/drupal/drupal.module', 'drupal', 'module', 'Lets you register your site with a central server and improve ranking of Drupal projects by posting information on your installed modules and themes', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/filter/filter.module', 'filter', 'module', 'Handles the filtering of content in preparation for display.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/forum/forum.module', 'forum', 'module', 'Enables threaded discussions about general topics.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/help/help.module', 'help', 'module', 'Manages the display of online help.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/legacy/legacy.module', 'legacy', 'module', 'Provides legacy handlers for upgrades from older Drupal installations.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/locale/locale.module', 'locale', 'module', 'Enables the translation of the user interface to languages other than English.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/menu/menu.module', 'menu', 'module', 'Allows administrators to customize the site navigation menu.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/node/node.module', 'node', 'module', 'Allows content to be submitted to the site and displayed on pages.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/path/path.module', 'path', 'module', 'Allows users to rename URLs.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/ping/ping.module', 'ping', 'module', 'Alerts other sites when your site has been updated.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/poll/poll.module', 'poll', 'module', 'Allows your site to capture votes on different topics in the form of multiple choice questions.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/profile/profile.module', 'profile', 'module', 'Supports configurable user profiles.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/search/search.module', 'search', 'module', 'Enables site-wide keyword searching.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/statistics/statistics.module', 'statistics', 'module', 'Logs access statistics for your site.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/taxonomy/taxonomy.module', 'taxonomy', 'module', 'Enables the categorization of content.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/throttle/throttle.module', 'throttle', 'module', 'Handles the auto-throttling mechanism, to control site congestion.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/tracker/tracker.module', 'tracker', 'module', 'Enables tracking of recent posts for users.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/upload/upload.module', 'upload', 'module', 'Allows users to upload and attach files to content.', 0, 0, 0, -1, 0);
INSERT INTO `system` VALUES ('modules/user/user.module', 'user', 'module', 'Manages the user registration and login system.', 1, 0, 0, 0, 0);
INSERT INTO `system` VALUES ('modules/watchdog/watchdog.module', 'watchdog', 'module', 'Logs and records system events.', 1, 0, 0, 0, 0);
-- Dumping data for table `users`
INSERT INTO `users` VALUES (0, '', '', '', 0, 0, 0, '', '', 0, 0, 0, 0, NULL, '', '', '', NULL);
-- Dumping data for table `variable`
INSERT INTO `variable` VALUES ('theme_default', 's:7:"garland";');
INSERT INTO `variable` VALUES ('filter_html_1', 'i:1;');
INSERT INTO `variable` VALUES ('node_options_forum', 'a:1:{i:0;s:6:"status";}');
INSERT INTO `variable` VALUES ('menu_primary_menu', 'i:2;');
INSERT INTO `variable` VALUES ('menu_secondary_menu', 'i:2;');
INSERT INTO `variable` VALUES ('install_profile', 's:7:"default";');
INSERT INTO `variable` VALUES ('node_options_page', 'a:1:{i:0;s:6:"status";}');
INSERT INTO `variable` VALUES ('comment_page', 'i:0;');
INSERT INTO `variable` VALUES ('theme_settings', 'a:1:{s:21:"toggle_node_info_page";b:0;}');chmod ne fonctionne pas chez Free. Voir plus haut pour le protéger autrement avec un .htaccess ou bien en le déplacant dans un autre dossier.
$confdir = 'sites';
par
$confdir = 'MonRepUltraSecreT';
Il faut bien sûr renommer le répertoire “sites” par “MonRepUltraSecreT” ou même le créer (NB: si vous le créez, il faut alors créer également un sous-répertoire MonRepUltraSecreT/default, dans lequel on placera le php.settings).
L’information sera toujours en rouge dans l’administration de drupal mais inaccessible en réalité.
Ajouter la ligne suivante dans le .htaccess
PHP 1
Voila, à l’issue de ce tutoriel vous devriez avoir une installation fonctionnelle de Drupal 5.6, espérons qu’a l’avenir, Drupal 6 simplifiera la tâche.
Bon courage.