In today's era of rapid development of the Internet, business based on Web development has gradually become a method favored by various enterprises, and servers are an indispensable part of any Internet enterprise. For most Internet beginners, setting up a server is a relatively complicated issue, so this article will introduce how to set up PHP on a Windows server for reference.
First of all, in order to set up a PHP environment, we need a web server that can run on Windows. Here we choose IIS as our Web server, which is a web server application developed by Microsoft and can run on the Windows operating system. IIS can be started by installing Internet Information Services (IIS) Manager.
Next, we need to install PHP. You can choose the officially provided Windows version of PHP, or you can download a third-party PHP installation package. Here we choose to download the PHP installation package for installation. Choose a PHP version that suits you, download it and extract it directly to the root directory of IIS, such as: C:\inetpub\wwwroot.
Then, we need to do some configuration on the IIS server. In the IIS manager, find the path where the PHP we downloaded is located, select "Handler Mappings", and then click the "Add Module Mapping" button in the menu on the right. In the dialog box that appears, enter the corresponding information. Among them, "Request Path" selects *.php, "Module" selects FastCgiModule, and "Executable" selects the path where php-cgi.exe is located. Then check "Invoke handler only if request is mapped to", select "File or folder exists", and finally click OK to save the configuration.
Next, we need to configure FastCGI. FastCGI is a general-purpose, high-performance web server extension that can improve the performance of web applications using FastCGI. In IIS Manager, find the tab "FastCGI Settings" and click "Add Application" to set up a new FastCGI application.
In the "Add FastCGI Application" dialog box that opens, enter the corresponding information. Enter the path where php-cgi.exe is located in "Full Path", enter "-c C:\php.ini" in "Arguments", and finally click OK to save the configuration.
Finally, we need to make some settings for the PHP environment in the php.ini file. Find the file C:\php.ini, open it with an editor, find the setting of "extension_dir", enter the directory path of the extension library, such as: extension_dir = "C:\php\ext", and then find the setting of "fastcgi.impersonate" , change it to fastcgi.impersonate = 1, and finally save the file.
At this point, we have successfully set up the PHP environment. You can test whether PHP is running normally by entering "http://localhost/index.php" in the browser.
In short, it is not difficult to set up a PHP environment on a Windows server. You just need to follow the above steps. Of course, in order to better use and manage the PHP environment, it is recommended that developers have an in-depth understanding and master the relevant knowledge to achieve better applications.
The above is the detailed content of How to set up a php environment in windows server. For more information, please follow other related articles on the PHP Chinese website!