These instructions assume you have already completed the previous 2 installations and have them working.
IMPORTANT: Update to Installing Apache.... If you downloaded Apache from the previous installation instructions and it is 32-bit, you will need to re-download Apache again (I have updated the download link to provide the 64-bit version of the file).
Earlier in the term you would have installed PHP by downloading a folder and placing that folder in the root C drive. C:\php
It is now recommended that you move the php folder to inside your Apache24 folder. C:\Apache24\php
Update your system environment pathvariables to change the associated path to the new folder. C:\Apache24\php
If you did not create an environment path variable to the Apache24/bin folder, do so now: C:\Apache24\bin
Look in your php folder for a file named: php8apache2_4.dll
. If this file does not exist, you will need to go back to the php download site and download the thread friendly version of php and replace the files in the php folder with that version making sure all the files are in the same location as before.
Edit the httpd.conf
file, located in c:\Apache24\conf
directory by adding the following code the the bottom of the file and saving it.
PHPIniDir "c:/Apache24/php"
LoadFile C:/Apache24/php/php8ts.dll
LoadFile c:/Apache24/php/libpq.dll
LoadModule php_module c:/Apache24/php/php8apache2_4.dll
AddType application/x-httpd-php .phtml .php
AddType application/x-httpd-source .phps
To verify that php is installed correctly and in the right location: Open a command prompt (as administrator) and type php -v
. You should get the version information from PHP. If this did not work, then you might check the environment variables, firewalls, anti-virus software, or that the files are in the correct location.
To verify the httpd.conf file is properly formatted and the files are all located where they are expected to be: Open a command prompt (as administrator) and type httpd -t
. You should get a message stating that the syntax is okay. If you get an error, see if it is an obvious typo. Otherwise, make sure that you have downloaded the correct version of PHP x64 and the placed the files in the right location.
Edit the httpd.conf file one more time:
- change the #Servername ....:80
line to be: ServerName localhost
- Save the file
- Restart the Apache24 Service in the windows services application.
In the PHP folder should be a file named php.ini-development
. Make a copy of this file and rename the copy to php.ini
.
Edit this new php.ini
file and make the following changes:
edit the line (approx. line 768) #extension_dir = "ext"
to change to extension_dir = "C:/Apache24/php/ext"
Set the date.timezone
line (Approx. line 978) to be date.timezone = "America/Toronto"
. Remove the # if there is one!
Search for the line: ;extension=pgsql
Right before the above ;extension=pgsql
- Windows11 - add a new line with: extension=php_pgsql.dll
- Windows10 - add a new line with: extension=php_pgsql
Save and exit the php.ini file.
Restart the Apache24 service in the services application once again.
To test PHP, I suggest moving one of your PHP labs (4, 5, or 6) to your server web folder and testing if it works.
To test the Database connectivity and access to the pg_connect() function, import Lab7 into your web folder and see if it works.
This is an extremely frustrating process and troubleshooting will be part of it. Let us work together in class to get this worked out.