使用PHPStudy等集成包搭建是能省不少事,但是也少看見了很多東西,這樣就不能自己安排,不喜歡這種感覺。
我這里是在VM虛擬機的Win7下進行的,其它Windows系統(tǒng)大同小異,其" />
時間:2023-05-31 10:33:02 | 來源:網(wǎng)站運營
時間:2023-05-31 10:33:02 來源:網(wǎng)站運營
一步步教你手動搭建Web服務器環(huán)境:作者:掌控安全-羅網(wǎng)
使用PHPStudy等集成包搭建是能省不少事,但是也少看見了很多東西,這樣就不能自己安排,不喜歡這種感覺。
我這里是在VM虛擬機的Win7下進行的,其它Windows系統(tǒng)大同小異,其實在Windows Server之類的系統(tǒng)上搭建應該更好。
Define SRVROOT "c:/Apache24"ServerRoot"${SRVROOT}"改為Define SRVROOT "d:/Server/Apache24"ServerRoot"${SRVROOT}"
ServerName(主機名):localhost:80,去掉#才能讓設置生效# If your host doesn't have a registered DNS name, enter its IP address here.##ServerName www.example.com:80改為# If your host doesn't have a registered DNS name, enter its IP address here.#ServerName localhost:80
DocumentRoot(Apache默認的網(wǎng)頁目錄):d:/Server/www# DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.#DocumentRoot"${SRVROOT}/htdocs"<Directory"${SRVROOT}/htdocs">改為# DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.#DocumentRoot"d:/Server/www"<Directory"d:/Server/www">
DirectoryIndex(Apache默認的入口網(wǎng)頁):這里沒做更改,就用的默認的index.html沒做更改<IfModule dir_module>DirectoryIndex index.html</IfModule>如果要更改,可以改為<IfModule dir_module>DirectoryIndex index.php index.html index.htm</IfModule>index.php index.html index.htm三個文件是有優(yōu)先關系的,例:若同時有index.php index.html,則默認訪問index.php若只有index.html,則默認訪問index.html
ScriptAlias(沒研究過,反正是個路徑):這里沒做更改沒做更改ScriptAlias/cgi-bin/"${SRVROOT}/cgi-bin/"往下幾行還有這個,也沒改<Directory"${SRVROOT}/cgi-bin">AllowOverrideNoneOptionsNoneRequire all granted</Directory>
我這里虛擬機網(wǎng)絡連接NAT模式下,在物理機中通過Chrome,firefox,IE,360均可正常訪問網(wǎng)頁,唯獨edge不行,不知道為什么。出現(xiàn)It works!說明應該沒什么大問題了,關閉黑窗體,接下來把httpd.exe裝到Windows服務里。
假裝沒發(fā)生過,反正Chrome能訪問就行了。
若想刪除服務,可以以管理員身份運行cmd用sc delete Apache2.4命令刪除安裝成功后,在桌面的“計算機”上右鍵—管理—服務和應用程序—服務,可以查看所有服務,其中就有Apache2.4服務。
;On windows:;extension_dir ="ext"改為;On windows:extension_dir ="D:/Server/PHP/ext"
date.timezone(設置時區(qū)):;date.timezone =改為date.timezone = PRC
default_charset(設置編碼):沒有更改,就用默認的UTF-8default_charset ="UTF-8"
開啟擴展:網(wǎng)上搜了幾個常用的擴展,去掉分號開啟,功能可查官方文檔;extension=curl;extension=gd2;extension=fileinfo;extension=mbstring;extension=pdo_mysql;extension=mysqli改為extension=curlextension=gd2extension=fileinfoextension=mbstringextension=pdo_mysqlextension=mysqli
為Apache服務添加PHP支持 :# php7 supportLoadModule php7_module "D:/Server/PHP/php7apache2_4.dll"AddType application/x-httpd-php .php .html .htm# configure the path to php.iniPHPIniDir"D:/Server/PHP"
<?php phpinfo();?>
<?php $conn=mysqli_connect("localhost","root","root密碼");if($conn) echo "連接success";else echo "連接fail";?>
關鍵詞:服務,環(huán)境
微信公眾號
版權所有? 億企邦 1997-2025 保留一切法律許可權利。