PHP - MySQL [Retour au menu]
Installation de PHP

Il faut aller sur PHP Net, et downloader PHP.

J'ai downloadé un .ZIP, dans lequel j'ai trouvé 2 exécutables : php.zip et php-cli.exe... L'un ou l'autre n'ont pas l'air d'être des fichiers d'installation... Je copie donc bêtement les fichiers décompressés dans C:\PHP, qui est un dossier que je viens de créer.

Comme conseillé dans PHP France, je copie php.ini-dist dans C:\Winnt, et je renomme ce fichier en php.ini.

Personnalisation de PHP.INI

J'édite ce fichier php.ini, et je recherche la chaîne include_path. Je trouve :

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below
doc_root =
; The directory under which PHP opens the script using /~usernamem used only
; if nonempty.
user_dir =
; Directory in which the loadable extensions (modules) reside.
extension_dir = ./
; Whether or not to enable the dl() function. The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
enable_dl = On
; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers. Left undefined, PHP turns this on by default. You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; cgi.force_redirect = 1
; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape
; (iPlanet) web servers, you MAY need to set an environment variable name that PHP
; will look for to know it is OK to continue execution. Setting this variable MAY
; cause security issues, KNOW WHAT YOU ARE DOING FIRST.
; cgi.redirect_status_env = ;
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

Je modifie ce code en :

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
include_path = .
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below
doc_root =

; The directory under which PHP opens the script using /~usernamem used only
; if nonempty.
user_dir =
; Directory in which the loadable extensions (modules) reside.
;extension_dir = ./
; Ca, c'est pour indiquer ou sont les DLL nécessaires :
extension_dir = c:\php\extensions
; Whether or not to enable the dl() function. The dl() function does NOT work
; properly in multithreaded servers, such as IIS or Zeus, and is automatically
; disabled on them.
enable_dl = On
; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers. Left undefined, PHP turns this on by default. You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; cgi.force_redirect = 1
; if cgi.force_redirect is turned on, and you are not running under Apache or Netscape
; (iPlanet) web servers, you MAY need to set an environment variable name that PHP
; will look for to know it is OK to continue execution. Setting this variable MAY
; cause security issues, KNOW WHAT YOU ARE DOING FIRST.
; cgi.redirect_status_env = ;
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
upload_max_filesize = 2097152

dans la section "Windows Extensions", il y a toute une série de DLLs qu'on peut àvoir à utiliser. L'utilisation de MySQL ne recquiert pas de DLL particulière. Si on en a besoin d'une autre, il suffit de décommenter (enlever le ;) devant chaque DLL recquise.

Je crée ensuite un dossier Sessions, dans C:\PHP, afin d'y inclure les infos de sessions, et je modifie la ligne dans php.ini :

session.save_path = /tmp

par

session.save_path = c:\php\sessions

Bien. Une fois tout ceci fait, on peut aller dans Internbet Explorer et taper l'adresse

http://127.0.0.1

ou

http://localhost

ce qui revient au même

Apparemment, on dirait qu'à partir d'ici, tout va pour le mieux, et que ça marche : J'en ai fait la preuve :

Créer un fichier test.php dans lequel il y a ce contenu : (La partie en gras représente le code PHP côté serveur - C'est un petit code à la con )

<html>
  <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>
<body>
  <?
    $date = date("d-m-Y");
    echo "$date";
  ?>
</body>
</html>

Dans Internet explorer, aller dans http://localhost, et cliquer sur test.php. L'affichage suivant apparait :

09-08-2002

Et quand on va dans le code source HTML :

<html>
  <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>
<body bgcolor="#FFFFFF" text="#000000">
  09-08-2002
</body>
</html>

Les instructions PHP ne sont plus visibles, ce qui prouve que le code a généré du HTML côté serveur