PHP: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 5: Line 5:
</syntaxhighlight>
</syntaxhighlight>
=<tt>php.ini</tt>=
=<tt>php.ini</tt>=
php.ini is the PHP configuration file. After changing it, use:
<syntaxhighlight lang='shell'>
apachectl graceful
</syntaxhighlight>
to reload the configuration file without killing the server.
To find the location for the command line interpreter, run:
<syntaxhighlight lang='bash'>
php --ini
</syntaxhighlight>
To find the location for the web module, create a "phpinfo.php" file in http root, with the following content:
<syntaxhighlight lang='php'>
<?php
phpinfo();
</syntaxhighlight>
and load it through the web server.


=Locate the <tt>php.ini</tt> File=
=Locate the <tt>php.ini</tt> File=

Revision as of 18:27, 29 December 2023

Overview

Get Version

php -v

php.ini

php.ini is the PHP configuration file. After changing it, use:

apachectl graceful

to reload the configuration file without killing the server.

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 http root, with the following content:

<?php
phpinfo();

and load it through the web server.

Locate the php.ini File

php -i | grep "Configuration File"

...
Configuration File (php.ini) Path => /etc
...

Installation

Linux

Generic

yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql php-xml php-mbstring

Note

The PHP installation command assumes we are going to use MySQL (or MariaDB). Update accordingly if using a different database.

Installing PHP 7.3 on Centos 7

https://linuxize.com/post/install-php-7-on-centos-7/#installing-php-73-on-centos-7

If yum-config-manager is not installed, install it as shown here:

Yum | yum-config-manager
yum install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php73
sudo yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql php-xml php-mbstring

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/.

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