win10環(huán)境PHP 7 安裝配置【教程】
PHP 7出來好一段時間了,前些日子工作比較忙,沒時間研究,現(xiàn)在有點時間了,公司里生產環(huán)境不能隨便升級,家里自己的電腦還是可以裝一下看看效果的。
下面簡單說明一下PHP 7 + Apache 2.4的安裝。
Apache 2.4 安裝配置 安裝
Apache 2.4,在官方網(wǎng)站上沒有Windows下的編譯版本,需要到http://httpd.apache.org/docs/2.4/platform/windows.html找到提供Windows編譯版本下載的鏡像網(wǎng)站,我用的是:http://www.apachelounge.com/download/,根據(jù)需要下載32或64位版本,下載后是個zip包。下載后,將ZIP包內的Apace24目錄解壓到任意目錄。
注意:Apache和PHP的一些信息要匹配,包括32/64位、VC版本號。對于PHP 7,官網(wǎng)上只有VC14編譯的版本,因此對應的Apache版本也需要是VC14編譯的。
配置
單站點配置
打開%Apache24%\conf\httpd.conf文件:
1、 找到“ServerRoot”,將其指定為%Apache24%所在目錄;
2、 修改文檔根目錄;
DocumentRoot "E:/wwwpages" <Directory "E:/wwwpages">
3、 添加 index.php 到 index 目錄中
DirectoryIndex index.html index.php
4、 把Apache安裝成服務:
httpd.exe -k install -n "Apache24"
若服務啟動失敗則修改下端口號。
多站點配置(用端口號區(qū)分)
在一臺服務器上可以配置多個站點,本節(jié)說明如何配置通過端口號區(qū)分的不同站點。
配置httpd.conf。
首先增加監(jiān)聽端口(配置幾個站點,就增加幾個端口):
Listen 8081
Listen 8082
等以上內容都設置以后,可以通過netstat -n -a查看端口是否開啟。
其次配置虛擬站點:
NameVirtualHost *:8080 <VirtualHost *:8080> ServerName www.mysite1.com #DocumentRoot "C:/Rainman/ProjectWorkspace2.0/SourceCode/Server/wanpush" DocumentRoot "C:/Rainman/ProjectWorkspace3.0_clound/SourceCode" <Directory "C:/Rainman/ProjectWorkspace3.0_clound/SourceCode"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> ErrorLog "logs/mysite1.com-error.log" CustomLog "logs/mysite1.com-access.log" common </VirtualHost> NameVirtualHost *:8081 <VirtualHost *:8081> ServerName www.mysite2.com DocumentRoot "C:/Rainman/ProjectWorkspace3.0_clound/yiqixiu" <Directory "C:/Rainman/ProjectWorkspace3.0_clound/yiqixiu"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> ErrorLog "logs/mysite2.com-error.log" CustomLog "logs/mysite2.com-access.log" common </VirtualHost>
主要為每個虛擬站點配置DocumentRoot和Directory參數(shù)。
驗證
安裝完成后,編寫如下HTML頁面:
<html> <body> <h1>Hello world!</h1> </body> </html>
另存為index.html,該文件拷貝到“E:/wwwpages”下。
打開URL:http://localhost:8080/,頁面顯示“Hello world!”,則表示Apache安裝啟動成功。
卸載服務
卸載服務:httpd –k uninstall –n “apache24”
注意:名稱一定要跟安裝時的名稱保持一致。
PHP 7.0.6 安裝配置 安裝 下載php-7.0.6-Win32-VC14-x64.zip,將其解壓到任意目錄。
配置 1、配置Apache
打開Apache的配置文件,增加如下內容:
LoadModule php7_module "D:/PHPDevEnv/PHP/php7apache2_4.dll" AddType application/x-httpd-php .php AddType application/x-httpd-php .html AddHandler application/x-httpd-php .php PHPIniDir "D:/PHPDevEnv/PHP"
注:紅色部分使用實際的路徑。
2、配置PHP
將PHP目錄下的php.ini-development改名為php.ini,然后打開該文件,查找“extension_dir”,將前面注釋去掉,并修改為絕對路徑,譬如:
extension_dir = "D:/PHPDevEnv/PHP/ext"
注:修改為絕對路徑,是避免有些PHP擴展找不到正確的路徑。
驗證 在Apache網(wǎng)站根目錄(具體位置見2.1節(jié))下創(chuàng)建一個 phpinfo.php 文件:
<?php
phpinfo();
?>
在瀏覽器中打開http://localhost:8080/phpinfo.php.
相關文章
解析php中static,const與define的使用區(qū)別
本篇文章是對php中static,const與define的使用區(qū)別進行了詳細的分析介紹,需要的朋友參考下2013-06-06php數(shù)組函數(shù)序列 之array_count_values() 統(tǒng)計數(shù)組中所有值出現(xiàn)的次數(shù)函數(shù)
array_count_values() 函數(shù)用于統(tǒng)計數(shù)組中所有值出現(xiàn)的次數(shù),本函數(shù)返回一個數(shù)組,其元素的鍵名是原數(shù)組的值,鍵值是該值在原數(shù)組中出現(xiàn)的次數(shù)。2011-10-10PHP結合vue導出excel出現(xiàn)亂碼的解決方法分享
這篇文章主要為大家詳細介紹了PHP結合vue導出excel出現(xiàn)亂碼的解決方法,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下2023-02-02php array_slice函數(shù)的使用以及參數(shù)詳解
array array_slice ( array array, int offset [, int length]),根據(jù) offset 和 length 參數(shù)所指定的 array 數(shù)組中的一段序列。offset 表示開始位置,length表示這段序列的長度.2008-08-08