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 7.4. They are not standard in CentOS 7.

# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
# yum -y install yum-utils
# yum-config-manager --enable remi-php74
# yum -y update
# yum install php php-cli php-common
# php -v
(# php -m)
# yum install php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath
# yum install php-json php-soap php-smbclient
# 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" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://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.

SElinux

SELinux is blocking the read/write operations

# chcon -Rv -t httpd_sys_rw_content_t /srv/www/vhosts/www.example.com/ (if you want to allow full web root)

# chcon -Rv -t httpd_sys_rw_content_t /srv/www/vhosts/www.example.com/uploads/ (Or just uploads folder)

Ownership

For cms let apache own the files.

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

Links

PHP-FPM

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

Installing

# yum install php-fpm

Links