1. Environmental Description
- Apache: 2.4.51
- php: 5.6.9
- OS: Windows server (2012, 2019) - tested
2. Download the installation package
- Apache:Apache Haus Downloads
- Select the corresponding version
- PHP:windows.php.net - /downloads/releases/archives/
- Select the corresponding version
- PHP-Oci extension: http://pecl.php.net/package/oci8
- Select the corresponding version (you can select the corresponding version according to the description)
- There is no corresponding version and the OCI8 extension cannot be displayed
- Oracle instantclient:
- It is recommended to select the corresponding database version to install (you can also not use the corresponding version, but it needs to correspond to the OCI8.dll version)
Note: All files can be placed in one folder, as long as the path in the configuration file is correct.
3. Apache configuration
- Path Apache decompression directory → conf → httpd.conf file
- Modify Define SRVROOT "/Apache24" - define "SRVROOT"
- "/Apache24" corresponds to the installation directory
- Modify Define SRVROOT "/Apache24" - define "SRVROOT"
-
- Modify the listening port "Listen 80"
- You can first check whether it is occupied (if it is not occupied, you do not need to modify it)
- Modify the listening port "Listen 80"
netstat -ano |findstr 80 #Windows
-
- Add PHP configuration
LoadModule php7_module php7apache2_4.dll的路径 #此行需要根据Apache、PHP版本进一步调整
PHPIniDir php的路径
AddType application/x-httpd-php .php .html .htm
-
- Add PHP configuration (2)
< IfModule dir_module>
DirectoryIndex index.htm #添加index.php
< /IfModul e>
Note: The Apache configuration has been roughly completed here, you can configure the system self-test at this time, or you can check it together after the PHP configuration is completed.
cd C:/Apache/bin #切换至Apache/bin目录下
httpd.exe -t #若无报错继续进行,有报错则按照报错继续修改
httpd.exe -k install -n Apache #无报错可以继续进行安装 “-k”执行指令、“-n”配置服务名称
Four, PHP configuration
- Copy php.ini-development in the php directory and modify it to: php.ini
- Note: The copied php.ini extensions are all modified, and the extensions need to be opened accordingly
- Modify the php.ini file
- "extension_dir" closes the comment, and the path is changed to the "ext" directory in the PHP directory
extension_dir = "C:/php-5.6.9/ext"
-
- Search for "oci8" - here is the extended part of the comment, you can open the comment if necessary
- Ordinary installation only needs to open php_oci8_12c.dll (need to correspond to the file in the ext directory, pay attention to the version)
- Search for "oci8" - here is the extended part of the comment, you can open the comment if necessary
-
- "short_open_tag = On" - modify this behavior "on", otherwise it will show blank when opening phpinfo
- Configure php environment variables
- My Computer-Properties-Advanced System Settings-Environment Variables-System Variables-Path-Edit-New, write php path and ext path, click OK to save
C:/php-5.6.9/php/ext
C:/php-5.6.9/php
5. Put the PHP-OCI8 extension into
- Put the PHP-OCI8 extension into the ext directory in the PHP directory
六、Oracle instant client
- Put in the corresponding version of Oracle instant client (the version used here is 12.2)
- Configure environment variables
C:/instantclient_12_2
Note: Some OS need to restart after updating the environment variables to take effect
Seven, put the test file
- Put the test file index.php according to the path of DocumentRoot in httpd.conf
- It can only be accessed after restarting the service.
<?
phpinfo();
?>
8. Debugging
- Login URL to view phpinfo
- Command line view (whether there is an OCI8 extension)
php -m
9. Matters needing attention
- Configure httpd.conf in Apache to add PHP modification items
- php.ini modify specific entries
- Configure PHP and instant OS environment variables
- put in extension