« Annexes:ApachePHP » : différence entre les versions
| (12 versions intermédiaires par 2 utilisateurs non affichées) | |||
| Ligne 10 : | Ligne 10 : | ||
<pre> | <pre> | ||
[root@vmsqwarebox ~]# dnf -y update | [root@vmsqwarebox ~]# dnf -y update | ||
[root@vmsqwarebox ~]# dnf install httpd -y | [root@vmsqwarebox ~]# dnf install httpd mod_ssl -y | ||
</pre> | </pre> | ||
<br> | <br> | ||
| Ligne 29 : | Ligne 29 : | ||
Test pour voir si votre site répond : | Test pour voir si votre site répond : | ||
<pre> | <pre> | ||
http://192.168. | http://192.168.231.28/ | ||
</pre> | </pre> | ||
<br> | <br> | ||
| Ligne 36 : | Ligne 36 : | ||
<pre> | <pre> | ||
#To add EPEL and REMI Repository. | #To add EPEL and REMI Repository. | ||
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest- | dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm | ||
dnf -y install https://rpms.remirepo.net/enterprise/remi-release- | dnf -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm | ||
#To install yum utilities. | #To install yum utilities. | ||
| Ligne 53 : | Ligne 53 : | ||
Name Stream Profiles Summary | Name Stream Profiles Summary | ||
php 8.1 common [d], devel, minimal PHP scripting language | php 8.1 common [d], devel, minimal PHP scripting language | ||
php 8.2 common [d], devel, minimal PHP scripting language | |||
Remi's Modular repository for Enterprise Linux 9 - x86_64 | Remi's Modular repository for Enterprise Linux 9 - x86_64 | ||
| Ligne 65 : | Ligne 66 : | ||
# Installing PHP | # Installing PHP | ||
dnf install -y php php-pdo php-mysqlnd php-ldap php-zip | dnf install -y php php-pdo php-mysqlnd php-ldap php-zip php-gmp | ||
root@vmsqwarebox:/root # php -v | root@vmsqwarebox:/root # php -v | ||
| Ligne 89 : | Ligne 90 : | ||
http://192.168.230.22/phpinfo.php | http://192.168.230.22/phpinfo.php | ||
=> PHP Version 8.2. | => PHP Version 8.2.18 | ||
</pre> | </pre> | ||
<br> | <br> | ||
| Ligne 105 : | Ligne 106 : | ||
<pre> | <pre> | ||
;session.save_path = "/tmp" | ;session.save_path = "/tmp" | ||
memory_limit = 512M | memory_limit = 512M | ||
</pre> | </pre> | ||
| Ligne 153 : | Ligne 153 : | ||
user = dbsqware | user = dbsqware | ||
group = dba | group = dba | ||
... | |||
listen.owner = dbsqware | listen.owner = dbsqware | ||
listen.group = dba | listen.group = dba | ||
listen.mode = 0660 | listen.mode = 0660 | ||
... | |||
;listen.acl_users = apache,nginx | |||
;listen.acl_groups = | |||
... | |||
listen.allowed_clients = | |||
php_value[session.save_path] = /var/tmp | php_value[session.save_path] = /var/tmp | ||
php_admin_value[memory_limit] = 512M | php_admin_value[memory_limit] = 512M | ||
| Ligne 175 : | Ligne 181 : | ||
User=dbsqware | User=dbsqware | ||
Group=dba | Group=dba | ||
</pre> | |||
<br> | |||
==Modification du /etc/php.d/10-opcache.ini== | |||
Modifiez le fichier /etc/php.d/10-opcache.ini | |||
<pre> | |||
[root@vmsqwarebox ~]# cp -p /etc/php.d/10-opcache.ini /etc/php.d/10-opcache.ini.org | |||
[root@vmsqwarebox ~]# vi /etc/php.d/10-opcache.ini | |||
</pre> | |||
<br> | |||
En principe, les seules modifications à faire sont les suivantes (sinon fpm ne voit pas les modifs de liens symboliques) : | |||
<pre> | |||
;opcache.revalidate_path=0 | |||
opcache.revalidate_path=1 | |||
</pre> | </pre> | ||
<br> | <br> | ||
Dernière version du 10 septembre 2025 à 18:03
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.18 sous Rocky Linux 9.
(Version 7.4 sous CentOS 7 : Installation ApachePHP CentOS 7).
(Version 8.2.5 sous Rocky 8 : Installation ApachePHP Rocky 8).
Installation des paquets
Installation Apache Web Server dnf :
[root@vmsqwarebox ~]# dnf -y update [root@vmsqwarebox ~]# dnf install httpd mod_ssl -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.231.28/
Activation repo + install PHP 8.2.18 :
#To add EPEL and REMI Repository.
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
dnf -y install https://rpms.remirepo.net/enterprise/remi-release-9.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:01:14 ago on Mon 15 Apr 2024 10:10:57 AM EDT.
Rocky Linux 9 - AppStream
Name Stream Profiles Summary
php 8.1 common [d], devel, minimal PHP scripting language
php 8.2 common [d], devel, minimal PHP scripting language
Remi's Modular repository for Enterprise Linux 9 - x86_64
Name Stream Profiles Summary
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
php remi-8.3 common [d], 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 php-gmp
root@vmsqwarebox:/root # php -v
PHP 8.2.18 (cli) (built: Apr 9 2024 18:46:23) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.18, Copyright (c) Zend Technologies
with Zend OPcache v8.2.18, 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.18
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" 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.owner = dbsqware listen.group = dba listen.mode = 0660 ... ;listen.acl_users = apache,nginx ;listen.acl_groups = ... listen.allowed_clients = 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
Modification du /etc/php.d/10-opcache.ini
Modifiez le fichier /etc/php.d/10-opcache.ini
[root@vmsqwarebox ~]# cp -p /etc/php.d/10-opcache.ini /etc/php.d/10-opcache.ini.org [root@vmsqwarebox ~]# vi /etc/php.d/10-opcache.ini
En principe, les seules modifications à faire sont les suivantes (sinon fpm ne voit pas les modifs de liens symboliques) :
;opcache.revalidate_path=0 opcache.revalidate_path=1
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