wk2 php Flashcards
What is SAPI
SAPI or Server Application Programming Interface is the mechanism that controls the interaction between the “outside world” and the PHP engine. So a server administrator would always want to use it. In fact, you cannot avoid using it without a lot of effort since even the command line interface is considered a SAPI.
What is a PHP Handler?
PHP Handlers are types of Apache modules, containing libraries that the Apache webserver uses to interpret and run PHP code.
So now that we know what a SAPI is, what does that have to do with PHP Handlers? Well, a handler is just another name for a SAPI. Common handlers include DSO (Dynamic Shared Object), FCGI (Fast Common Gateway Interface) and suPHP.
Describe the DSO php handler
Short for Dynamic Shared Object, also known as mod_php, this is the oldest, and some might say the fastest PHP handler. It essentially makes PHP a part of Apache by having the Apache server interpret the PHP code itself through the use of the mod_php module. This means that PHP scripts are executed by the same user that is running Apache, which in cPanel environments, will be the nobody user.
Describe the CGI php handler
When using cgi as your PHP handler, instead of running the PHP code within Apache, it is now run as its own CGI process, in a program handled separately from Apache. By default, CGI will be called by the Apache server meaning that it will run as the Apache user with all the problems of doing so that mod_php encountered. Unlike mod_php however, CGI has the ability to see the PHP as another user (presumably the user that owns the files) using another Apache module known as suexec.
Describe the suPHP php handler
suPHP runs PHP outside of the Apache script as CGI. Unlike CGI however, it will run the scripts as a user other than the Apache user (presumably the user that owns the files). This means that if you are using a CMS, you will be able to upload files from within your web application using suPHP.
Describe the FastCGI php handler
FCGI is the last major PHP handler. It offers the security benefits of suPHP by executing files as the owner of the file. Unlike suPHP, it keeps an open session for the file when the processing is done, resulting in significant memory use, but also allows for the user of OPcode caching such as APCH or memcached.
Describe the FPM php handler
PHP FastCGI Process Manager (PHP-FPM) - FastCGI serves PHP applications through the mod_proxy_fcgi Apache module. This method is fast but may require changes to the FastCGI directives to work efficiently. We will go over this one more in-depth later.
Describe the LSAPI php handler
LSAPI (LiteSpeed SAPI ) provides a fast and stable way to serve PHP applications. cPanel & WHM’s version of LSAPI differs from the one that CloudLinux provides. This version disables Checkpoint/Restore in Userspace (CRIU), connection pooling, and opcache preservation. To utilize this handler’s full functionality, your system must run CloudLinux and for this reason, we won’t discuss it any further here, but you can read CloudLinux’s Documentation if you want to know more.
php-sapi.ini vs php.ini
If a php-sapi.ini file exists, where sapi represents the SAPI in use, the system reads that file instead of the php.ini file.
In the context of PHP-FPM (php fastcgi process manager), what is a pool?
A pool is a group of workers that can respond to php requests. HP-FPM maintains pools (workers that can respond to PHP requests) to accomplish this.
When are user pools created?
In a cPanel & WHM environment The system creates a user pool when the /var/cpanel/userdata/[user]/[domain].php_fpm.yaml configuration file exists in the domain. This file must include the following lines:
Tell me about about the following configuration files:
/var/cpanel/ApachePHPFPM/system.yaml
/var/cpanel/ApachePHPFPM/system_pool_defaults.yaml
The system-pool-defaults.yaml file applies the value to each pool that you create.
Each domain in the system requires that you create one pool.
The system does not require these files to run because the built-in defaults enable the PHP-FPM to run sufficiently.
Only include the differences in directives within these files.
An example of system.yaml’s contents:
daemonize: yes
Where does the system store config files that control PHP-FPM?
/opt/cpanel/ea-phpXX/root/etc/php-fpm.conf - This file contains the system configurations of PHP-FPM.
/opt/cpanel/ea-phpXX/root/etc/php-fpm.d/[domain].conf - This file changes your domain to the domain setting of the website that you use. For example, the cptest1.tld.conf domain.
XX = php version, ea-php73 is php 7.3
Within which WHM interface would you enable the monitoring of PHP-FPM applications?
WHM Home»_space; Service Configuration»_space; Service Manager