WhyInstalling the PHP module for Apache, including support for IPv6. Additional extensions will be installed and configured.
- Requirement: Apache
- Reference: PHP documentation
Build information
Ensure the following options:
[x] CLI Build CLI version [x] CGI Build CGI version [x] FPM Build FPM version [x] EMBED Build embedded library [x] DTRACE Build with DTrace probes [x] IPV6 IPv6 protocol support [x] MYSQLND Build with MySQL Native Driver [x] LINKTHR Link thread lib (for threaded extensions) [x] ZTS Force Zend Thread Safety (ZTS) build
[x] BCMATH bc style precision math functions [x] BZ2 bzip2 library support [x] CTYPE ctype functions [x] CURL CURL support [x] DOM DOM support [x] EXIF EXIF support [x] FILEINFO fileinfo support [x] FILTER input filter support [x] FTP FTP support [x] GD GD library support [x] GETTEXT gettext library support [x] GMP GNU MP support [x] ICONV iconv support [x] INTL Internationalization(ICU) [x] JSON JavaScript Object Serialization support [x] LDAP OpenLDAP support [x] MBSTRING multibyte string support [x] MYSQLI MySQLi database support [x] OPCACHE OPcache support [x] OPENSSL OpenSSL support [x] PDO PHP Data Objects Interface (PDO) [x] PDO_MYSQL PDO MySQL driver [x] PDO_SQLITE PDO sqlite driver [x] PHAR phar support [x] POSIX POSIX-like functions [x] SESSION session support [x] SIMPLEXML simplexml support [x] SODIUM Sodium encryption support [x] SQLITE3 sqlite3 support [x] TOKENIZER tokenizer support [x] XML XML support [x] XMLREADER XMLReader support [x] XMLWRITER XMLWriter support [x] XSL XSL support (Implies DOM) [x] ZLIB ZLIB support
Configuration
The main configuration file is /usr/local/etc/php.ini, it is also
possible to define most of the values in the Apache configuration
using directives: php_flag, php_value,
php_admin_flag and php_admin_value.
php.ini
- Interpreter
-
PHP will not use the short form (ie:
<?) as it conflicts with processing instructions for XML documents.short_open_tag = Off
- Error handling
-
For a production system, errors and warnings will not be saved as they can be particularly numerous even if the code is functional.
display_errors = Off
- Memory
-
Limit memory usage to 20MB per web request.
memory_limit = 20M
- Files
-
Sending files is allowed, but limited to 2MB per file, the value of
post_max_sizeis also involved in sending file because the transfer is done by thePOST.file_uploads = On upload_max_filesize = 2M
- Timezone
-
For the correct operation of a number of applications, it is advisable to set the time zone. By default we choose
UTCas it is the international basis of civil time adopted by most countries worldwide.date.timezone = UTC
Apache
The main Apache configuration is located in the
/usr/local/etc/apache24/ directory, for PHP it is essentially made of
the module loading and the association of the PHP engine with *.php
and *.phps files.
LoadModule php7_module libexec/apache24/libphp7.so
<IfModule php7_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
It can be decided to not create the Includes/php.conf file.
In that case, it will only be required to add the corresponding line
in the website configuration, if it need to run PHP.
The line to be added being:
AddType application/x-httpd-php .php
Apache
In case of PHP use, we wish to have the index file for directories to be processed by PHP. To achieve this we must specify the processing order of index files.
DirectoryIndex index.php index.html
Thereafter special directives in PHP can be used to change the values
of various configuration elements, some will allow overloading using
the .htaccess file, others do not. They are listed below:
| Overloadable | Not overloadable | |
|---|---|---|
| Value | php_value |
php_admin_value |
| Flag | php_flag |
php_admin_flag |
A configuration example, among others, is:
php_value error_log /web/www.example.com/log/php.log php_value default_mimetype 'text/html; charset=utf-8' php_value memory_limit 36M php_value session.save_path /web/www.example.com/session/ php_value open_basedir /web/www.example.com/content/ php_admin_flag display_errors off php_admin_flag file_uploads off