1.web 服務器軟件
Nginx --->反向代理
Apache --->Php
IIs --->Asp.net
tomcat --->Javaphp
2.安裝Web服務器軟件
安裝一個經常使用的web放服務器軟件 Apache HTTP Serverhtml
安裝解壓版的Apache 服務器
bin目錄是二進制的目錄,exe是二進制的文件 可運行的東西放在裏面web
3.打開windows 服務
cmd -->services.msc 查看全部的服務chrome
4.安裝apache服務
httpd.exe -k install -n "Apache"(服務器名稱 可自定義)
Testing httpd.conf...apache
問題1:出現 ServerRoot must be a valid directory(需改配置文件apache/conf/httpd.conf中 ServerRoot:''的路徑)apache的安裝路徑,修改後測試 命令:httpd -twindows
問題2:提示DocumentRoot 「c:/apache/...」is not a directory or is not readable 由於不少未修改路徑的目錄文件名,修改成文件的安裝目錄 路徑瀏覽器
問題3:httpd:Could not reliably determine the server's fully qualified domain name ...
set the 'ServerName' directive globally to suppress this message
解決方案:設置ServerName localhost緩存
5.啓動apache服務器
httpd -k start -n "Apache"tomcat
6.若是網絡設備沒有鏈接任何網絡狀況,咱們會有一個本地迴環地址 127.0.0.1服務器
7.路由器或交換機中的 192.168.1.1屬於網關 ,192.168.1是網段
8.DNS服務器 DNS尋址 經過寬帶運營商提供的服務器解釋一個域名背後對應的Ip 這個過程過程叫作DNS尋址
幫你完成DNS尋址過程的服務器叫作DNS服務器
9.php中 host文件 操做系統在發起DNS服務器的查詢請求以前,會優先檢查本機的hosts文件,若是這個文件中包含了對當前解析的域名的配置,則再也不發起對DNS服務器的請求,直接使用hosts文件中的配置
windows/system32/drivers/etc/hosts 192.0.0.1 www.baidu.com
本機的hosts文件配置只能影響到本機的DNS尋址
10.端口 每臺計算機只有65536個端口
能夠經過在命令行中運行 netstat -an 命令監聽本機端口使用狀況
http默認的端口 80
https默認的端口 443
11.監聽端口 在httpd.conf文件中 修改 Listen 80
12.網站根目錄 默認根目錄爲:apache/htdocs/
在httpd.conf文件中 修改 DocumentRoot "D:www/"
<Directory "D:www/">
問題1.Forbidden You don't hava permission to access/on this server(全部文件磁盤根目錄/禁止訪問)
<Directory /> (禁止全部'/'下的目錄訪問)
AllowOverride None
Require all denied (禁止全部'/'下的目錄訪問)
</Directory >
修改<Directory "D:www/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted ("D:www/"目錄容許訪問)
</Directory >
13.index.html 爲默認文檔
修改<IfModule dir_module>
DirectoryIndex index.html (能夠改成任意默認文件)
</IfModule>
14.目錄瀏覽 禁止訪問目錄瀏覽
修改<Directory "D:www/">
Options (Indexes )FollowSymLinks (把Indexes去掉)
AllowOverride None
Require all granted
</Directory >
15.虛擬主機 httpd.conf中 Virtual Host
Include conf/extra/httpd-vhosts.conf
httpd-vhosts.conf中 配置虛擬主機
*80 監聽綁定在當前電腦上的任意IP 的80 端口
因爲多個虛擬主機一同工做,每一個虛擬主機必須配置 ServerName
<VirtualHost *:80> (監聽綁定在當前電腦上的任意IP 的80 端口)
ServerAdmin 163@.com
DocumentRoot "d:/www/" 網站根目錄
ServerName www.baidu.com
ServerAlias www.baidu 別名.com
Errorlog "logs/baidu.log"
CustomLog "log/" common
</VirtualHost>
16.清除DNS緩存 瀏覽器中輸入 chrome://chrome-urls-->chrome://net-internals-->DNS
DNS->先找瀏覽器緩存->再找操做系統緩存->再找hosts文件->再找運行商DNS服務器
17.配置多個虛擬主機(添加Directory容許訪問的路徑)
一:
<VirtualHost *:80> (監聽綁定在當前電腦上的任意IP 的80 端口)
ServerAdmin 163@.com
DocumentRoot "d:/www/" 網站根目錄
<Directory "D:www/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted ("D:www/"目錄容許訪問)
</Directory >
ServerName www.baidu.com
ServerAlias www.baidu 別名.com
Errorlog "logs/baidu.log"
CustomLog "log/" common
</VirtualHost>
二:
<VirtualHost *:80> (監聽綁定在當前電腦上的任意IP 的80 端口)
ServerAdmin 163@.com
DocumentRoot "d:/aaa/" 網站根目錄
<Directory "D:aaa/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted ("D:www/"目錄容許訪問)
</Directory >
ServerName www.baidu.com
ServerAlias www.baidu 別名.com
Errorlog "logs/baidu.log"
CustomLog "log/" common
</VirtualHost>
18.Apache 加載php處理模塊
在httpd.conf中加載 以下代碼
LoadModule php7_module(名稱能夠隨便起) c:php/apache2_4.dll
這個模塊不是根據後綴判斷是否 php工做,根據MIME Type 是否是 application/x-httpd-php 決定是否讓php上場
在httpd.conf中載入 MIME type爲application/x-httpd-php的文件 <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-httpd-php .php </IfModule>