Difference between revisions of "Appendices:ApachePHP"
m (→Installing packages) |
Dtavernier (talk | contribs) |
||
Line 8: | Line 8: | ||
Installing Apache Web Server with dnf : | Installing Apache Web Server with dnf : | ||
− | < | + | <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 | ||
− | </ | + | </syntaxhighlight> |
<br> | <br> | ||
Start and enable Apache : | Start and enable Apache : | ||
− | < | + | <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 | ||
− | </ | + | </syntaxhighlight> |
<br> | <br> | ||
Test to see if your site is responding : | Test to see if your site is responding : | ||
− | < | + | <syntaxhighlight lang="sh" line> |
http://192.168.231.28/ | http://192.168.231.28/ | ||
− | </ | + | </syntaxhighlight> |
<br> | <br> | ||
Repo activation and installing PHP 8.2.18 : | Repo activation and installing PHP 8.2.18 : | ||
− | < | + | <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 | ||
− | </ | + | </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 : | ||
− | < | + | <syntaxhighlight lang="sh" line> |
systemctl restart httpd | systemctl restart httpd | ||
Line 91: | Line 91: | ||
=> PHP Version 8.2.18 | => PHP Version 8.2.18 | ||
− | </ | + | </syntaxhighlight> |
<br> | <br> | ||
Line 97: | Line 97: | ||
Change the file /etc/php.ini | Change the file /etc/php.ini | ||
− | < | + | <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 | ||
− | </ | + | </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 : | ||
− | < | + | <syntaxhighlight lang="sh" line> |
;session.save_path = "/tmp" | ;session.save_path = "/tmp" | ||
memory_limit = 512M | memory_limit = 512M | ||
− | </ | + | </syntaxhighlight> |
<br> | <br> | ||
Change the file /etc/httpd/conf.d/php.conf | Change the file /etc/httpd/conf.d/php.conf | ||
− | < | + | <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 | ||
− | </ | + | </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 : | ||
− | < | + | <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" | ||
− | </ | + | </syntaxhighlight> |
<br> | <br> | ||
Line 127: | Line 127: | ||
Change the file /etc/httpd/conf/httpd.conf | Change the file /etc/httpd/conf/httpd.conf | ||
− | < | + | <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 | ||
− | </ | + | </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 : | ||
− | < | + | <syntaxhighlight lang="sh" line> |
User dbsqware | User dbsqware | ||
Group dba | Group dba | ||
− | </ | + | </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 | ||
− | < | + | <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> |
<br> | <br> | ||
In principle, the only changes to be made are the following : | In principle, the only changes to be made are the following : | ||
− | < | + | <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 | ||
− | </ | + | </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 | ||
− | < | + | <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 | ||
− | </ | + | </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 : | ||
− | < | + | <syntaxhighlight lang="sh" line> |
[Service] | [Service] | ||
User=dbsqware | User=dbsqware | ||
Group=dba | Group=dba | ||
− | </ | + | </syntaxhighlight> |
<br> | <br> | ||
==Reload== | ==Reload== | ||
− | < | + | <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 | ||
− | </ | + | </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.
Contents
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