Difference between revisions of "Installing PHP On Windows"

From ISoft Wiki
Jump to navigationJump to search
(Create the basic installation documentation for PHP on Windows)
 
m (Updating the install procedure)
 
(6 intermediate revisions by 3 users not shown)
Line 2: Line 2:


== Installing PHP ==
== Installing PHP ==
For maximum compatibility, the PHP install provided is compiled for 32-bit, but will work just fine on 64-bit systems.
For maximum compatibility, we'll be using the 64-bit version of PHP.


1. Download the PHP package from dl.isoftdata.com: [http://dl.isoftdata.com/php-5.5.9-windows.zip http://dl.isoftdata.com/php-5.5.9-windows.zip]
1. Download the latest version of PHP; you'll want to download the zip that is x64 and Thread Safe.


2. Unzip the top level zip file and run vcredist_x86.exe.  This installs the Visual C++ for Visual Studio 2012 redistributable necessary for PHP.
2. Download and install the Visual C++ redistributable for Visual Studio (necessary for PHP).
# Find the redistributable package here:
*64-bit: https://www.microsoft.com/en-us/download/details.aspx?id=48145


3. Unzip the php-5.5.9-Win32-VC11-x86.zip zip file into C:\Program Files(x86)\PHP
3. Unzip the php-5.5.12-Win64-VC11-x64.zip file into C:\Program Files\PHP


4. Open up the System Properties.  Under the "Advanced" tab, click "Environmental Variables".  Pick the "Path" from the list in the "System variables" box.  Click the "Edit..." button.  Type ";C:\Program Files(x86)\PHP" into the box to add the PHP to the path.  Click all the OKs.
4. Open up the System Properties.  Under the "Advanced" tab, click "Environmental Variables".  Pick the "Path" from the list in the "System variables" box.  Click the "Edit..." button.  Type ";C:\Program Files\PHP") into the box to add the PHP to the path.  Click all the OKs.


5. Rename C:\Program Files (x86)\PHP\php.ini-release to C:\Program Files (x86)\PHP\php.ini
5. Rename C:\Program Files (x86)\PHP\php.ini-production to C:\Program Files (x86)\PHP\php.ini


6. Edit that php.ini file:
6. Edit that php.ini file:
   Uncomment (remove the semicolon at the start of the line) date.timezone= and set it to the valid timezone.  ISoft is 'date.timezone=America/Chicago'
   Uncomment (remove the semicolon at the start of the line) date.timezone= and set it to the valid timezone.  Central Time is 'date.timezone=America/Chicago', Eastern Time is 'date.timezone=America/New_York'
   Uncomment the line that says 'extension_dir = "ext"'
   Uncomment the line that says 'extension_dir = "ext"'
   Uncomment the line that says 'extension=php_mysqli.dll'
   Uncomment the line that says 'extension=php_mysqli.dll'
'''Note:''' If php.ini seems to up and disappear, this is because Windows has moved it to the user's application store: C:\Users\<username>\AppData\Local\VirtualStore\Program Files (x86)\PHP  You can edit it in that location, and when PHP is run under this user, it'll act as though the ini file is in the directory.  To make php.ini valid for all users, once the changes have been made to php.ini, copy it from the VirtualStore to C:\Program Files (x86)\PHP.


7. Verify the configuration by running <pre>php -r phpinfo(); > phpinfo.rtf</pre> If this doesn't work, make sure that PHP is in the path.
7. Verify the configuration by running this in a command prompt:<pre>php -r phpinfo(); > phpinfo.txt</pre> If this doesn't work, make sure that PHP is in the path.


8. Open phpinfo.rtf in WordPad, and make sure there is a mysqli section. If there isn't a mysqli section, check to see that "Loaded Configuration File" near the beginning of the file is "C:\Program Files (x86)\PHP\php.ini"
8. Open phpinfo.txt in Notepad, and make sure there is a mysqli section. If there isn't a mysqli section, check to see that "Loaded Configuration File" near the beginning of the file is "C:\Program Files\PHP\php.ini"


The php.ini file can be customized for the site or any script needs.  The date.timezone change is strongly recommended, as PHP will constantly complain unless it is set.  The mysqli change is required for most of our modern scripts, and is recommended regardless.
The php.ini file can be customized for the site or any script needs.  The date.timezone change is strongly recommended, as PHP will constantly complain unless it is set.  The mysqli change is required for most of our modern scripts, and is recommended regardless.


If the php.ini file is changed, running PHP processes will need to be restarted to catch those changes.  That means restarting any Apache, IIS, or FastCGI instances on the server.  If only standalone scripts are used, there is no running process to restart.
If the php.ini file is changed, running PHP processes will need to be restarted to catch those changes.  That means restarting any Apache, IIS, or FastCGI instances on the server.  If only standalone scripts are used, there is no running process to restart.

Latest revision as of 11:10, 10 January 2017

Some scripts and services that we can provide are written in PHP. To roll them out to customers, we need to install PHP on their servers. This is generally already done or easily done on Linux servers, but is more difficult for Windows servers. This document gives a quick walkthrough of the installation process.

Installing PHP

For maximum compatibility, we'll be using the 64-bit version of PHP.

1. Download the latest version of PHP; you'll want to download the zip that is x64 and Thread Safe.

2. Download and install the Visual C++ redistributable for Visual Studio (necessary for PHP).

  1. Find the redistributable package here:

3. Unzip the php-5.5.12-Win64-VC11-x64.zip file into C:\Program Files\PHP

4. Open up the System Properties. Under the "Advanced" tab, click "Environmental Variables". Pick the "Path" from the list in the "System variables" box. Click the "Edit..." button. Type ";C:\Program Files\PHP") into the box to add the PHP to the path. Click all the OKs.

5. Rename C:\Program Files (x86)\PHP\php.ini-production to C:\Program Files (x86)\PHP\php.ini

6. Edit that php.ini file:

 Uncomment (remove the semicolon at the start of the line) date.timezone= and set it to the valid timezone.  Central Time is 'date.timezone=America/Chicago', Eastern Time is 'date.timezone=America/New_York'
 Uncomment the line that says 'extension_dir = "ext"'
 Uncomment the line that says 'extension=php_mysqli.dll'

Note: If php.ini seems to up and disappear, this is because Windows has moved it to the user's application store: C:\Users\<username>\AppData\Local\VirtualStore\Program Files (x86)\PHP You can edit it in that location, and when PHP is run under this user, it'll act as though the ini file is in the directory. To make php.ini valid for all users, once the changes have been made to php.ini, copy it from the VirtualStore to C:\Program Files (x86)\PHP.

7. Verify the configuration by running this in a command prompt:

php -r phpinfo(); > phpinfo.txt

If this doesn't work, make sure that PHP is in the path.

8. Open phpinfo.txt in Notepad, and make sure there is a mysqli section. If there isn't a mysqli section, check to see that "Loaded Configuration File" near the beginning of the file is "C:\Program Files\PHP\php.ini"

The php.ini file can be customized for the site or any script needs. The date.timezone change is strongly recommended, as PHP will constantly complain unless it is set. The mysqli change is required for most of our modern scripts, and is recommended regardless.

If the php.ini file is changed, running PHP processes will need to be restarted to catch those changes. That means restarting any Apache, IIS, or FastCGI instances on the server. If only standalone scripts are used, there is no running process to restart.