Installation de Apache + MySql + PHP pour Debian
basé sur le tutorial de
http://www.ac-creteil.fr/reseaux/system ... ebian.html
mais en utilisant les versions les plus recentes des programmes mentionnés (Apache 2, PHP 5, ...) et en faisant des vérifications à chaque étape.
Apache
installation:
Code:
apt-get install apache2
vérification:->
http://debian/
PHPinstallation:Code:
apt-get install php5
vérification:créer le fichier
/var/www/foo/foo.php (avec privileges root) en y insérant le code suivant:
Citer:
<?
phpinfo();
?>
->
http://debian/foo/foo.php
MySQLinstallation:Code:
apt-get install mysql-server
+ suivre les instructions du fichier
/usr/share/doc/mysql-server-5.0/README.Debian.gz:
Citer:
(...)
* WHAT TO DO AFTER INSTALLATION:
================================
The MySQL manual describes certain steps to do at this stage in a separate
chapter. They are not necessary as the Debian packages does them
automatically.
The only thing that is left over for the admin is
- setting the passwords
- creating new users and databases
- read the rest of this text
* PASSWORDS:
============
It is strongly recommended to set a password for the mysql root user (which
is NOT the same as the "normal" root user) with the command:
/usr/bin/mysqladmin -u root password 'enter-your-good-new-password-here'
If you already had a password set add " -p " before "-u" to the line above.
If you are tired to type the password in every time or want to automate your
scripts you can store it in the file $HOME/.my.cnf. It should be chmod 0600
(-rw------- username username .my.cnf) to ensure that nobody else can read
it. Every other configuration parameter can be stored there, too. You will
find an example below and more information in the MySQL manual in
/usr/share/doc/mysql-doc or
http://www.mysql.com.
ATTENTION: It is necessary, that a .my.cnf from root always contains a "user"
line wherever there is a "password" line, else, the Debian maintenance
scripts, that use /etc/mysql/debian.cnf, will use the username
"debian-sys-maint" but the password that is in root's .my.cnf. Also note,
that every change you make in the /root/.my.cnf will affect the mysql cron
script, too.
# an example of $HOME/.my.cnf
[client]
user = your-mysql-username
password = enter-your-good-new-password-here
(...)
créer le mot de passe pour l'administrateur de MySQL
Code:
/usr/bin/mysqladmin -u root password 'enter-your-good-new-password-here'
créer le fichier
/root/.my.cnf (avec privileges root) et y insérer:
Citer:
[client]
user = root
password = enter-your-good-new-password-here
protéger le fichier des regards exterieurs ...
Code:
chmod 0600 /root/.my.cnf
vérification:lancer
mysql dans une console (avec privileges root -> su) et tester:
Code:
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 44 to server version: 5.0.22-Debian_3-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select host, user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| debian | root |
| localhost | debian-sys-maint |
| localhost | root |
+-----------+------------------+
3 rows in set (0.01 sec)
mysql> quit
Bye
PHP/MySQLinstallation:Code:
apt-get install php5-mysql
vérification:créer le fichier
/var/www/foo/foo2.php (avec privileges root) en y insérant le code suivant:
Citer:
<?php
// Url de votre base de donnée. Généralement, c'est locahost.
$Serveur_db="localhost";
// Votre login pour votre base de donnée
$User_db="root";
// Votre mot de passe pour la base de donnée
$Passe_db="enter-your-good-new-password-here";
// Nom de votre base de donnée
$Base_name="mysql";
// Connection à MySQL
$Connect_db=mysql_connect($Serveur_db,$User_db,$Passe_db);
// Sélection de la base de donnée
mysql_select_db($Base_name,$Connect_db);
// Séléction de la table
$requete=mysql_query("select host, user from user");
while($j=mysql_fetch_array($requete)) // Boucle avec la fonction while()
{
// On sort les informations de la table et on les affiche
print '• '.$j[host].' - <span style="font-weight:bold;">'.$j[user].'</span><br>';
}
print '<br>Il y a '.mysql_numrows($requete).' utilisateur(s)!';
?>
->
http://debian/foo/foo2.php
phpMyAdmininstallation:Code:
apt-get install phpmyadmin
vérification:->
http://debian/phpmyadmin/ 
mais aussiredémarrer le server apache:
Code:
# /etc/init.d/apache2 restart
redémarrer le server mysql:
Code:
# /etc/init.d/mysql restart
v'là
