How to install php in windows environment: first download PHP and decompress the downloaded PHP compressed package to the specified installation directory; then open "php.ini" and modify the configuration information; then modify the Apache configuration file ;Finally load the PHP module and restart the Apache service.
PHP environment construction under Windows system
1. The premise for PHP environment construction is 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 it is used 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:
Description: a. The comment in the ini file is a semicolon (English semicolon), so if you uncomment, delete the semicolon;
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.
Before modification:
# DirectoryIndex: sets the file that Apache will serve if a directory # is requested. #<IfModule dir_module>DirectoryIndex index.html</IfModule>
# DirectoryIndex: sets the file that Apache will serve if a directory # is requested. #<IfModule dir_module>DirectoryIndex index.html index.php index.htm</IfModule>
LoadModule rewrite_module modules/mod_rewrite.so
#php5.6LoadModule php5_module D:/soft/php-5.6.33/php5apache2_4.dll <IfModule php5_module> PHPIniDir "D:/soft/php-5.6.33/" AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps</IfModule>
#php7 LoadModule php7_module D:/soft/php-7.x.x/php7apache2_4.dll<IfModule php7_module> PHPIniDir "D:/soft/php-7.x.x/" AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps</IfModule>
<?php echo phpinfo();?>
localhost:8081/index.php or 127.0.0.1:8081/index.php to open the PHP page .
Finally, the PHP environment can be built with the help of the PHP development environment building tool. Download address: http://www.php.cn/xiazai/gongju or http://www.wampserver.com/ , I will not introduce the tool installation method here. For more related knowledge, please visitPHP Chinese website!
The above is the detailed content of Detailed explanation of how to install php windows environment. For more information, please follow other related articles on the PHP Chinese website!