Rob's web

PHP

PHP is a general-purpose scripting language especially suited to web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994. The PHP reference implementation is now produced by The PHP Group. PHP originally stood for Personal Home Page, but it now stands for the recursive initialism PHP: Hypertext Preprocessor.

PHP code is usually processed on a web server by a PHP interpreter implemented as a module, a daemon or as a Common Gateway Interface (CGI) executable. On a web server, the result of the interpreted and executed PHP code - which may be any type of data, such as generated HTML or binary image data - would form the whole or part of an HTTP response. Various web template systems, web content management systems, and web frameworks exist which can be employed to orchestrate or facilitate the generation of that response. Additionally, PHP can be used for many programming tasks outside of the web context, such as standalone graphical applications and robotic drone control. Arbitrary PHP code can also be interpreted and executed via command-line interface (CLI).

Installing

We install the PHP 8.2.

# dnf module reset php
# dnf module install php:remi-8.2
# php -v
# dnf install php php-cli php-common php-gd
# dnf install php-mysqlnd php-mbstring php-json php-dba php-dbg php-devel php-embedded php-enchant
# dnf install php-bcmath php-gmp php-intl php-ldap php-odbc php-pdo php-opcache php-pear php-mysql
# dnf install php-process php-snmp php-soap php-xml php-opcache php-igbinary php-imagick php-imap
# dnf install php-memcached php-redis
# dnf install ImageMagick composer
# php -m
# systemctl restart httpd

Testing

Create a php page that shows the PHP info.

# cd /srv/www/default/httpdocs
# vi phpinfo.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "https://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<title>Test</title>
</head>

<body>

<?php
phpinfo();
?>

</body>
</html>

After you saved it open in you browser: server1.example.com/phpinfo.php. This shows the configuration.

Configuration

The main configuration is done in php.ini.

SElinux

SELinux is blocking the read/write operations

If you want to allow full web root.

# cd /srv/www/vhosts/www.example.com
# chcon -Rv -t httpd_sys_rw_content_t /httpsdocs/

Or just uploads folder.

# cd /srv/www/vhosts/www.example.com/httpsdocs/
# chcon -Rv -t httpd_sys_rw_content_t uploads/

Ownership

For cms let apache own the files.

# chown apache:apache -R /srv/www/vhosts/www.example.com/

PHP-FPM

FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites.

Installing

# dnf install php-fpm

Starting

# systemctl start php-fpm
# systemctl enable php-fpm

After an php update restart php-fpm and httpd.

# systemctl restart php-fpm httpd

Links