Windows下Apache和php環(huán)境怎么搭建

這篇文章主要講解了“Windows下Apache和php環(huán)境怎么搭建”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“Windows下Apache和php環(huán)境怎么搭建”吧!

成都創(chuàng)新互聯(lián)公司是一家專(zhuān)注于成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作服務(wù)器托管機(jī)柜的網(wǎng)絡(luò)公司,有著豐富的建站經(jīng)驗(yàn)和案例。

獲取php和Apache安裝文件

php下載地址:http://windows.php.net/download/

獲取安裝包:httpd-2.4.23-win64-VC11.zip

apache下載地址:https://www.apachelounge.com/download/VC11/

獲取安裝包:php-5.6.27-Win32-VC11-x64.zip

我統(tǒng)一解壓到D盤(pán)根目錄,對(duì)應(yīng)目錄是:

D:\Apache24

D:\php-5.6.27-Win32-VC11-x64

打開(kāi)httpd.conf文件 D:\Apache24\conf\httpd.conf

找到以下幾處

ServerRoot "c:/Apache24"

DocumentRoot "c:/Apache24/htdocs"

<Directory "c:/Apache24/htdocs">

ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"

<Directory "c:/Apache24/cgi-bin">

將里面默認(rèn)的配置路徑“c:/Apache24”統(tǒng)統(tǒng)改為你當(dāng)前apache的目錄路徑“D:/Apache24”,如下:

ServerRoot "D:/Apache24"

DocumentRoot "D:/Apache24/htdocs"

<Directory "D:/Apache24/htdocs">

ScriptAlias /cgi-bin/ "D:/Apache24/cgi-bin/"

<Directory "D:/Apache24/cgi-bin">

添加下面幾行,增加對(duì)php5的支持:

# php5 support

LoadModule php5_module D:/php-5.6.27-Win32-VC11-x64/php5apache2_4.dll

AddType application/x-httpd-php .php .html .htm

# configure the path to php.ini

PHPIniDir "D:/php-5.6.27-Win32-VC11-x64"

DirectoryIndex index.php index.html  加入index.php識(shí)別入口

將Include conf/extra/httpd-vhosts.conf注釋打開(kāi),并打開(kāi)httpd-vhosts.conf文件,開(kāi)始配置虛擬主機(jī)

下面是我的httpd-vhosts.conf配置示例

<VirtualHost *:80>

    ServerAdmin liuzhen@leimingtech.com

    DocumentRoot "D:/Apache24/htdocs"

    ServerName localhost

    ServerAlias 127.0.0.1

    ErrorLog "logs/dummy-host.example.com-error.log"

    CustomLog "logs/dummy-host.example.com-access.log" common

    DirectoryIndex index.php index.html

</VirtualHost>

注意里面對(duì)應(yīng)的端口需要在httpd.conf配置文件中添加,Listen 80,多個(gè)可以分開(kāi)寫(xiě)兩個(gè)

Listen 80

Listen 8080

在D:\php-5.6.27-Win32-VC11-x64下面找php.ini-development,復(fù)制一份,命名為php.ini

調(diào)整一下幾點(diǎn)

On windows:

extension_dir = "D:/php-5.6.27-Win32-VC11-x64/ext"

short_open_tag = On  讓PHP支持簡(jiǎn)短標(biāo)簽寫(xiě)法,如在設(shè)置為Off時(shí),在寫(xiě)程序時(shí)用<?=$xxx;?>會(huì)報(bào)錯(cuò),要寫(xiě)成<?php echo $xxx;?>才行

extension=php_MySQL.dll 

extension=php_mbstring.dll

extension=php_curl.dll  如果未生效將PHP安裝文件夾下的三個(gè)文件php_curl.dll(可能在ext文件夾中),libeay32.dll,ssleay32.dll 復(fù)制到 %windir%/system32下

extension=php_gd2.dll

extension=php_openssl.dll

extension=php_pdo_mysql.dll

extension=php_xmlrpc.dll

date.timezone = Asia/Shanghai 設(shè)置時(shí)區(qū)

將php加入到環(huán)境變量
D:/php-5.6.27-Win32-VC11-x64/ext;D:php-5.6.27-Win32-VC11-x64;

打開(kāi)windows命令行用管理員身份運(yùn)行

切換到D:\Apache24\bin目錄

加入服務(wù):httpd -k install -n Apache24

卸載服務(wù):sc delete Apache24

apache加入服務(wù)過(guò)程中出現(xiàn)丟失MSVCR110.dll錯(cuò)誤信息

Windows下Apache和php環(huán)境怎么搭建

需要安裝一個(gè)微軟的V11組件,下載地址:http://www.microsoft.com/zh-CN/download/details.aspx?id=30679

我這里是64位操作系統(tǒng),所以下載VSU4\vcredist_x64.exe

安裝完成后,重新執(zhí)行“httpd -k install -n Apache24”命令再次加入服務(wù)

感謝各位的閱讀,以上就是“Windows下Apache和php環(huán)境怎么搭建”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)Windows下Apache和php環(huán)境怎么搭建這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

網(wǎng)頁(yè)名稱(chēng):Windows下Apache和php環(huán)境怎么搭建
本文鏈接:http://muchs.cn/article32/ipjisc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、網(wǎng)站收錄、標(biāo)簽優(yōu)化、靜態(tài)網(wǎng)站ChatGPT、品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司