PHP: Windows 系统下的安装

切换语言:

English

German

Spanish

French

Italian

Japanese

Brazilian Portuguese

Russian

Turkish

Ukrainian

Chinese (Simplified)

Other

Windows 系统下的安装

目录Windows 系统下的推荐配置手动安装预编译的二进制文件在Windows系统上安装 Apache 2.xWindows 上与 IIS 安装用于安装 PHP 的第三方工具从源程序编译在 Windows 系统的命令行上运行 PHP

建议在生产中使用 Windows 上的 PHP 官方版本,但也可以从源代码编译 PHP。

PHP 也可以安装在 Azure App Services(Azure 应用服务)(又名

Microsoft Azure、Windows Azure 或 (Windows) Azure Web Apps(Azure Web 应用))上。

常见问题解答的安装章节涵盖了可能遇到的常见安装和配置问题。

发现了问题?

了解如何改进此页面

提交拉取请求

报告一个错误

+添加备注

用户贡献的备注 2 notes

up

down

572

SmugWimp at smugwimp dot com ¶20 years ago

If you make changes to your PHP.ini file, consider the following.

(I'm running IIS5 on W2K server. I don't know about 2K3)

PHP will not "take" the changes until the webserver is restarted, and that doesn't mean through the MMC. Usually folks just reboot. But you can also use the following commands, for a much faster "turnaround". At a command line prompt, type:

iisreset /stop

and that will stop the webserver service. Then type:

net start w3svc

and that will start the webserver service again. MUCH faster than a reboot, and you can check your changes faster as a result with the old:

phpinfo();

?>

in your page somewhere.

I wish I could remember where I read this tip; it isn't anything I came up with...

up

down

109

lukasz at szostak dot biz ¶20 years ago

You can have multiple versions of PHP running on the same Apache server. I have seen many different solutions pointing at achieving this, but most of them required installing additional instances of Apache, redirecting ports/hosts, etc., which was not satisfying for me.

Finally, I have come up with the simplest solution I've seen so far, limited to reconfiguring Apache's httpd.conf.

My goal is to have PHP5 as the default scripting language for .php files in my DocumentRoot (which is in my case d:/htdocs), and PHP4 for specified DocumentRoot subdirectories.

Here it is (Apache's httpd.conf contents):

---------------------------

# replace with your PHP4 directory

ScriptAlias /php4/ "c:/usr/php4/"

# replace with your PHP5 directory

ScriptAlias /php5/ "c:/usr/php5/"

AddType application/x-httpd-php .php

Action application/x-httpd-php "/php5/php-cgi.exe"

# populate this for every directory with PHP4 code

Action application/x-httpd-php "/php4/php.exe"

# directory where your PHP4 php.ini file is located at

SetEnv PHPRC "c:/usr/php4"

# remember to put this section below the above

# directory where your PHP5 php.ini file is located at

SetEnv PHPRC "c:/usr/php5"

---------------------------

This solution is not limited to having only two parallel versions of PHP. You can play with httpd.conf contents to have as many PHP versions configured as you want.

You can also use multiple php.ini configuration files for the same PHP version (but for different DocumentRoot subfolders), which might be useful in some cases.

Remember to put your php.ini files in directories specified in lines "SetEnv PHPRC...", and make sure that there's no php.ini files in other directories (such as c:\windows in Windows).

And finally, as you can see, I run PHP in CGI mode. This has its advantages and limitations. If you have to run PHP as Apache module, then... sorry - you have to use other solution (the best advice as always is: Google it!).

Hope this helps someone.

+添加备注

区别对待消费者?法国版iPhone13依旧有耳机,理由很奇葩
王者荣耀怎么拆卸铭文 王者荣耀铭文拆卸指南