PHP environment building windows

Posted by getmukesh on Fri, 14 Feb 2020 08:54:55 +0100

To prepare the Apache and php packages:

Link: https://pan.baidu.com/s/1xclkowi-a3r8oeyften3a
Extraction code: whjj

Install Apache

1. Modify the httpd.conf configuration in the Apache24\conf \ directory, and open the httpd.conf file in Notepad
2. Find the item "Define SRVROOT" and change the value in quotation marks to Apache installation directory
3. Modify the default index to support PHP:

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

4. Enable rewrite function: remove the "ා" in front of the following line of code

LoadModule rewrite_module modules/mod_rewrite.so

5. Add PHP support and PHP installation path at the end of the file

# php7 support
LoadModule php7_module "D:/php-7.4.2/php7apache2_4.dll"
AddType application/x-httpd-php .php .html .htm

# configure the path to php.ini
<IfModule php5_module> 
    PHPIniDir "D:/php-7.4.2" 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
</IfModule>

Install PHP

1. Open the PHP installation directory, copy php.ini-development, and then change php.ini-development to php.ini for saving
2. Open php.ini to modify the configuration, and find the directory where extension dir = ext is changed to extension dir = ext, for example

extension_dir ="D:\php-7.4.2\ext"

2. Modify the extension file to be loaded. The following code is the code after canceling the comment of some extension programs:

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. Set the default time zone:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone select time zone list URL
date.timezone = Asia/Shanghai

Start Apache service

1. Setting environment variables
Right click my computer, properties - > advanced, find the lowest environment variable button, select the PATH variable of the current user, edit and create the following new entry:
D:\Apache24\bin
D:\php-7.4.2
D:\php-7.4.2\ext
2. Install apache services
Open the command line as administrator and execute httpd.exe -k install

The word Apache 2.4 service is successfully installed appears to indicate that the service was started successfully.
3. Start service
Find the bin folder in the installation directory of apache, double-click ApacheMonitor.exe, and then apache will open.
You can select the following icon in the taskbar, right-click to open the Apache Service Monitor window, and click start.
4. At this time, enter localhost in the browser address bar, and the apache interface will appear after you enter. Description configuration succeeded!
5. Next, create a new phpinfo.php file in the Apache installation directory / htdocs. The content is:

<?php
phpinfo();
?>

After saving, enter 127.0.0.1/phpinfo.php in the browser, enter, and the version information about PHP will appear

6. Now that the php environment is set up, you can put the php file into the htdocs folder to run.

Reproduced at https://blog.csdn.net/galen2016/article/details/80778662 and https://blog.csdn.net/weixin_/article/details/79110311

Published 13 original articles, won praise 4, visited 832
Private letter follow

Topics: PHP Apache Oracle Database