Difference between revisions of "Installing PHP On Windows"

From ISoft Wiki
Jump to navigationJump to search
(I don't have time to update it right now)
m (Updating the install procedure)
 
Line 1: Line 1:
<h1> This article is out of date and needs to be revised </h1>
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 PHP install provided is compiled for 32-bit, but will work just fine on 64-bit systems.  If you want to use 64-bit version of PHP, one is also available.  If you use the 64-bit version, you should use C:\Program Files for all instructions, rather than C:\Program Files (x86).  Except for the minor filename and directory changes, all other steps are identical.
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] (32-bit) or [http://windows.php.net/downloads/releases/php-7.0.5-Win32-VC14-x64.zip http://windows.php.net/downloads/releases/php-7.0.5-Win32-VC14-x64.zip] (64-bit)
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 either vcredist_x86.exe or vcredist_x64_vs11.exe (depending on if you are using 32-bit or 64-bit).  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 packages here:  
# Find the redistributable package here:  
*32-bit http://windows.php.net/downloads/releases/php-5.6.18-nts-Win32-VC11-x86.zip
*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


3. Either unzip the php-5.5.9-Win32-VC11-x86.zip zip file into C:\Program Files(x86)\PHP or 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 ";C:\Program Files (x86)\PHP" (Or ";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.
'''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.