« Annexes:ApachePHPRocky8 » : différence entre les versions

De WikiFr_dbSQWare
Aller à la navigation Aller à la recherche
m Ymauger a déplacé la page Annexes:ApachePHP vers Annexes:ApachePHPRocky8 sans laisser de redirection
 
(18 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
Le plus simple est de faire une installation des paquets standards de la distribution de votre OS, mais cela requiert une connexion à un repo. Le démarrage du deamon httpd peut également se faire avec un autre utilisateur que root à condition de ne pas utiliser le port 80 pour le site.
Le plus simple est de faire une installation des paquets standards de la distribution de votre OS, mais cela requiert une connexion à un repo.<br>
Le démarrage du deamon httpd peut également se faire avec un autre utilisateur que root à condition de ne pas utiliser le port 80 pour le site.<br>
Cet exemple est une installation de Apache et PHP 8.2 sous Rocky Linux 8.<br>
(Version 7.4 sous CentOS 7 : [[Annexes:ApachePHPCentOS7|Installation ApachePHP CentOS 7]]).<br>


==Installation des paquets==
==Installation des paquets==


Installation des paquets standards par yum :
Installation Apache Web Server dnf :
<pre>
<pre>
[root@vmsqwarebox ~]# yum install httpd php php-pdo php-mysql
[root@vmsqwarebox ~]# dnf -y update
[root@vmsqwarebox ~]# dnf install httpd -y
</pre>
</pre>
<br>
<br>


==Modification du php.ini==
Démarrage et activation de apache :
<pre>
systemctl start httpd
systemctl enable httpd
systemctl status httpd
 
## Si firewall non desactivé
# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload
</pre>
<br>
 
Test pour voir si votre site répond :
<pre>
http://192.168.230.28/
</pre>
<br>
 
Activation repo + install PHP 8.2 :
<pre>
#To add EPEL and REMI Repository.
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
 
#To install yum utilities.
dnf -y install yum-utils
 
#To enable php 8.2 Remi repository.
dnf module reset php
dnf module install php:remi-8.2
 
# To list the available PHP version:
dnf module list php
 
Last metadata expiration check: 0:05:50 ago on Sat 15 Apr 2023 05:33:19 PM CEST.
Rocky Linux 8 - AppStream
Name                            Stream                                  Profiles                                                  Summary
php                              7.2 [d]                                  common [d], devel, minimal                                PHP scripting language
php                              7.3                                      common [d], devel, minimal                                PHP scripting language
php                              7.4                                      common [d], devel, minimal                                PHP scripting language
php                              8.0                                      common [d], devel, minimal                                PHP scripting language
 
Remi's Modular repository for Enterprise Linux 8 - x86_64
Name                            Stream                                  Profiles                                                  Summary
php                              remi-7.2                                common [d], devel, minimal                                PHP scripting language
php                              remi-7.3                                common [d], devel, minimal                                PHP scripting language
php                              remi-7.4                                common [d], devel, minimal                                PHP scripting language
php                              remi-8.0                                common [d], devel, minimal                                PHP scripting language
php                              remi-8.1                                common [d], devel, minimal                                PHP scripting language
php                             remi-8.2 [e]                            common [d] [i], devel, minimal                            PHP scripting language
 
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
 
# Installing PHP
dnf install -y php php-pdo php-mysqlnd php-ldap php-zip


Modifiez le fichier /applis/dbsqware/php/lib/php.ini.
root@vmsqwarebox:/root # php -v
PHP 8.2.5 (cli) (built: Apr 11 2023 16:16:23) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.5, Copyright (c), by Zend Technologies
</pre>
<br>
 
Test pour voir si votre site répond et est configuré avec PHP 8.2 :
<pre>
systemctl restart httpd
 
cat <<EOFCAT >/var/www/html/phpinfo.php
<?php
 
phpinfo();
 
?>
EOFCAT
 
http://192.168.230.22/phpinfo.php
 
=> PHP Version 8.2.5
</pre>
<br>
 
==Modification du php.ini + php.conf==
 
Modifiez le fichier /etc/php.ini
<pre>
<pre>
[root@vmsqwarebox ~]# cp -p /etc/php.ini /etc/php.ini.org
[root@vmsqwarebox ~]# cp -p /etc/php.ini /etc/php.ini.org
Ligne 20 : Ligne 107 :
En principe, les seules modifications à faire sont les suivantes :
En principe, les seules modifications à faire sont les suivantes :
<pre>
<pre>
;session.save_path = "/var/lib/php/session"
;session.save_path = "/tmp"
;session.entropy_file =
;session.entropy_file =
memory_limit = 512M
</pre>
<br>
Modifiez le fichier /etc/httpd/conf.d/php.conf
<pre>
[root@vmsqwarebox ~]# cp -p /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.org
[root@vmsqwarebox ~]# vi /etc/httpd/conf.d/php.conf
</pre>
<br>
En principe, les seules modifications à faire sont les suivantes :
<pre>
#php_value session.save_path    "/var/lib/php/session"
php_value session.save_path    "/var/tmp"
</pre>
</pre>
<br>
<br>
Ligne 27 : Ligne 129 :
==Modification du httpd.conf==
==Modification du httpd.conf==


Modifiez le fichier /etc/httpd/conf/httpd.conf .
Modifiez le fichier /etc/httpd/conf/httpd.conf
<pre>
[root@vmsqwarebox ~]# cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
[root@vmsqwarebox ~]# vi /etc/httpd/conf/httpd.conf
</pre>
<br>
 
En principe, les seules modifications à faire sont les suivantes :
<pre>
<pre>
Exemple de modifications (User, Group, AddType, …):
ServerName sqwarebox
#LoadModule php5_module modules/libphp5.so
User dbsqware
User dbsqware
Group dba
Group dba
DirectoryIndex index.html index.php index.html.var
AddType application/x-httpd-php .php
</pre>
</pre>
<br>
<br>


==Mise en place du démarrage automatique de apache==
==Modification du /etc/php-fpm.d/www.conf==
 
Modifiez le fichier /etc/php-fpm.d/www.conf
<pre>
[root@vmsqwarebox ~]# cp -p /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.org
[root@vmsqwarebox ~]# vi /etc/php-fpm.d/www.conf
</pre>
<br>


Paramétrage du redémarrage automatique :
En principe, les seules modifications à faire sont les suivantes :
<pre>
<pre>
[root@vmsqwarebox ~]# chkconfig --list httpd
user = dbsqware
httpd          0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt
group = dba
[root@vmsqwarebox ~]# chkconfig httpd on
listen.acl_groups =
[root@vmsqwarebox ~]# chkconfig --list httpd
listen.owner = dbsqware
httpd          0:arrêt 1:arrêt 2:marche        3:marche        4:marche        5:marche        6:arrêt
listen.group = dba
[root@vmsqwarebox ~]# service httpd restart
listen.mode = 0660
Arrêt de httpd :                                          [  OK  ]
php_value[session.save_path]    = /var/tmp
Démarrage de httpd :                                      [  OK  ]
php_admin_value[memory_limit] = 512M
</pre>
<br>
 
==Modification du /usr/lib/systemd/system/php-fpm.service==
Modifiez le fichier /usr/lib/systemd/system/php-fpm.service
<pre>
[root@vmsqwarebox ~]# cp -p /usr/lib/systemd/system/php-fpm.service /usr/lib/systemd/system/php-fpm.service.org
[root@vmsqwarebox ~]# vi /usr/lib/systemd/system/php-fpm.service
</pre>
<br>
 
En principe, les seules modifications à faire sont les suivantes :
<pre>
[Service]
User=dbsqware
Group=dba
</pre>
<br>
 
==Reload des services==
 
<pre>
systemctl daemon-reload
 
chown -R dbsqware:dba /var/log/php-fpm /var/log/httpd
chmod -R g+rw /var/log/php-fpm /var/log/httpd
chmod -R g+s /var/log/php-fpm /var/log/httpd
 
systemctl is-enabled php-fpm
 
systemctl enable --now php-fpm
 
systemctl start php-fpm
systemctl start httpd
</pre>
</pre>
<br>
<br>

Dernière version du 15 avril 2024 à 15:07

Le plus simple est de faire une installation des paquets standards de la distribution de votre OS, mais cela requiert une connexion à un repo.
Le démarrage du deamon httpd peut également se faire avec un autre utilisateur que root à condition de ne pas utiliser le port 80 pour le site.
Cet exemple est une installation de Apache et PHP 8.2 sous Rocky Linux 8.
(Version 7.4 sous CentOS 7 : Installation ApachePHP CentOS 7).

Installation des paquets

Installation Apache Web Server dnf :

[root@vmsqwarebox ~]# dnf -y update
[root@vmsqwarebox ~]# dnf install httpd -y


Démarrage et activation de apache :

systemctl start httpd
systemctl enable httpd
systemctl status httpd

## Si firewall non desactivé
# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload


Test pour voir si votre site répond :

http://192.168.230.28/


Activation repo + install PHP 8.2 :

#To add EPEL and REMI Repository.
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm

#To install yum utilities.
dnf -y install yum-utils

#To enable php 8.2 Remi repository.
dnf module reset php
dnf module install php:remi-8.2

# To list the available PHP version:
dnf module list php

Last metadata expiration check: 0:05:50 ago on Sat 15 Apr 2023 05:33:19 PM CEST.
Rocky Linux 8 - AppStream
Name                             Stream                                   Profiles                                                  Summary
php                              7.2 [d]                                  common [d], devel, minimal                                PHP scripting language
php                              7.3                                      common [d], devel, minimal                                PHP scripting language
php                              7.4                                      common [d], devel, minimal                                PHP scripting language
php                              8.0                                      common [d], devel, minimal                                PHP scripting language

Remi's Modular repository for Enterprise Linux 8 - x86_64
Name                             Stream                                   Profiles                                                  Summary
php                              remi-7.2                                 common [d], devel, minimal                                PHP scripting language
php                              remi-7.3                                 common [d], devel, minimal                                PHP scripting language
php                              remi-7.4                                 common [d], devel, minimal                                PHP scripting language
php                              remi-8.0                                 common [d], devel, minimal                                PHP scripting language
php                              remi-8.1                                 common [d], devel, minimal                                PHP scripting language
php                              remi-8.2 [e]                             common [d] [i], devel, minimal                            PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

# Installing PHP
dnf install -y php php-pdo php-mysqlnd php-ldap php-zip

root@vmsqwarebox:/root # php -v
PHP 8.2.5 (cli) (built: Apr 11 2023 16:16:23) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.5, Copyright (c), by Zend Technologies


Test pour voir si votre site répond et est configuré avec PHP 8.2 :

systemctl restart httpd

cat <<EOFCAT >/var/www/html/phpinfo.php
<?php

phpinfo();

?>
EOFCAT

http://192.168.230.22/phpinfo.php

=> PHP Version 8.2.5


Modification du php.ini + php.conf

Modifiez le fichier /etc/php.ini

[root@vmsqwarebox ~]# cp -p /etc/php.ini /etc/php.ini.org
[root@vmsqwarebox ~]# vi /etc/php.ini


En principe, les seules modifications à faire sont les suivantes :

;session.save_path = "/tmp"
;session.entropy_file =
memory_limit = 512M


Modifiez le fichier /etc/httpd/conf.d/php.conf

[root@vmsqwarebox ~]# cp -p /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.org
[root@vmsqwarebox ~]# vi /etc/httpd/conf.d/php.conf


En principe, les seules modifications à faire sont les suivantes :

#php_value session.save_path    "/var/lib/php/session"
php_value session.save_path    "/var/tmp"


Modification du httpd.conf

Modifiez le fichier /etc/httpd/conf/httpd.conf

[root@vmsqwarebox ~]# cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
[root@vmsqwarebox ~]# vi /etc/httpd/conf/httpd.conf


En principe, les seules modifications à faire sont les suivantes :

User dbsqware
Group dba


Modification du /etc/php-fpm.d/www.conf

Modifiez le fichier /etc/php-fpm.d/www.conf

[root@vmsqwarebox ~]# cp -p /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.org
[root@vmsqwarebox ~]# vi /etc/php-fpm.d/www.conf


En principe, les seules modifications à faire sont les suivantes :

user = dbsqware
group = dba
listen.acl_groups =
listen.owner = dbsqware
listen.group = dba
listen.mode = 0660
php_value[session.save_path]    = /var/tmp
php_admin_value[memory_limit] = 512M


Modification du /usr/lib/systemd/system/php-fpm.service

Modifiez le fichier /usr/lib/systemd/system/php-fpm.service

[root@vmsqwarebox ~]# cp -p /usr/lib/systemd/system/php-fpm.service /usr/lib/systemd/system/php-fpm.service.org
[root@vmsqwarebox ~]# vi /usr/lib/systemd/system/php-fpm.service


En principe, les seules modifications à faire sont les suivantes :

[Service]
User=dbsqware
Group=dba


Reload des services

systemctl daemon-reload

chown -R dbsqware:dba /var/log/php-fpm /var/log/httpd
chmod -R g+rw /var/log/php-fpm /var/log/httpd
chmod -R g+s /var/log/php-fpm /var/log/httpd

systemctl is-enabled php-fpm

systemctl enable --now php-fpm

systemctl start php-fpm
systemctl start httpd