Download PHP Non Thread Safe version from http://windows.php.net.
After download finished, extract it into your computer and rename the folder with "php", copy it into your Apache folder "C:\apache"
Create a new folder in D drive name it "MyWebs" we will set this as a new Apache Document Root
In the "C:\apache\php" folder, find and rename "php.ini-production" to "php.ini"
Double click to open it and find the following line:
doc_root =
Add path to the MyWebs folder we've just created:
doc_root = "d:\mywebs"
Find the next line:
; extension_dir = "ext"
Uncomment it and add path to the PHP extensions directory:
extension_dir = "c:\apache\php\ext"
By default PHP uses Windows temp to store session and upload data. We can move them to Apache directory.
Create a new folder in "C:\apache" name it "temp" inside the "temp" folder create 2 folders name them "upload" and "session" Now we got 2 new folders "C:\apache\temp\upload" and "C:\apache\temp\session"
Still in the PHP configuration file (php.ini) find the below line:
;upload_tmp_dir =
Uncomment it and add path to the upload folder:
upload_tmp_dir= "C:\apache\temp\upload"
And the next line:
;session.save_path = "/tmp"
Uncomment it and add path to the session folder:
session.save_path= "C:\apache\temp\session"
Save the PHP configuration.
Configuring Apache Server with PHP.
Download FastCGI ASF module (mod_fcgid.so) from http://www.apachelounge.com/download/, you can find it in the Apache modules section
Extract it and copy the mod_fcgid.so into the Apache modules folder C:\Apache\modules
Open up Apache Configuration file, located at C:\apache\conf\httpd.conf
Find DocumentRoot and Directory
DocumentRoot "c:/Apache/htdocs"
<Directory "c:/Apache/htdocs">
Replace the path to the PHP doc_root we created earlier
DocumentRoot "d:/mywebs"
<Directory "d:/mywebs">
Still in the <Directory "d:/mywebs"> replace the foolowing line:
Options Indexes FollowSymLinks
With these lines:
Options Indexes FollowSymLinks ExecCGI
AddHandler fcgid-script .php
FcgidWrapper c:/apache/php/php-cgi.exe .php
Next, find DirectoryIndex as follows:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Add index.php to the line
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
At the end of the httpd.conf add the following lines:
#LoadModule fcgid_module modules/mod_fcgid.so
#FcgidInitialEnv PHPRC "C:/Apache/php"
Restart the Apache Server.
Testing PHP run as FastCGI
Open up Notepad, copy and paste the code below:
<?php phpinfo(); ?>
Save the file into Apache document root "D:\MyWebs" as "phpinfo.php"
Open up browser, in the address bar type in "http://localhost/phpinfo.php" and Enter.
If you did it right, you should see something like the image above.
Here is a video on YouTube How to install PHP as FastCGI under Apache on Windows 10
No comments:
Post a Comment