What Will I Learn?
- Configure PHP 7
- Configure Apache to work with PHP 7
Requirements
- Windows 10, 8.1,7
- RAM 4GB (at least)
- Apache must be installed before (check my previous tutorials)
- PHP 7 must be installed before (check my previous tutorials)
- Text Editor (Notepad++ for example)
Difficulty
- Basic
Getting Started
In this tutorial I'm using php7 (thread safe) as well as apache24 version
please make sure you've unzipped the files In the place you prefer before we start.
or simply check my previous tutorials at the end of this tutorial.
Note:
make sure you've stoppded/uninstalled the service before start.
do the following commands in the command prompt window (cmd.exe) as administrator
cd C:\Apache24\bin
Hit Enter, Then
httpd.exe -k stop
Hit Enter. That's it.
Configure Apache
Open the Apache Configuration file C:\Apache24\conf\httpd.conf
After all modules add this:
LoadModule php7_module C:/php7/php7apache2_4.dll
<IfModule php7_module>
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php7"
</IfModule>
How to set Directory index?
Add this inside ifModule php7_module
also you can add different formats or more than one file name.
DirectoryIndex index.html index.php
Example
LoadModule php7_module C:/php7/php7apache2_4.dll
<IfModule php7_module>
DirectoryIndex index.html default.php index.php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/php7"
</IfModule>
Then. Make sure you've added it after all modules
Save the file then close it.
Configure PHP 7
First rename the file C:\php7\php.ini-development
to C:\php7\php.ini
. It’s a good idea to make a backup of this file as well.
Enable Extensions
Edit C:\php7\php.ini
;extension=php_mysqli.dll
;extension=php_mbstring.dll
;extension=php_pdo_mysql.dll
just uncomment it. by removing ;
then it will be enabled.
Save the file then close it.
Create the following php file C:\Apache24\htdocs\phpinfo.php
<?php
phpinfo();
?>
Start Apache Service
You have to start Apache Windows service, to do this, use Apache monitor C:\Apache24\bin\ApacheMonitor.exe
`
The other alternative is to open the command prompt window (cmd.exe) as administrator and execute:
if the service isn't installed:
httpd.exe -k install
to start the service:
httpd.exe -k start
to stop the the service
httpd.exe -k stop
Then browse to:
http://localhost/phpinfo.php
to make sure everything is okay!
Troubleshooting
Configuration Problems Apache
If you have any problem when starting Apache because of its configuration, you can see the detailed error by executing:
cd C:\Apache24\bin
Hit Enter, Then
httpd.exe -t
Enter.
The -t parameter test the syntax of the configuration files, and then exits.
You can find the specification of the others parameters here.
also make sure you've installed:
Visual C++ Redistributable for Visual Studio 2012
Visual C++ Redistributable for Visual Studio 2017
To avoid any errors like MSVCR110.dll
, MSVCR140.dll
Previous Tutorials
- Configure PHP 5 after installing with Apache on windows
- How to use multiple PHP versions with Apache on Windows
- Setup your own Apache MariaDB PHP phpMyAdmin on Windows!
All images has been taken/created by @Jinzo for an open source project.
Posted on Utopian.io - Rewarding Open Source Contributors