Difference between revisions of "Installing PHP On Windows"
(I don't have time to update it right now) |
m (Updating the install procedure) |
||
Line 1: | Line 1: | ||
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. | 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 == | == Installing PHP == | ||
For maximum compatibility, the | For maximum compatibility, we'll be using the 64-bit version of PHP. | ||
1. Download the PHP | 1. Download the latest version of PHP; you'll want to download the zip that is x64 and Thread Safe. | ||
2. | 2. Download and install the Visual C++ redistributable for Visual Studio (necessary for PHP). | ||
# Find the redistributable | # Find the redistributable package here: | ||
*64-bit: https://www.microsoft.com/en-us/download/details.aspx?id=48145 | *64-bit: https://www.microsoft.com/en-us/download/details.aspx?id=48145 | ||
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. | |||
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 | |||
5. Rename 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. | 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. | '''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. | 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. | 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 10: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).
- 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.