Appendices:ApachePHP: Difference between revisions

From Wiki_dbSQWare
Jump to navigation Jump to search
No edit summary
Line 8: Line 8:


Installing Apache Web Server with dnf :
Installing Apache Web Server with dnf :
<pre>
<syntaxhighlight lang="sh" line>
[root@vmsqwarebox ~]# dnf -y update
[root@vmsqwarebox ~]# dnf -y update
[root@vmsqwarebox ~]# dnf install httpd mod_ssl -y
[root@vmsqwarebox ~]# dnf install httpd mod_ssl -y
</pre>
</syntaxhighlight>
<br>
<br>


Start and enable Apache :
Start and enable Apache :
<pre>
<syntaxhighlight lang="sh" line>
systemctl start httpd
systemctl start httpd
systemctl enable httpd
systemctl enable httpd
Line 24: Line 24:
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload
# firewall-cmd --reload
</pre>
</syntaxhighlight>
<br>
<br>


Test to see if your site is responding :
Test to see if your site is responding :
<pre>
<syntaxhighlight lang="sh" line>
http://192.168.231.28/
http://192.168.231.28/
</pre>
</syntaxhighlight>
<br>
<br>


Repo activation and installing PHP 8.2.18 :
Repo activation and installing PHP 8.2.18 :
<pre>
<syntaxhighlight lang="sh" line>
#To add EPEL and REMI Repository.
#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://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Line 73: Line 73:
Zend Engine v4.2.18, Copyright (c) Zend Technologies
Zend Engine v4.2.18, Copyright (c) Zend Technologies
     with Zend OPcache v8.2.18, Copyright (c), by Zend Technologies
     with Zend OPcache v8.2.18, Copyright (c), by Zend Technologies
</pre>
</syntaxhighlight>
<br>
<br>


Test to see if your site is responding and is setup with PHP 8.2 :
Test to see if your site is responding and is setup with PHP 8.2 :
<pre>
<syntaxhighlight lang="sh" line>
systemctl restart httpd
systemctl restart httpd


Line 91: Line 91:


=> PHP Version 8.2.18
=> PHP Version 8.2.18
</pre>
</syntaxhighlight>
<br>
<br>


Line 97: Line 97:


Change the file /etc/php.ini
Change the file /etc/php.ini
<pre>
<syntaxhighlight lang="sh" line>
[root@vmsqwarebox ~]# cp -p /etc/php.ini /etc/php.ini.org
[root@vmsqwarebox ~]# cp -p /etc/php.ini /etc/php.ini.org
[root@vmsqwarebox ~]# vi /etc/php.ini
[root@vmsqwarebox ~]# vi /etc/php.ini
</pre>
</syntaxhighlight>
<br>
<br>


In principle, the only changes to be made are the following :
In principle, the only changes to be made are the following :
<pre>
<syntaxhighlight lang="sh" line>
;session.save_path = "/tmp"
;session.save_path = "/tmp"
memory_limit = 512M
memory_limit = 512M
</pre>
</syntaxhighlight>
<br>
<br>


Change the file /etc/httpd/conf.d/php.conf
Change the file /etc/httpd/conf.d/php.conf
<pre>
<syntaxhighlight lang="sh" line>
[root@vmsqwarebox ~]# cp -p /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.org
[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
[root@vmsqwarebox ~]# vi /etc/httpd/conf.d/php.conf
</pre>
</syntaxhighlight>
<br>
<br>


In principle, the only changes to be made are the following :
In principle, the only changes to be made are the following :
<pre>
<syntaxhighlight lang="sh" line>
#php_value session.save_path    "/var/lib/php/session"
#php_value session.save_path    "/var/lib/php/session"
php_value session.save_path    "/var/tmp"
php_value session.save_path    "/var/tmp"
</pre>
</syntaxhighlight>
<br>
<br>


Line 127: Line 127:


Change the file /etc/httpd/conf/httpd.conf
Change the file /etc/httpd/conf/httpd.conf
<pre>
<syntaxhighlight lang="sh" line>
[root@vmsqwarebox ~]# cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
[root@vmsqwarebox ~]# cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
[root@vmsqwarebox ~]# vi /etc/httpd/conf/httpd.conf
[root@vmsqwarebox ~]# vi /etc/httpd/conf/httpd.conf
</pre>
</syntaxhighlight>
<br>
<br>


In principle, the only changes to be made are the following :
In principle, the only changes to be made are the following :
<pre>
<syntaxhighlight lang="sh" line>
User dbsqware
User dbsqware
Group dba
Group dba
</pre>
</syntaxhighlight>
<br>
<br>


Line 143: Line 143:


Change the file /etc/php-fpm.d/www.conf
Change the file /etc/php-fpm.d/www.conf
<pre>
<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
</pre>
</syntaxhighlight>
<br>
<br>


In principle, the only changes to be made are the following :
In principle, the only changes to be made are the following :
<pre>
<syntaxhighlight lang="sh" line>
user = dbsqware
user = dbsqware
group = dba
group = dba
Line 161: Line 161:
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
</pre>
</syntaxhighlight>
<br>
<br>


==Changes for /usr/lib/systemd/system/php-fpm.service==
==Changes for /usr/lib/systemd/system/php-fpm.service==
Change the file /usr/lib/systemd/system/php-fpm.service
Change the file /usr/lib/systemd/system/php-fpm.service
<pre>
<syntaxhighlight lang="sh" line>
[root@vmsqwarebox ~]# cp -p /usr/lib/systemd/system/php-fpm.service /usr/lib/systemd/system/php-fpm.service.org
[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
[root@vmsqwarebox ~]# vi /usr/lib/systemd/system/php-fpm.service
</pre>
</syntaxhighlight>
<br>
<br>


In principle, the only changes to be made are the following :
In principle, the only changes to be made are the following :
<pre>
<syntaxhighlight lang="sh" line>
[Service]
[Service]
User=dbsqware
User=dbsqware
Group=dba
Group=dba
</pre>
</syntaxhighlight>
<br>
<br>


==Reload==
==Reload==


<pre>
<syntaxhighlight lang="sh" line>
systemctl daemon-reload
systemctl daemon-reload


Line 195: Line 195:
systemctl start php-fpm
systemctl start php-fpm
systemctl start httpd
systemctl start httpd
</pre>
</syntaxhighlight>
<br>
<br>

Revision as of 09:58, 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 :

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


Start and enable Apache :

systemctl start httpd
systemctl enable httpd
systemctl status httpd

## If firewall is active :
# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload


Test to see if your site is responding :

http://192.168.231.28/


Repo activation and installing 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 to see if your site is responding and is setup with 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


Changes php.ini + php.conf

Change the file /etc/php.ini

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


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

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


Change the file /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


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

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


Changes httpd.conf

Change the file /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


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

User dbsqware
Group dba


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

Change the file /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


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

user = dbsqware
group = dba
;listen.acl_users = apache,nginx
;listen.acl_groups =
listen.owner = dbsqware
listen.group = dba
listen.mode = 0660
listen.allowed_clients =
php_value[session.save_path]    = /var/tmp
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

[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


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

[Service]
User=dbsqware
Group=dba


Reload

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