PHP: Difference between revisions
(10 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=<tt>php.ini</tt>= | =<tt>php.ini</tt>= | ||
<code>php.ini</code> is the PHP configuration file. If PHP is used to render content for a httpd server, restart the server to reload the configuration without killing the server with: | |||
php.ini is the PHP configuration file. | |||
<syntaxhighlight lang='shell'> | <syntaxhighlight lang='shell'> | ||
apachectl graceful | apachectl graceful | ||
</syntaxhighlight> | </syntaxhighlight> | ||
To find the location for the command line interpreter, run: | To find the location for the command line interpreter, run: | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
php --ini | php --ini | ||
</syntaxhighlight> | </syntaxhighlight> | ||
To find the location for the web module, create a | To find the location for the web module, create a <code>phpinfo.php</code> file in the httpd server root, with the following content: | ||
<syntaxhighlight lang='php'> | <syntaxhighlight lang='php'> | ||
<?php | <?php | ||
phpinfo(); | phpinfo(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
and load it through the web server. | and load it through the web server. Usually, the location of the module is also configured in the httpd server configuration file <code>[[Httpd_Configuration|httpd.conf]]</code> as: | ||
<syntaxhighlight lang='xml'> | |||
= | LoadModule php_module /opt/brew/opt/php@8.1/lib/httpd/modules/libphp.so | ||
</syntaxhighlight> | |||
==Locate the <tt>php.ini</tt> File== | |||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
php -i | grep "Configuration File" | php -i | grep "Configuration File" | ||
... | ... | ||
Configuration File (php.ini) Path => /etc | Configuration File (php.ini) Path => /etc | ||
Line 35: | Line 32: | ||
=Installation= | =Installation= | ||
==Linux== | ==<span id='Linux'></span>Centos 7== | ||
=== | ===PHP 8.3=== | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
yum install php php-common php-opcache php-mcrypt | yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm | ||
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm | |||
yum install -y --enablerepo=remi-php83 php php-cli php-common php-opcache php-mcrypt php-gd php-curl php-mysqlnd php-xml php-mbstring php-intl | |||
</syntaxhighlight> | </syntaxhighlight> | ||
===Old PHP Versions=== | |||
{{Internal|PHP Installation Old Versions|Old PHP Versions}} | |||
=== | |||
==Mac== | ==Mac== | ||
Line 67: | Line 55: | ||
The <code>php.ini</code> and <code>php-fpm.ini</code> files can be found in <code>/opt/brew/etc/php/8.3/</code>. | The <code>php.ini</code> and <code>php-fpm.ini</code> files can be found in <code>/opt/brew/etc/php/8.3/</code>. | ||
If PHP will be used with <code>httpd</code>, <code>httpd.conf</code> must be configured to load the PHP module. Instructions are available here: {{Internal|Httpd_on_Mac#Configure_PHP|Configure PHP for <tt>httpd</tt> on Mac}} | |||
=Upgrade= | =Upgrade= |
Latest revision as of 22:45, 31 December 2023
Overview
Get Version
php -v
php.ini
php.ini
is the PHP configuration file. If PHP is used to render content for a httpd server, restart the server to reload the configuration without killing the server with:
apachectl graceful
To find the location for the command line interpreter, run:
php --ini
To find the location for the web module, create a phpinfo.php
file in the httpd server root, with the following content:
<?php
phpinfo();
and load it through the web server. Usually, the location of the module is also configured in the httpd server configuration file httpd.conf
as:
LoadModule php_module /opt/brew/opt/php@8.1/lib/httpd/modules/libphp.so
Locate the php.ini File
php -i | grep "Configuration File"
...
Configuration File (php.ini) Path => /etc
...
Installation
Centos 7
PHP 8.3
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install -y --enablerepo=remi-php83 php php-cli php-common php-opcache php-mcrypt php-gd php-curl php-mysqlnd php-xml php-mbstring php-intl
Old PHP Versions
Mac
Latest:
brew install php
To install a specific version:
brew install php@7.4
The php.ini
and php-fpm.ini
files can be found in /opt/brew/etc/php/8.3/
.
If PHP will be used with httpd
, httpd.conf
must be configured to load the PHP module. Instructions are available here:
Upgrade
Configuration
Error Reporting
Some PHP installations come with error reporting set to dump all errors, including some not appropriate for production, like deprecation messages.
To set error reporting to a production settings, configure the following in the php.ini
file:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT