溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

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

發(fā)布時(shí)間:2021-08-14 23:04:03 來(lái)源:億速云 閱讀:174 作者:chen 欄目:web開發(fā)

這篇文章主要講解了“Windows下Apache和php環(huán)境怎么搭建”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“Windows下Apache和php環(huá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盤根目錄,對(duì)應(yīng)目錄是:

D:\Apache24

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

打開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注釋打開,并打開httpd-vhosts.conf文件,開始配置虛擬主機(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è)可以分開寫兩個(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)簽寫法,如在設(shè)置為Off時(shí),在寫程序時(shí)用<?=$xxx;?>會(huì)報(bào)錯(cuò),要寫成<?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;

打開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)證。這里是億速云,小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI