pense-bête de bruno sanchiz

Accueil > Linux > les programmes à installer > installation de APACHE MYSQL mariadb

installation de APACHE MYSQL mariadb

Publié le 1er mars 2007, dernière mise-à-jour le 28 février 2023, 22 visites, 23644 visites totales.

vori aussi configuration de apache2

php7 + phpmyadmin +mysql / mariadb

#phpmyadmin

PROGRAMMATION PHP7 APACHE2 MARIADB

  • buster/deb10
    • php7
      apt-get install  apache2 libapache2-mod-php mariadb-server php-gmp php-imap php-intl php gnupg2 php php-bz2 php-curl php-cli php-common php-gd php-json php-mbstring php-mysql  php-readline php-sqlite3 php-xml php-zip dh-php    php-gettext php-http php-memcache  php-pear php-pecl-http php-php-gettext php-phpseclib php-propro php-raphf  php-text-wiki  pkg-php-tools php-fpdf ; echo "oboslete : php-opcache";
    • mariadb/mysql
      apt-get install mariadb-common mariadb-server php-mysql  ;echo  akonadi-backend-mysql dbconfig-mysql default-mysql-client default-mysql-server libdbd-mysql-perl:amd64 libmariadb3:amd64 libmysqlclient18:amd64 libqt4-sql-mysql:amd64 libqt5sql5-mysql:amd64 mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server mariadb-server-10.3 mariadb-server-core-10.3 mysql-client mysql-common php-mysql php5-mysql php7.3-mysql python-mysql.connector python-mysqldb python3-mysql.connector
  • bullseye/deb11
    • php7
      apt-get install dh-php libapache2-mod-php php php-bz2 php-cli php-common php-curl php-fpdf php-gd  php-gmp php-http php-imap php-intl php-json php-mbstring php-memcache php-mysql php-pear php-pecl-http php-php-gettext php-phpseclib php-propro php-raphf php-readline php-sqlite3 php-text-wiki php-xml php-zip pkg-php-tools
      ; echo obsolete : php-gettext
    • mariadb/mysql
      apt-get install mariadb-common mariadb-server php-mysql mysql-common

problème de version php : exemple du passage à php7

service apache2 stop
a2dismod php5
a2enmod php7 #( ou a2enmod php7.4 )?
service apache2 start

problème de apache2 :

Le problème peut venir de vieilles versions de php ; dans ce cas,

  • apt-cache policy php donne le php accessible ( 5.5 , 7.4 ... ) qui devrait être le même que celui donné par dpkg -l |egrep " php[0-9\.]+ "|cut -d " " -f3

[<-phpmyadmin]

PHPMYADMIN

Si on ne peut pas l’installer normalement, le télécharger sur le site https://files.phpmyadmin.net/phpMyAdmin/ et prendre celui avec le plus grand numéro ; dans l’exemple en dessous on a le fichier phpMyAdmin-4.9.5-all-languages.zip.

créer un fichier /etc/apache2/conf-available/phpmyadmin.conf :

PUIS a2enconf phpmyadmin.conf

DOC : https://www.gabinhocity.eu/installer-apache-php7-3-mysql-et-phpmyadmin-sur-debian-10-buster/


Il peut être pratique d’avoir un utilisateur dans le groupe www-data ( adduser machin www-data ). Ensuite on peut écrire avec cet utilisateur dans le répertoire /var/www/html et chown www-data.www-data puis un chmod -R 770 lesfichiers permet une utilisation.


phpmyadmin en français ( en test ) :
mettre ces deux lignes à la fin du fichier /etc/phpmyadmin/config.inc.php ( ou /usr/share/phpmyadmin/config.inc.php ) :

ou directement :
echo -e "\$cfg['DefaultLang'] = 'fr';\n\$cfg['FilterLanguages'] = '^(fr|en)';" >> /etc/phpmyadmin/config.inc.php


Erreur : mysql ou mariadb ne redémarre pas ; un log donne "Can't lock aria control file '/var/lib/mysql/aria_log_control" : effacer /var/lib/mysql/ib_logfile0 et /var/lib/mysql/ib_logfile1 :


Voir configuration de apache2


DOCS
archives installation
archives phpmyadmin
archives mysql
erreurs à l’installation



https://docs.phpmyadmin.net/fr/latest/config.html#languages
https://dev.mysql.com/downloads/connector/python/
http://fr.php.net/manual/fr/function.mysql-fetch-row.php
http://mysqltutorial.org/python-connecting-mysql-databases/
https://www.mysql.com/products/connector/
programme apache2-doc : apt-get install apache2-doc puis afficher index

The configuration layout for an Apache2 web server installation on Debian systems is as follows :

  • apache2.conf is the main configuration file. It puts the pieces together by including all remaining configuration files when starting up the web server.
  • ports.conf is always included from the main configuration file. It is used to determine the listening ports for incoming connections, and this file can be customized anytime.
  • Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ directories contain particular configuration snippets which manage modules, global configuration fragments, or virtual host configurations, respectively.
  • They are activated by symlinking available configuration files from their respective *-available/ counterparts. These should be managed by using our helpers a2enmod, a2dismod, a2ensite, a2dissite, and a2enconf, a2disconf . See their respective man pages for detailed information.
  • The binary is called apache2. Due to the use of environment variables, in the default configuration, apache2 needs to be started/stopped with /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not work with the default configuration.

Document Roots

By default, Debian does not allow access through the web browser to any file apart of those located in /var/www, public_html directories (when enabled) and /usr/share (for web applications). If your site is using a web document root located elsewhere (such as in /srv) you may need to whitelist your document root directory in /etc/apache2/apache2.conf.

The default Debian document root is /var/www/html. You can make your own virtual hosts under /var/www. This is different to previous releases which provides better security out of the box.



ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")



(2007)
installation de apache2

Permet d’installer un serveur apache/mysql sur son ordinateur

INSTALLATION

A LA DEMANDE DU MOT DE PASSE, rentrer un mot de passe .........................................breezy edgy dapper

sudo apt-get install php5 apache2 apache2-mpm-prefork libapache2-mod-php5 php5-mysql php5-gd php5-cli mysql-server mysql-client mysql-common libmysqlclient12 libapache2-mod-auth-mysql php5-cgi php5-cli

.........................................gutsy

sudo apt-get install php5 apache2 apache2-mpm-prefork libapache2-mod-php5 php5-mysql php5-gd php5-cli mysql-server mysql-client mysql-common libmysqlclient15off libapache2-mod-auth-mysql php5-cgi php5-cli

Malheureusement, le répertoire de base de apache ( obtenu avec l’adresse http://127.0.0.1 ) est root pour ses permissions donc :


dans un terminal ,tapez sudo chmod a+w /var/www/ && sudo apache2 -k restart

Pour voir si ça marche, créez un fichier phpinfo.php dans /var/www contenant une ligne :

<?php phpinfo() ; ?> Si ça ne marche pas voir en dessous

Puis ouvrez http://127.0.0.1/phpinfo.php

installation de gd ( sous gutsy gd est activée de base )

éditer sudo gedit /etc/php5/apache2/php.ini et, dans le paragraphe commençant par dynamic, enlever le ; devant extension=gd.so

en profiter pour changer les valeurs suivantes :

max_execution_time = 3000 ; Maximum execution time of each script, in seconds

max_input_time = 6000 ; Maximum amount of time each script may spend parsing request data

memory_limit = 128M ; Maximum amount of memory a script may consume (8MB)

(automatisable par cd /etc/php5/apache2/ && sudo chmod 777 php.ini && cat php.ini|sed "s/max_execution_time = \([0-9]*\) /max_execution_time = 3000 /" |sed "s/max_input_time = \([0-9]*\) /max_input_time = 6000 /" > php.ini && sudo chmod 644 php.ini && sudo apache2 -k start )

puis redémarrer apache :

sudo apache2 -k restart

http://127.0.0.1/phpinfo.php doit indiquer la bibliothèque gd


installez ENSUITE phpmyadmin : sudo apt-get install phpmyadmin en sélectionnant apache2

vérifier son installation avec l’adresse http://127.0.0.1/phpmyadmin login :root motdepasse :celuidudessus

si rien n’apparaît taper dans un terminal :

sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

en cas de pb, configurer le mot de passe de phpmyadmin avec mysql_secure_installation et sans mot de passe au début

( pour refaire les réponses :

dpkg-reconfigure -priority=low postfix ) puis :

mysqladmin -u root password ’votre_mot_de_passe’

.........................................
Si les fichiers php n’affiche rien mais veulent être ouverts avec un éditeur de texte quelconque :

commencer par sudo apache2 -k restart, ça peut suffire

sudo apt-get install mysql-server-5.0 apache2 apache2-doc libapache2-mod-php5 php5 php5-cli php5-pear php5-gd php5-mysql phpmyadmin && sudo mysql_install_db && sudo mysql_secure_installation && sudo a2enmod php5 && sudo apt-get install libapache2-mod-php5

dans /etc/apache2/httpd.conf ajouter les lignes Code :

LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

AddType application/x-tar .tgz

AddType application/x-httpd-php .php

dans /etc/apache2/mods-available/php5.conf ajouter la ligne

AddType application/x-httpd-php5 .php

dans /etc/apache2/mods-available/php5.load ajouter la ligne

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AddType application/x-httpd-php5 /cgi-bin/php5

dans /etc/apache2/httpd.conf ajouter les lignes

LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

AddType application/x-tar .tgz

AddType application/x-httpd-php .php

ls /etc/apache2/mods-enabled/php5.conf /etc/apache2/mods-enabled/php5.load

doit donner /etc/apache2/mods-enabled/php5.conf /etc/apache2/mods-enabled/php5.load

vérifier l existence des liens :

ls -al /etc/apache2/mods-enabled/php5* doit donner

/etc/apache2/mods-enabled/php5.conf -> ../mods-available/php5.conf

/etc/apache2/mods-enabled/php5.load -> ../mods-available/php5.load

sinon tapez :

sudo ln -s /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php5.conf && sudo ln -s /etc/apache2/mods-available/php5.load /etc/apache2/mods-enabled/php5.load

Eventuellement enlever les # dans sudo gedit /etc/apache2/apache2.conf

#AddType application/x-httpd-php .php

#AddType application/x-httpd-php-source .phps

Et ensuite

sudo apache2 -k restart && sudo /etc/init.d/apache2 force-reload

PROBLEMES

Fatal error : Unknown : Failed opening required ’/var/www/transformee_de_fourier.php’ (include_path=’. :/usr/share/php :/usr/share/pear’) in Unknown on line 0

sudo chmod a+r /var/www/transformee_de_fourier.php

voire pour le rendre modifiable :

sudo chmod 777 /var/www/transformee_de_fourier.php

a2enmod php5

/etc/init.d/apache2 force-reload


Ouvrez un terminal et tapez :

sudo mysql_secure_installation

Le script de sécurisation du serveur MySQL démarre. Si vous êtes à l’aise avec l’anglais les questions posées sont assez simples et il suffit d’y répondre puis de passer à la suite.

Enter current password for root (enter for none) :

Validez avec « Entrée ». En effet, pour l’instant, il n’y a pas de mot de passe.

Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password ? [Y/n]

Faites « Entrée » pour choisir un mot de passe.

New password :

Entrez le mot de passe de votre choix et validez par « Entrée ».

By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users ? [Y/n]

Faites « Entrée » pour supprimer l’utilisateur anonyme créé lors de l’installation.

Normally, root should only be allowed to connect from ’localhost’. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely ? [Y/n]

Si vous n’avez pas besoin d’administrer votre base de données à distance, ce qui devrait être le cas de la plupart des utilisateurs, validez par « Entrée ». Ainsi, l’utilisateur « root » ne pourra se connecter qu’en local. Sinon tapez « n ».

Remove test database and access to it ? [Y/n]

Validez par « Entrée » pour supprimer la base de données de test créée lors de l’installation.

Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now ? [Y/n]

Validez par « Entrée » pour prendre en compte les changements que vous venez de faire et les appliquer immédiatement.

Si vous êtes sous Gutsy Tribu 5, à la fin de l’installation des paquets, une page bleue va s’afficher et vous demander le nouveau mot de passe root MySQL.

[bruno sanchiz]