Difference between revisions of "Appendices:ApachePHP"

From Wiki_dbSQWare
Jump to: navigation, search
(Changes httpd.conf)
(Changes for /etc/php-fpm.d/www.conf)
Line 144: Line 144:
 
Change the file /etc/php-fpm.d/www.conf
 
Change the file /etc/php-fpm.d/www.conf
 
<syntaxhighlight lang="sh" line>
 
<syntaxhighlight lang="sh" line>
[root@vmsqwarebox ~]# cp -p /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf.org
+
[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
+
[root@vmsqwarebox ~] vi /etc/php-fpm.d/www.conf
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<br>
 
<br>

Revision as of 10:00, 28 April 2025

Work In Progress

The easiest way is to install the standard packages from your OS distribution, but this requires connecting to a repo.
The httpd daemon can also be started with a user other than root, provided you don't use port 80 for the site.
This example is an installation of Apache and PHP 8.2.18 on Rocky Linux 9.

Installing packages

Installing Apache Web Server with dnf :

1 [root@vmsqwarebox ~] dnf -y update
2 [root@vmsqwarebox ~] dnf install httpd mod_ssl -y


Start and enable Apache :

1 systemctl start httpd
2 systemctl enable httpd
3 systemctl status httpd
4 
5 ## If firewall is active :
6 firewall-cmd --zone=public --permanent --add-service=http
7 firewall-cmd --zone=public --permanent --add-service=https
8 firewall-cmd --reload


Test to see if your site is responding :

1 http://192.168.231.28/


Repo activation and installing PHP 8.2.18 :

 1 #To add EPEL and REMI Repository.
 2 dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
 3 dnf -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
 4 
 5 #To install yum utilities.
 6 dnf -y install yum-utils
 7 
 8 #To enable php 8.2 Remi repository.
 9 dnf module reset php
10 dnf module install php:remi-8.2
11 
12 # To list the available PHP version:
13 dnf module list php
14 
15 Last metadata expiration check: 0:01:14 ago on Mon 15 Apr 2024 10:10:57 AM EDT.
16 Rocky Linux 9 - AppStream
17 Name                                   Stream                                         Profiles                                                         Summary
18 php                                    8.1                                            common [d], devel, minimal                                       PHP scripting language
19 php                                    8.2                                            common [d], devel, minimal                                       PHP scripting language
20 
21 Remi's Modular repository for Enterprise Linux 9 - x86_64
22 Name                                   Stream                                         Profiles                                                         Summary
23 php                                    remi-7.4                                       common [d], devel, minimal                                       PHP scripting language
24 php                                    remi-8.0                                       common [d], devel, minimal                                       PHP scripting language
25 php                                    remi-8.1                                       common [d], devel, minimal                                       PHP scripting language
26 php                                    remi-8.2 [e]                                   common [d] [i], devel, minimal                                   PHP scripting language
27 php                                    remi-8.3                                       common [d], devel, minimal                                       PHP scripting language
28 
29 Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
30 
31 # Installing PHP
32 dnf install -y php php-pdo php-mysqlnd php-ldap php-zip php-gmp
33 
34 root@vmsqwarebox:/root # php -v
35 PHP 8.2.18 (cli) (built: Apr  9 2024 18:46:23) (NTS gcc x86_64)
36 Copyright (c) The PHP Group
37 Zend Engine v4.2.18, Copyright (c) Zend Technologies
38     with Zend OPcache v8.2.18, Copyright (c), by Zend Technologies


Test to see if your site is responding and is setup with PHP 8.2 :

 1 systemctl restart httpd
 2 
 3 cat <<EOFCAT >/var/www/html/phpinfo.php
 4 <?php
 5 
 6 phpinfo();
 7 
 8 ?>
 9 EOFCAT
10 
11 http://192.168.230.22/phpinfo.php
12 
13 => PHP Version 8.2.18


Changes php.ini + php.conf

Change the file /etc/php.ini

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


In principle, the only changes to be made are the following :

1 ;session.save_path = "/tmp"
2 memory_limit = 512M


Change the file /etc/httpd/conf.d/php.conf

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


In principle, the only changes to be made are the following :

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


Changes httpd.conf

Change the file /etc/httpd/conf/httpd.conf

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


In principle, the only changes to be made are the following :

1 User dbsqware
2 Group dba


Changes for /etc/php-fpm.d/www.conf

Change the file /etc/php-fpm.d/www.conf

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


In principle, the only changes to be made are the following :

 1 user = dbsqware
 2 group = dba
 3 ;listen.acl_users = apache,nginx
 4 ;listen.acl_groups =
 5 listen.owner = dbsqware
 6 listen.group = dba
 7 listen.mode = 0660
 8 listen.allowed_clients =
 9 php_value[session.save_path]    = /var/tmp
10 php_admin_value[memory_limit] = 512M


Changes for /usr/lib/systemd/system/php-fpm.service

Change the file /usr/lib/systemd/system/php-fpm.service

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


In principle, the only changes to be made are the following :

1 [Service]
2 User=dbsqware
3 Group=dba


Reload

 1 systemctl daemon-reload
 2 
 3 chown -R dbsqware:dba /var/log/php-fpm /var/log/httpd
 4 chmod -R g+rw /var/log/php-fpm /var/log/httpd
 5 chmod -R g+s /var/log/php-fpm /var/log/httpd
 6 
 7 systemctl is-enabled php-fpm
 8 
 9 systemctl enable --now php-fpm
10 
11 systemctl start php-fpm
12 systemctl start httpd