Configure PHP 7 after installing with Apache on windows

in #utopian-io6 years ago (edited)

introphp.png

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
1.png

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
5.png

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.
4.png
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
3.png
`

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


All images has been taken/created by @Jinzo for an open source project.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

This post has received a 0.03 % upvote from @drotto thanks to: @jinzo.

Your Post Has Been Featured on @Resteemable!
Feature any Steemit post using resteemit.com!
How It Works:
1. Take Any Steemit URL
2. Erase https://
3. Type re
Get Featured Instantly – Featured Posts are voted every 2.4hrs
Join the Curation Team Here

Hey @jinzo I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Apache is a great addition to the stack if you want great performance. The platform I am using for apache server hosting also uses nginx that further boosts the performance.

Coin Marketplace

STEEM 0.19
TRX 0.13
JST 0.030
BTC 63768.98
ETH 3410.21
USDT 1.00
SBD 2.49