wk2 php Flashcards

1
Q

What is SAPI

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a PHP Handler?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe the DSO php handler

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe the CGI php handler

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe the suPHP php handler

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe the FastCGI php handler

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe the FPM php handler

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe the LSAPI php handler

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

php-sapi.ini vs php.ini

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In the context of PHP-FPM (php fastcgi process manager), what is a pool?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When are user pools created?

A

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:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Tell me about about the following configuration files:

/var/cpanel/ApachePHPFPM/system.yaml

/var/cpanel/ApachePHPFPM/system_pool_defaults.yaml

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Where does the system store config files that control PHP-FPM?

A

/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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Within which WHM interface would you enable the monitoring of PHP-FPM applications?

A

WHM Home&raquo_space; Service Configuration&raquo_space; Service Manager

How well did you know this?
1
Not at all
2
3
4
5
Perfectly