Windows伺服器安裝配置PHP7.0環境圖文教程

來源:互聯網
上載者:User

標籤:mpi   comment   ase   低版本   相關   環境   ddl   ace   gzip   

摘自http://www.111cn.net/phper/linux-php/109865.htmWindows伺服器安裝配置PHP7.0環境圖文教程www.111cn.net 更新:2016-05-20 編輯:swteen 來源:轉PHP7在windows環境中安裝已經不像低版本的php了它需要安裝其它的一些外掛程式才可以正常的運行了,下面我們來看一篇關於Windows伺服器安裝配置PHP7.0環境圖文教程了,希望對各位有協助。 

在Windows環境下載及配置PHP7.0,2015年9月可下載PHP5.4至7.0,這次使用最新PHP版本7.0。而「PHP 7.0.0 RC 1」、「PHP 7.0.0 RC 2」是屬於開發當中的版本,在生產環境使用需注意,穩定版是PHP5.6.13。

確認Microsoft Visual C++版本

Microsoft Visual C++的版本至關重要,根據Microsoft Visual C++版本下載的PHP不同。

PHP官網的左側欄有以下注釋。

VC9, VC11 & VC14
More recent versions of PHP are built with VC9, VC11 or VC14 (Visual Studio 2008, 2012 or 2015 compiler respectively) and include improvements in performance and stability.
– The VC9 builds require you to have the Visual C++ Redistributable for Visual Studio 2008 SP1 x86 or x64 installed
– The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 x86 or x64 installed
– The VC14 builds require to have the Visual C++ Redistributable for Visual Studio 2015 x86 or x64 installed
根據Microsoft Visual C++版本選擇下載的PHP版本。

VC9:Microsoft Visual C++ 2008
VC11:Microsoft Visual C++ 2012
VC14:Microsoft Visual C++ 2015

點擊「開始」->「控制台」>->「卸載程式」,可以查看到現在的Microsoft Visual C++的版本。


Microsoft Visual C++版本是2015,因此必須選擇VC14開始的PHP檔案。

下載PHP7.0

從以下PHP官網進行下載。

  • http://www.php.net/

「PHP 7.0.0 RC 2」處寫著「Windows source and binaries can be found on windows.php.net/qa/」。

下載源碼訪問如下URL。
  • http://windows.php.net/qa/

PHP7.0(7.0.0RC2)的32位有「VC14 x86 Non Thread Safe」、「VC14 x86 Thread Safe」,64位有「VC14 x64 Non Thread Safe」、「VC14 x64 Thread Safe」。這次使用環境是Windows Server2008 64位因此選擇下載64位的「VC14 x64 Thread Safe」,大家根據自己的實際環境選擇下載的源檔案(下載之前再次提醒大家注意VC9、VC11、VC14是根據Windows環境的Microsoft Visual C++版本選擇,如果Microsoft Visual C++ 2012的話,就不可以下載VC14的PHP檔案。)。

重要的是在左側欄,有以下注意事項。

IIS
If you are using PHP as FastCGI with IIS you should use the Non-Thread Safe (NTS) versions of PHP.Apache
Please use the Apache builds provided by Apache Lounge. They provide VC9, VC11 and VC14 builds of Apache for x86 and x64. We use their binaries to build the Apache SAPIs.If you are using PHP as module with Apache builds from apache.org (not recommended) you need to use the older VC6 versions of PHP compiled with the legacy Visual Studio 6 compiler. Do NOT use VC9+ versions of PHP with the apache.org binaries.With Apache you have to use the Thread Safe (TS) versions of PHP.這次是在以Apache為Web伺服器的環境下使用PHP。Apache可在Apache Lounge進行下載(具體的下載方法參照下載Apache2.4.16,安裝方法參照安裝Apache2.4.16)。PHP有「Non Thread Safe」、「Thread Safe」版本,在這裡使用「Thread Safe」版本。

點擊「VC14 x64 Thread Safe (2015-Sep-04 02:40:39)」的Zip。

點擊「儲存」下載到任意的目錄下,就完成PHP的下載步驟了。

安裝PHP7.0

接著來進行PHP的安裝步驟。把下載的檔案解壓以後,存放到任意的目錄下就完成安裝了。這次安裝到「C:\MiddleWare\PHP」。

運行PHP所需的所有檔案都在該目錄下。

1) 添加PHP模組

首先確認PHP模組的路徑。

在「httpd.conf」檔案,尋找「Dynamic Shared Object (DSO) Support」的部分。預設是在61行附近。並在最後追加如下一行。LoadModule php7_module C:/MiddleWare/PHP/php7apache2_4.dll
# Dynamic Shared Object (DSO) Support## To be able to use the functionality of a module which was built as a DSO you# have to place corresponding `LoadModule‘ lines at this location so the# directives contained in it are actually available _before_ they are used.# Statically compiled modules (those listed by `httpd -l‘) do not need# to be loaded here.## Example:# LoadModule foo_module modules/mod_foo.so#LoadModule access_compat_module modules/mod_access_compat.soLoadModule actions_module modules/mod_actions.so??????#LoadModule xml2enc_module modules/mod_xml2enc.soLoadModule php7_module C:/MiddleWare/PHP/php7apache2_4.dll
追加以上配置以後Apache啟動時,會讀取PHP模組。

2) 登入副檔名

把PHP的副檔名(.php)和PHP關聯起來。例如訪問「http://www.example.com/sample.php」時,返回給瀏覽器的不是sample.php的內容,而是sample.php記載的PHP指令碼的執行結果。

在「httpd.conf」檔案裡搜尋「AddType」。預設是在404行附近,並追加如下2行。AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#    # TypesConfig points to the file containing the list of mappings from    # filename extension to MIME-type.    #    TypesConfig conf/mime.types    #    # AddType allows you to add to or override the MIME configuration    # file specified in TypesConfig for specific file types.    #    #AddType application/x-gzip .tgz    #    # AddEncoding allows you to have certain browsers uncompress    # information on the fly. Note: Not all browsers support this.    #    #AddEncoding x-compress .Z    #AddEncoding x-gzip .gz .tgz    #    # If the AddEncoding directives above are commented-out, then you    # probably should define those extensions to indicate media types:    #    AddType application/x-compress .Z    AddType application/x-gzip .gz .tgz  AddType application/x-httpd-php .php    AddType application/x-httpd-php-source .phps??????</IfModule>
追加以上2行之後當訪問副檔名為.php檔案時,PHP程式會進行處理。

3) 指定php.ini設定檔路徑(PHPIniDir)

首先確認存放php.ini檔案目錄。

在「httpd.conf」檔案裡指定PHP設定檔php.ini的目錄,在這裡添加到「httpd.conf」檔案的最後。PHPIniDir “c:/MiddleWare/PHP”Apache會參照PHPIniDir目錄下的php.ini檔案。

4) 確認PHP運行情況

PHP相關的Apache配置已經完成。在這裡作一個簡單的PHP指令檔確認配置是否正確。變更設定檔之後別忘了重啟Apache。

開啟文字編輯器,追加如下內容。<?php
phpinfo();
?>

文靜名為「phpinfo.php」,儲存到Apache的htdocs目錄下。

開啟瀏覽器輸入「http://localhost/phpinfo.php」。如以下頁面顯示PHP相關資訊的話,Apache可以正常調用PHP了。


好了以上就是關於Windows伺服器安裝配置PHP7.0環境圖文教程了,這裡介紹了安裝那個版本的外掛程式可以支援php 7正常在windows中運行了。

Windows伺服器安裝配置PHP7.0環境圖文教程

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.