PHP Configuration and ini File Locations ======================================== On an InterWorx server, there are several different PHP versions and options available, each with their own configuration or ini file. These include: - The System PHP version - PHP versions installed via the :doc:`Multiple PHP tool ` - The Internal InterWorx PHP version. This documentation refers only to the System PHP version, and the versions provided by the Multiple PHP tool. Information on managing the Internal InterWorx PHP configuration files can be found :doc:`here `. .. contents:: PHP Configuration Files ----------------------- Overview ^^^^^^^^ There are two possible PHP Modes for the System PHP version: - mod_suPHP - Apache module that runs PHP scripts as the script owner, using the script owner's permissions - If a user's script is compromised, it will not affect other users - Can prevent users from running unauthorized PHP scripts, as they will not have the proper permissions to do so - PHP-FPM - Process manager that uns PHP scripts as a separate process outside of the web server, and communicates with the web server using FastCGI - Better able to handle large numbers of concurrent requests - Generally better performance and scalability vs suPHP - Better resource management than suPHP PHP-FPM is the default System PHP Mode on an InterWorx server. It is also the mode that is automatically used for all PHP versions provide by the Multiple PHP tool. Configuration File Locations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Each mode has its own configuration file: - **mod_suPHP**: ``/etc/httpd/conf.d/suphp.conf`` - **PHP-FPM**: ``/etc/httpd/conf.d/php-fpm.conf`` The contents of the configuration file for the PHP Mode that is not currently in use has each line commented out with ``#IWORX-DISABLED#``. This is expected behavior. How To Identify and Manage the PHP Mode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #. Log into NodeWorx from the browser (https://ip.ad.dr.ess:2443/nodeworx) #. In NodeWorx, navigate to **System Services > Web Server > Overview** #. Under PHP Integration Mode, the information in the **PHP Mode** dropdown is the current mode being used on the server for the System PHP instance .. image:: /images/nw-php-mode-and-version.png :alt: PHP Mode #. To change the mode, if desired, select a different **PHP Mode** from that dropdown #. Click **Update** PHP.ini Files ------------- Overview ^^^^^^^^ As it is possible for there to be more than one PHP version installed on a server, it is not uncommon for there to be more than one ``php.ini`` file--a file for the System PHP version, as well as a file for each PHP version installed via the Multiple PHP tool. How To Identify the System PHP Version ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In NodeWorx ''''''''''' #. Log into NodeWorx from the browser (https://ip.ad.dr.ess:2443/nodeworx) #. In NodeWorx, navigate to **System Services > Web Server > Overview** #. Under PHP Integration Mode, the System PHP field lists the current System PHP version .. image:: /images/nw-php-mode-and-version.png :alt: system PHP version At the CLI '''''''''' #. Log in to the server at the CLI as root, either via SSH or from the terminal #. At the CLI, use the following to check the System PHP version: .. code-block:: php -v In this example, the System version is currently PHP 8.2: .. code-block:: [root@server ~]# php -v PHP 8.2.5 (cli) (built: Apr 11 2023 16:16:23) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.2.5, Copyright (c) Zend Technologies [root@server ~]# How to Identify Which Multiple PHP Versions Are Installed ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In NodeWorx ''''''''''' #. Log into NodeWorx from the browser (https://ip.ad.dr.ess:2443/nodeworx) #. In NodeWorx, navigate to **System Services > Web Server > Overview** #. Under Multiple PHP Versions, the **checked versions** are the ones that are currently installed on the server. The following example has PHP 5.6, 7.1, 7.4, 8.0, and 8.2 installed: .. image:: /images/nw-multiple-installed-php-versions.png :alt: installed multiple PHP versions At the CLI '''''''''' #. Log in to the server at the CLI as root, either via SSH or from the terminal #. Run thie following command. This will list all of the PHP versions currently installed on the server, both as the System PHP and installed via the Multiple PHP tool: .. code-block:: ~iworx/bin/php-fpm.pex --list-installed-versions Example output--this server has PHP 5.6, 7.1, 7.4, 8.0, and 8.2 installed via the Multiple PHP tool, as well as 8.2 as the System PHP version: .. code-block:: [root@server ~]# ~iworx/bin/php-fpm.pex --list-installed-versions System PHP (php-fpm) 8.2.5 php-cli php-fpm 8.2.5 remi-php82 installed PHP-FPM 5.6.40 php56-php-cli php56-php-fpm 5.6.40 remi-safe installed PHP-FPM 7.1.33 php71-php-cli php71-php-fpm 7.1.33 remi-safe installed PHP-FPM 7.4.33 php74-php-cli php74-php-fpm 7.4.33 remi-safe installed PHP-FPM 8.0.28 php80-php-cli php80-php-fpm 8.0.28 remi-safe installed PHP-FPM 8.2.5 php82-php-cli php82-php-fpm 8.2.5 remi-safe installed [root@server ~]# PHP.ini File Locations ^^^^^^^^^^^^^^^^^^^^^^ - **System PHP Version**: ``/etc/php.ini`` - **Multiple PHP Versions**: - **PHP 5.x Versions**: ``/opt/remi/php{version}/root/etc/php.ini``, replacing ``{version}`` with the PHP version. For example, the php.ini file for version 5.6 is located at ``/opt/remi/php56/root/etc/php.ini`` - **PHP 7.x Versions**: ``/etc/opt/remi/php{version}/php.ini``, replacing ``{version}`` with the PHP version. For example, the php.ini file for version 7.4 is located at ``/etc/opt/remi/php74/php.ini`` - **PHP 8.x Versions**: ``/etc/opt/remi/php{version}/php.ini``, replacing ``{version}`` with the PHP version. For example, the php.ini file for version 8.1 is located at ``/etc/opt/remi/php81/php.ini`` How To Easily Locate All PHP.ini Files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #. Log in to the server at the CLI as root, either via SSH or from the terminal #. At the CLI, make sure that the package `mlocate `__ is installed: .. code-block:: rpm -q mlocate If it is installed, the output will be similar to the following: .. code-block:: [root@server ~]# rpm -q mlocate mlocate-0.26-8.el7.x86_64 [root@server ~]# If it is not installed, install it using yum and follow the prompts: .. code-block:: yum install mlocate #. Run the following command to make sure mlocate's database is up to date, so that all files on the server and be found. Depending on the number of files on the server, this may take a few minutes. It is not expected for there to be any output when the task is finished: .. code-block:: updatedb #. Once ``updatedb`` as completed, run the following--this will search for all files named ``php.ini`` on the server. It will also exclude any files with "-"" in the file path, so it will not list any irrelevant files. It will also exclude any results with ``interworx`` or ``iworx`` in the file name or file path, so that only the php.ini files related to the system-level and multiple PHP versions are listed, not the internal InterWorx PHP version: .. code-block:: locate php.ini | grep -v "-" | grep -v interworx | grep -v iworx Example output--this server has PHP 5.6, 7.1, 7.4, 8.0, and 8.2 installed via the multiple PHP tool, as well as the server PHP version: .. code-block:: [root@server ~]# locate php.ini | grep -v "-" | grep -v interworx | grep -v iworx /etc/php.ini /etc/opt/remi/php71/php.ini /etc/opt/remi/php74/php.ini /etc/opt/remi/php80/php.ini /etc/opt/remi/php82/php.ini /opt/remi/php56/root/etc/php.ini [root@server ~]# PHP Module ini File Locations ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Like the php.ini files, each PHP version has its own directory for the ini files for the PHP modules installed for that version. The ini files for installed PHP modules can be found in the following directories: - **System PHP Version**: ``/etc/php.d/`` - **Multiple PHP Versions**: - **PHP 5.x Versions**: ``/opt/remi/php{version}/root/etc/php.d/``, replacing ``{version}`` with the PHP version. For example, the module ini files for version 5.6 are located in the ``/opt/remi/php56/root/etc/php.d/`` directory - **PHP 7.x Versions**: ``/etc/opt/remi/php{version}/php.d/``, replacing ``{version}`` with the PHP version. For example, the module ini files for version 7.4 are located in the ``/etc/opt/remi/php74/php.d/`` directory - **PHP 8.x Versions**: ``/etc/opt/remi/php{version}/php.d/``, replacing ``{version}`` with the PHP version. For example, the module ini files for version 8.1 are located in the ``/etc/opt/remi/php81/php.d/`` directory