Detailed explanation of how to install php windows environment

藏色散人
Release: 2023-03-02 06:56:01
Original
7510 people have browsed it

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.

Detailed explanation of how to install php windows environment

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"
Copy after login

Uncomment, or change it to:

extension_dir = "${phphome}\ext";
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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.
#<IfModule dir_module>DirectoryIndex index.html</IfModule>
Copy after login
After modification:

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#<IfModule dir_module>DirectoryIndex index.html index.php index.htm</IfModule>
Copy after login
3.4.3. Turn on the rewrite function: remove the # in front of the following line of code:

LoadModule rewrite_module modules/mod_rewrite.so
Copy after login
3.4.4. Load the PHP module, pay attention to the absolute path:

If it is PHP 5. Add the following code at the end of the httpd.conf file:

#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>
Copy after login
If it is PHP 7, make the corresponding changes, the example is as follows:

#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>
Copy after login
3.5. If the PHP x64-bit version is installed, Apache It also needs to be the x64-bit version. Then you need to copy the libssh2.dll in the php directory and the php_curl.dll in the ext directory to the System32 directory (the original article said that you also need to copy the libeay32.dll and ssleay32.dll files in the Apache directory, but I didn’t copy them. but still available). Otherwise the curl extension cannot be used. Reference link: http://my.oschina.net/lsfop/blog/496181. No verification is done, just follow the instructions and display normally.

4. Start Apache PHP and run the test:

4.1. In the D:\soft\php_5.6.33\www directory, create the index.php file with the following text content:

<?php
echo phpinfo();?>
Copy after login
4.2. Restart the Apache service, open the browser address bar and enter:

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 visit

PHP 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template