Php and Apache environment configuration

1. the Apache download and install:

2, PHP download:

2.1 Download: http://php.net/downloads.php
2.1 Selection: If the Apache with the proposed selection Thread Safe version; if it is with CGI or FAST-CGI with the proposed selection Non Thread Safe version.

3, PHP build environment:

  • The downloaded .zip archive decompression to the specified installation directory, where the installation path is: C: \ HttpWeb \ php_7.1.33.
  • The php.ini-development in the root directory or PHP php.ini-production copy and rename php.ini, as PHP configuration file;
  • Open the php.ini, modify the configuration information:
    Description:
    A, ini file annotation is a semicolon (semicolon), so the comment is deleted to cancel the semicolon;
    B, $ {} is phphome PHP root directory, namely: C: \ HttpWeb \ php_7.1.33, configuration files written in absolute path.
3.3.1, modify the path of the file extensions:

Here Insert Picture Description

3.3.2, change the extension of the file to be loaded, the following code is the code after the cancellation of part of the extension of the comment:
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 the 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 your own extensions on demand.

3.4, modify httpd.conf \ \ under Apache24 conf directory to configure Apache, PHP and Apache to work together;
3.4.1, DocumentRoot settings:

Before: The default is the htdocs directory under Apache24:
Here Insert Picture Description
After: Specifies the path to the custom, but remember this path.
Here Insert Picture Description

3.4.2, change the default indexes to support PHP:

before fixing:


# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

Modified:


# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php index.htm
</IfModule>
3.4.3 open rewrite function: on the front of this line of code # removed following:
LoadModule rewrite_module modules/mod_rewrite.so4
3.4.4, loaded PHP modules, pay attention to the absolute path:

If PHP 5, in the httpd.conf file add the following code:


#php5.6
LoadModule php5_module C:/HttpWeb/php-5.6.33/php5apache2_4.dll 
<IfModule php5_module> 
    PHPIniDir "C:/HttpWeb/php-5.6.33/" 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
</IfModule>

If PHP 7, the corresponding change, for example:


#php7
LoadModule php7_module C:/HttpWeb/php_7.1.33/php7apache2_4.dll
<IfModule php7_module> 
PHPIniDir "D:/HttpWeb/php_7.1.33/" 
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
3.5, PHP x64-bit version if installed, Apache also need to be x64-bit version. Php_curl.dll will then have to wait for the next libeay32.dll in the php directory, ssleay32.dll, libssh2.dll and four ext directory files are copied into the System32 directory under. Otherwise curl extension is not available.

4, Apache + PHP start running tests:

4.1, in C: \ HttpWeb \ php_7.1.33 \ at www directory, create a index.php file, the text reads as follows:
<?php
echo phpinfo();
?>
4.2, restart the Apache service, open the browser address bar enter: localhost: 8088 / index.php or 127.0.0.1:8088/index.php, you can open the PHP page.

Finally, a little explanation, PHP environment can build tools to build, by means of PHP development environment Download: http://www.php.cn/xiazai/gongju or http://www.wampserver.com/ , not here presentation tools installation method has.

Published 62 original articles · won praise 5 · Views 3929

Guess you like

Origin blog.csdn.net/qq_42194657/article/details/102963940