This article will introduce to you how to build a PHP environment under Windows system. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
#1. The prerequisite for building a PHP environment is that the Apache HTTP Server (Apache server) has been successfully installed and deployed, and the main page of the server can be accessed normally. The installation and deployment of Apache HTTP Server has been explained in detail in the previous article. If you are unclear, you can click "Apache HTTP Servcer-Apache Server Download and Installation under Windows System" to view the specific operations.
2. PHP download:
2.1. Download address: http://php.net/downloads.php
2.1. Version selection: If paired with Apache, It is recommended to choose the Thread Safe version; if it is used with CGI or FAST-CGI, it is recommended to choose the Non Thread Safe version.
3. PHP environment setup:
3.1. Extract the downloaded .zip compressed package to the specified installation directory. The installation path here is: D:\solt\php_5.6.33.
3.2. Copy php.ini-development or php.ini-production in the root directory of PHP and rename it to php.ini as the PHP configuration file;
3.3. Open php.ini and modify the configuration information:
Note: a. The comment in the ini file is a semicolon (English semicolon), so if you uncomment, delete the semicolon;
b, ${ phphome} is the root directory of PHP, that is: D:\solt\php_5.6.33, and the absolute path is written in the configuration file.
3.3.1. Modify the path of the extension file:
; extension_dir = "ext"
Uncomment, or change it to:
extension_dir = "${phphome}\ext";
Note: If it is used with Apache, it is recommended to change the path of the extension file Change it to an absolute path because it may not be loaded.
3.3.2. Modify the extension file that needs to be loaded. The following code is the code after uncommenting some extensions:
extension=php_bz2.dll extension=php_curl.dll extension=php_fileinfo.dll extension=php_gd2.dll extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll extension=php_mbstring.dll extension=php_exif.dll ; Must be after mbstring as it depends on it extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client extension=php_openssl.dll ;extension=php_pdo_firebird.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll extension=php_pdo_odbc.dll extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll extension=php_pgsql.dll ;extension=php_shmop.dll ; The MIBS data available in the PHP distribution must be installed. ; See http://www.php.net/manual/en/snmp.installation.php ;extension=php_snmp.dll extension=php_soap.dll extension=php_sockets.dll extension=php_sqlite3.dll ;extension=php_sybase_ct.dll extension=php_tidy.dll extension=php_xmlrpc.dll extension=php_xsl.dll
3.3.3. Set the default time zone:
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone 选择时区列表网址 date.timezone = Asia/Shanghai
3.3.4. Set up ssl:
[openssl] ; The location of a Certificate Authority (CA) file on the local filesystem ; to use when verifying the identity of SSL/TLS peers. Most users should ; not specify a value for this directive as PHP will attempt to use the ; OS-managed cert stores in its absence. If specified, this value may still ; be overridden on a per-stream basis via the "cafile" SSL stream context ; option. openssl.cafile= cacert.pem
You can add extensions according to your needs.
3.4. Modify httpd.conf in the Apache24\conf\ directory to configure Apache so that Apache and PHP can work together;
3.4.1. DocumentRoot settings:
Before modification : The default is the htdocs directory under Apache24:
After modification: Specify a custom path, but remember this path.
##3.4.2. Modify the default index to support PHP: Before modification:# DirectoryIndex: sets the file that Apache will serve if a directory # is requested. #DirectoryIndex index.html
# DirectoryIndex: sets the file that Apache will serve if a directory # is requested. #DirectoryIndex index.html index.php index.htm
LoadModule rewrite_module modules/mod_rewrite.so
#php5.6 LoadModule php5_module D:/soft/php-5.6.33/php5apache2_4.dllPHPIniDir "D:/soft/php-5.6.33/" AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
#php7 LoadModule php7_module D:/soft/php-7.x.x/php7apache2_4.dllPHPIniDir "D:/soft/php-7.x.x/" AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
The above is the detailed content of How to build a PHP environment under Windows system. For more information, please follow other related articles on the PHP Chinese website!