Competences techniques apache et drupal » Historique » Version 5
Julien Enselme, 11/05/2013 21:30
C’est partout pareil à ma connaissance.
| 1 | 1 | Florent Torregrosa | {{toc}} |
|---|---|---|---|
| 2 | |||
| 3 | h1. Competences techniques apache et drupal |
||
| 4 | |||
| 5 | h2. Savoir installer un serveur apache, phpmyadmin |
||
| 6 | |||
| 7 | * augmenter sa mémoire dédiée |
||
| 8 | * augmenter la taille maximale des fichiers pouvant être importés dans phpmyadmin |
||
| 9 | * post_max_size et upload_max_filesize dans /etc/php5/apache2/php.ini et /etc/php5/cli/php.ini puis restart apache |
||
| 10 | |||
| 11 | h2. Savoir ajouter/activer des modules pour le serveur apache (notamment le module pour les url-simplifiées) |
||
| 12 | |||
| 13 | * sudo a2enmod mod_rewrite |
||
| 14 | * sudo apt-get install curl libcurl3 libcurl3-dev php5-curl |
||
| 15 | |||
| 16 | h2. Savoir installer drush |
||
| 17 | |||
| 18 | * savoir où est installé drush : drush config |
||
| 19 | |||
| 20 | 3 | Florent Torregrosa | h2. Pouvoir utiliser un nom de domaine en local |
| 21 | 1 | Florent Torregrosa | |
| 22 | 3 | Florent Torregrosa | Quand je vais sur assos.centrale-marseille.fr, c’est mon site local que je vois et non pas celui de centrale. |
| 23 | |||
| 24 | Constater qu’en allant sur assos.centrale-marseille.fr on tombe sur la page par defaut de notre apache (la page sur laquelle on tombe dépend de si oui ou non elle a un vhost qui la concerne). |
||
| 25 | |||
| 26 | 2 | Florent Torregrosa | * Pour les distributions basées sur Debian |
| 27 | 1 | Florent Torregrosa | * Pour Mageia 3 |
| 28 | * Pour Fedora |
||
| 29 | |||
| 30 | 3 | Florent Torregrosa | h2. Pouvoir créer des vhost à la pelle |
| 31 | 1 | Florent Torregrosa | |
| 32 | 3 | Florent Torregrosa | Exemple : créer le domaine titi.local |
| 33 | 1 | Florent Torregrosa | |
| 34 | 2 | Florent Torregrosa | * Pour les distributions basées sur Debian |
| 35 | * Pour Mageia 3 |
||
| 36 | * Pour Fedora |
||
| 37 | 1 | Florent Torregrosa | |
| 38 | h2. Pouvoir reproduire en local un site en particulier |
||
| 39 | |||
| 40 | * pouvoir télécharger en local juste le minimum de fichiers |
||
| 41 | * le minimum c’est tout le htmltest sauf le dossier sites |
||
| 42 | * dans sites/ il faut ne prendre que le dossier default et le dossier du site qui nous concerne. |
||
| 43 | * pouvoir se démerder (script ou suite de ligne de commande ou …) pour pouvoir faire ça efficacement (une suite de commande scp n’est pas une mauvaise idée) |
||
| 44 | * rsync -lr --exclude nom_fichier_ou_dossier_a_exclure assos@sas1.centrale-marseille.fr:chemin_vers_dossier/* . |
||
| 45 | * sur sa machine se faire un dossier d6 et un dossier d7 |
||
| 46 | |||
| 47 | * exemple dans d6 : |
||
| 48 | <pre> |
||
| 49 | cd d6 |
||
| 50 | rsync -lr --exclude sites assos@sas1.centrale-marseille.fr:html/* . |
||
| 51 | 2 | Florent Torregrosa | mkdir sites |
| 52 | 1 | Florent Torregrosa | cd sites |
| 53 | rsync -lr assos@sas1.centrale-marseille.fr:html/sites/default . |
||
| 54 | 2 | Florent Torregrosa | rsync -lr assos@sas1.centrale-marseille.fr:html/sites/assos.centrale-marseille.fr.annales . (étape longue) |
| 55 | 1 | Florent Torregrosa | </pre> |
| 56 | |||
| 57 | h2. Pouvoir télécharger la base de donnée d’un seul site en particulier |
||
| 58 | |||
| 59 | * savoir faire ça avec phpmyadmin, dans phpmyadmin : |
||
| 60 | 2 | Florent Torregrosa | > * exporter |
| 61 | 1 | Florent Torregrosa | > * options personnalisées |
| 62 | > * choisir que les tables qui vous intéressent |
||
| 63 | > * laisser les autres options |
||
| 64 | > * enregistrer |
||
| 65 | > * ça enregistre dans votre dossier de téléchargements sur votre machine |
||
| 66 | |||
| 67 | 2 | Florent Torregrosa | * savoir le faire avec drush car parfois le fichier téléchargé par phpmyadmin est trop gros |
| 68 | 1 | Florent Torregrosa | |
| 69 | > * sur le sas : |
||
| 70 | > > <pre>dump_site annales (pour une base de données isolées, se placer dans le dossier du site puis drush sql-dump > nom_du_fichier.sql) |
||
| 71 | 4 | Florent Torregrosa | cd Desktop/dump_individuels</pre> |
| 72 | 1 | Florent Torregrosa | |
| 73 | > * sur sa machine : |
||
| 74 | > > </pre>@scp assos@sas1.centrale-marseille.fr:Desktop/dump_individuels/annales....</pre> |
||
| 75 | |||
| 76 | h2. Monter un site en local |
||
| 77 | |||
| 78 | * monter un seul vhost pour assos.centrale-marseille.fr (il sera valable pour tous les sous sites, il ne sera jamais édité) |
||
| 79 | * télécharger les fichiers et la base de donnée du site en question |
||
| 80 | * injecter la dbb en local (utiliser le phpmyadmin en local ou sudo mysql -u root -pmotdepasse nomdelabase < fichier.sql) |
||
| 81 | * modifier le settings.php du site en question pour donner les informations de connection mysql) |
||
| 82 | |||
| 83 | h2. Installer le script drush de mise à jour http://drupal.org/project/drush_sup |
||
| 84 | |||
| 85 | * suivre la procédure d’installation |
||
| 86 | * critère de validation : la commande suivante marche : drush sup |
||
| 87 | |||
| 88 | h2. Exécuter correctement le script de mise à jour |
||
| 89 | |||
| 90 | * lire la doc de drush sup |
||
| 91 | * exécuter drush sup avec les bons arguments |
||
| 92 | |||
| 93 | 3 | Florent Torregrosa | h1. Annexe : Nom de domaine |
| 94 | 1 | Florent Torregrosa | |
| 95 | 5 | Julien Enselme | Normalement, toutes les unix reposent sur le même principe. Ajouter l’entrée suivante dans /etc/hosts : @127.0.0.1 assos.centrale-marseille.fr@ |
| 96 | 1 | Florent Torregrosa | |
| 97 | 3 | Florent Torregrosa | h1. Annexe : Vhosts |
| 98 | 1 | Florent Torregrosa | |
| 99 | h2. Pour les distributions basées sous Debian |
||
| 100 | |||
| 101 | 3 | Florent Torregrosa | * Dans /etc/apache2/sites-available/ créer un fichier titi dont le contenu est : |
| 102 | <pre> |
||
| 103 | <VirtualHost *:80> |
||
| 104 | ServerAdmin webmaster@localhost |
||
| 105 | ServerName titi.local |
||
| 106 | ServerAlias titi.local |
||
| 107 | 2 | Florent Torregrosa | |
| 108 | 3 | Florent Torregrosa | DocumentRoot /chemin/dossier_site |
| 109 | 1 | Florent Torregrosa | |
| 110 | 3 | Florent Torregrosa | <Directory /chemin/dossier_site/> |
| 111 | Options Indexes FollowSymLinks MultiViews |
||
| 112 | AllowOverride All |
||
| 113 | Order allow,deny |
||
| 114 | allow from all |
||
| 115 | </Directory> |
||
| 116 | |||
| 117 | ErrorLog ${APACHE_LOG_DIR}/titi.error.log |
||
| 118 | |||
| 119 | # Possible values include: debug, info, notice, warn, error, crit, |
||
| 120 | # alert, emerg. |
||
| 121 | LogLevel warn |
||
| 122 | |||
| 123 | CustomLog ${APACHE_LOG_DIR}/titi.access.log combined |
||
| 124 | |||
| 125 | </VirtualHost> |
||
| 126 | </pre> |
||
| 127 | * créer le fichier test.html dans /chemin/dossier_site et mettre dedans @<h1>TITI</h1>@ |
||
| 128 | * ajouter un lien symbolique dans /etc/apache2/sites-enabled qui pointe sur le fichier titi qui est dans /etc/apache2/sites-available/ : |
||
| 129 | > * Manuellement : |
||
| 130 | 4 | Florent Torregrosa | > <pre> |
| 131 | 3 | Florent Torregrosa | cd /etc/apache2/sites-enabled/ |
| 132 | ln -s ../sites-available/titi . |
||
| 133 | </pre> |
||
| 134 | > * Avec la commande apache : |
||
| 135 | 4 | Florent Torregrosa | > <pre> |
| 136 | 3 | Florent Torregrosa | sudo service a2ensite titi |
| 137 | </pre> |
||
| 138 | * ajouter l’entrée titi.local dans le fichier /etc/hosts : |
||
| 139 | 1 | Florent Torregrosa | <pre> |
| 140 | @127.0.0.1 titi.local@ |
||
| 141 | 3 | Florent Torregrosa | </pre> |
| 142 | 4 | Florent Torregrosa | * restart apache |
| 143 | 3 | Florent Torregrosa | <pre> |
| 144 | 4 | Florent Torregrosa | sudo service apache2 restart |
| 145 | 1 | Florent Torregrosa | </pre> |
| 146 | * consulter titi.local/test.html |
||
| 147 | |||
| 148 | h2. Pour Mageia 3 |
||
| 149 | 4 | Florent Torregrosa | |
| 150 | {{warning(la partie pour mageia permet pour l'instant d'atteindre le site via localhost/nom_du_site, pas encore bien connecté avec le fichier Hosts)}} |
||
| 151 | |||
| 152 | * Dans /etc/httpd/conf/sites.d/ créer un fichier nom_du_fichier.conf dont le contenu est : |
||
| 153 | <pre> |
||
| 154 | # Drupal configuration |
||
| 155 | Alias /nom_du_site /chemin/dossier_site |
||
| 156 | |||
| 157 | <Directory /chemin/dossier_site/> |
||
| 158 | Require local granted |
||
| 159 | Options -Indexes +FollowSymlinks +Multiviews |
||
| 160 | AllowOverride None |
||
| 161 | |||
| 162 | # Protect files and directories from prying eyes. |
||
| 163 | <FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$"> |
||
| 164 | Order allow,deny |
||
| 165 | </FilesMatch> |
||
| 166 | |||
| 167 | # Don't show directory listings for URLs which map to a directory. |
||
| 168 | Options -Indexes |
||
| 169 | |||
| 170 | # Follow symbolic links in this directory. |
||
| 171 | Options +FollowSymLinks |
||
| 172 | |||
| 173 | # Make Drupal handle any 404 errors. |
||
| 174 | ErrorDocument 404 /index.php |
||
| 175 | |||
| 176 | # Set the default handler. |
||
| 177 | DirectoryIndex index.php index.html index.htm |
||
| 178 | |||
| 179 | # Override PHP settings that cannot be changed at runtime. See |
||
| 180 | # sites/default/default.settings.php and drupal_environment_initialize() in |
||
| 181 | # includes/bootstrap.inc for settings that can be changed at runtime. |
||
| 182 | |||
| 183 | # PHP 5, Apache 1 and 2. |
||
| 184 | <IfModule mod_php5.c> |
||
| 185 | php_flag magic_quotes_gpc off |
||
| 186 | php_flag magic_quotes_sybase off |
||
| 187 | php_flag register_globals off |
||
| 188 | php_flag session.auto_start off |
||
| 189 | php_value mbstring.http_input pass |
||
| 190 | php_value mbstring.http_output pass |
||
| 191 | php_flag mbstring.encoding_translation off |
||
| 192 | </IfModule> |
||
| 193 | |||
| 194 | # Requires mod_expires to be enabled. |
||
| 195 | <IfModule mod_expires.c> |
||
| 196 | # Enable expirations. |
||
| 197 | ExpiresActive On |
||
| 198 | |||
| 199 | # Cache all files for 2 weeks after access (A). |
||
| 200 | ExpiresDefault A1209600 |
||
| 201 | |||
| 202 | <FilesMatch \.php$> |
||
| 203 | # Do not allow PHP scripts to be cached unless they explicitly send |
||
| 204 | # cache headers themselves. Otherwise all scripts would have to |
||
| 205 | # overwrite the headers set by mod_expires if they want another |
||
| 206 | # caching behavior. This may fail if an error occurs early in the |
||
| 207 | # bootstrap process, and it may cause problems if a non-Drupal PHP |
||
| 208 | # file is installed in a subdirectory. |
||
| 209 | ExpiresActive Off |
||
| 210 | </FilesMatch> |
||
| 211 | </IfModule> |
||
| 212 | |||
| 213 | # Various rewrite rules. |
||
| 214 | <IfModule mod_rewrite.c> |
||
| 215 | RewriteEngine on |
||
| 216 | |||
| 217 | # Block access to "hidden" directories whose names begin with a period. |
||
| 218 | # This includes directories used by version control systems such as |
||
| 219 | # Subversion or Git to store control files. Files whose names begin with |
||
| 220 | # a period, as well as the control files used by CVS, are protected by |
||
| 221 | # the FilesMatch directive above. |
||
| 222 | # |
||
| 223 | # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, |
||
| 224 | # it is not possible to block access to entire directories from |
||
| 225 | # .htaccess, because <DirectoryMatch> is not allowed here. |
||
| 226 | # |
||
| 227 | # If you do not have mod_rewrite installed, you should remove these |
||
| 228 | # directories from your webroot or otherwise protect them from being |
||
| 229 | # downloaded. |
||
| 230 | RewriteRule "(^|/)\." - [F] |
||
| 231 | |||
| 232 | # If your site can be accessed both with and without the 'www.' prefix, |
||
| 233 | # you can use one of the following settings to redirect users to your |
||
| 234 | # preferred URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY |
||
| 235 | # one option: |
||
| 236 | # To redirect all users to access the site WITH the 'www.' prefix, |
||
| 237 | # (http://example.com/... will be redirected to http://www.example.com/...) |
||
| 238 | # uncomment the following: |
||
| 239 | # RewriteCond %{HTTP_HOST} !^www\. [NC] |
||
| 240 | # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
||
| 241 | # |
||
| 242 | # To redirect all users to access the site WITHOUT the 'www.' prefix, |
||
| 243 | # (http://www.example.com/... will be redirected to http://example.com/...) |
||
| 244 | # uncomment the following: |
||
| 245 | # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] |
||
| 246 | # RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301] |
||
| 247 | |||
| 248 | # Modify the RewriteBase if you are using Drupal in a subdirectory or in a |
||
| 249 | # VirtualDocumentRoot and the rewrite rules are not working properly. |
||
| 250 | # For example if your site is at http://example.com/drupal uncomment and |
||
| 251 | # modify the following line: |
||
| 252 | RewriteBase /nom_du_site |
||
| 253 | # |
||
| 254 | # If your site is running in a VirtualDocumentRoot at http://example.com/, |
||
| 255 | # uncomment the following line: |
||
| 256 | # RewriteBase / |
||
| 257 | |||
| 258 | # Pass all requests not referring directly to files in the filesystem to |
||
| 259 | # index.php. Clean URLs are handled in drupal_environment_initialize(). |
||
| 260 | RewriteCond %{REQUEST_FILENAME} !-f |
||
| 261 | RewriteCond %{REQUEST_FILENAME} !-d |
||
| 262 | RewriteCond %{REQUEST_URI} !=/favicon.ico |
||
| 263 | RewriteRule ^ index.php [L] |
||
| 264 | |||
| 265 | # Rules to correctly serve gzip compressed CSS and JS files. |
||
| 266 | # Requires both mod_rewrite and mod_headers to be enabled. |
||
| 267 | <IfModule mod_headers.c> |
||
| 268 | # Serve gzip compressed CSS files if they exist and the client accepts gzip. |
||
| 269 | RewriteCond %{HTTP:Accept-encoding} gzip |
||
| 270 | RewriteCond %{REQUEST_FILENAME}\.gz -s |
||
| 271 | RewriteRule ^(.*)\.css $1\.css\.gz [QSA] |
||
| 272 | |||
| 273 | # Serve gzip compressed JS files if they exist and the client accepts gzip. |
||
| 274 | RewriteCond %{HTTP:Accept-encoding} gzip |
||
| 275 | RewriteCond %{REQUEST_FILENAME}\.gz -s |
||
| 276 | RewriteRule ^(.*)\.js $1\.js\.gz [QSA] |
||
| 277 | |||
| 278 | # Serve correct content types, and prevent mod_deflate double gzip. |
||
| 279 | RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1] |
||
| 280 | RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1] |
||
| 281 | |||
| 282 | <FilesMatch "(\.js\.gz|\.css\.gz)$"> |
||
| 283 | # Serve correct encoding type. |
||
| 284 | Header set Content-Encoding gzip |
||
| 285 | # Force proxies to cache gzipped & non-gzipped css/js files |
||
| 286 | # separately. |
||
| 287 | Header append Vary Accept-Encoding |
||
| 288 | </FilesMatch> |
||
| 289 | </IfModule> |
||
| 290 | </IfModule> |
||
| 291 | |||
| 292 | </Directory> |
||
| 293 | </pre> |
||
| 294 | {{tip(Pour ce fichier de configuration, se baser sur celui fournit par Mageia lors de l'installation d'un Drupal depuis la logithèque de Mageia.)}} |
||
| 295 | |||
| 296 | * créer un dossier (avec un Drupal dedans) appelé dossier_site dans /chemin/ |
||
| 297 | * restart apache |
||
| 298 | <pre> |
||
| 299 | sudo service httpd stop |
||
| 300 | sudo service httpd start |
||
| 301 | </pre> |
||
| 302 | |||
| 303 | * consulter localhost/nom_du_site |
||
| 304 | |||
| 305 | 2 | Florent Torregrosa | |
| 306 | h2. Pour Fedora |