Monday, September 14, 2020

How to Install PHP on Windows with Apache



Hello dear readers! welcome back to another section of my tutorial on PHP. In this tutorial guide, we will be discussing about how to Install PHP on Windows OS with Apache.

The following below are the simple steps to install Apache and PHP5 on your Windows system. If the version of your PHP is different, then please take care accordingly.

Step 1

Download Apache server from their official website. You want the current stable release version with the no_src_msi extension. Double click the installer file to install; C:\Program Files is a common location. The PHP installer will also ask you if you want to run Apache as a service or from a command line or dos prompt. We recommed that you do not install as a service, as this may cause problems on startup.

Step 2

Now you need to extract the binary archive by using your unzip utility; C:\PHP is a common location.

Step 3

Copy few .dll files from your PHP directory to your systems directory (usually C:\Windows). You need a php5ts.dll for every case. You will also probably need to copy the file matching to your server module - C:\PHP\Sapi\php5apache.dll. It is possible you will also need others from the dlls subfolder - but start with the two mentioned above and then you can add more if you need them.

Step 4

Copy either php.ini-dist or php.ini-recommended (preferably the latter) to your Windows directory, and then rename it to php.ini. Open this file in a text editor (for example, Notepad). Edit this file to get the configuration directives; We highly recommend new users to set error reporting to E_ALL on their PHP development machines.

Step 5

Tell your Apache server where you want to serve files from and what extension(s) you want to identify the PHP files (.php is the standard, but you can use .html, or whatever you want). Now go to your HTTP configuration files via (C:\Program Files\Apache Group\Apache\conf or anything your path is), and open httpd.conf via a text editor. Search for the expression DocumentRoot (which should display twice) and change both paths to the directory you want to serve files out of. Add at least one PHP extension directive as shown in the first line of the following code -

LoadModule php5_module modules/php5apache.dll
AddType application/x-httpd-php .php .phtml

  • You may also need to add the following line of code.

AddModule mod_php5.c

Step 6

Stop and restart the WWW service. Now go to Start menu → Settings → Control → Panel → Services. Scroll down the list to IIS Admin Service. Select it and click Stop. After it stops select World Wide Web publishing Service and click Start. Stopping and restarting the service from within the Internet Service Manager will not suffice. Since this is a Windows OS, you may wish to reboot.

Step 7

Open a text editor and then type: <?php phpinfo(); ?>. Then save this file in your Web server's document root as info.php.

Step 8

Open any browser and browse the file. You must always make use of an HTTP request. For example, (http://www.domain.com/info.php or http://localhost/info.php or http://127.0.0.1/info.php) rather than making use of a filename (/home/httpd/info.php) in order for the file to be parsed correctly.

You should now see a very long table of information about your new PHP Installation message.


Alright guys! This is where we are rounding up for this tutorial post. In my next tutorial post, we are going to be studying about PHP Configuration in Apache Server.

Feel feel to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.
Share:

0 comments:

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.