配置虛擬目錄
通常我們可以在htdocs下面建立個(gè)文件夾MySite料睛,然后在瀏覽器輸入:http://localhost:8080/MySite 這樣就可以看到我們自己的站點(diǎn)了。然而有時(shí)我們想把站點(diǎn)放到其它目錄下面,這時(shí)就需要配置虛擬目錄了
比如我們?cè)贒盤建立如下文件夾D:\Code\WebSite,然后通過http://localhost:8080/DemoSite來訪問這個(gè)站點(diǎn)
打開httpd.conf文件,搜索<IfModule alias_module> 節(jié)點(diǎn),然后在節(jié)點(diǎn)內(nèi)輸入以下內(nèi)容:
<IfModule alias_module>
ScriptAlias /cgi-bin/ "D:/Program Files/Apache2.2/cgi-bin/"
Alias /DemoSite "D:/Code/WebSite"
<Directory "D:/Code/WebSite">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</IfModule>
注403禁止訪問錯(cuò)誤
修改\xampp\apache\conf\httpd.conf
<Directory />
AllowOverride All
Order deny,allow
Allow from all
</Directory>
xampp中的phpmyAdmin的配置在
xampp\apache\conf\extra\httpd-xampp.conf
中
多主機(jī)頭綁定
(就是在一個(gè)端口上綁定多個(gè)域名残邀,然后每個(gè)域名可以指向不同的目錄進(jìn)行訪問,主機(jī)頭是IIS里面的說法),打開httpd.conf文件,在文件最后添加如下內(nèi)容
多主機(jī)頭配置無需放在特定的節(jié)點(diǎn)下面,一般直接在配置文件底部添加即可
NameVirtualHost addr[:port] 為一個(gè)基于域名的虛擬主機(jī)指定一個(gè)IP地址(和端口),聲明主機(jī)頭必須加這條指令,否者主機(jī)頭配置不會(huì)生效,VirtualHost節(jié)點(diǎn)下面ServerName就是要綁定的域名,DocumentRoot表示此域名指向的目錄
本機(jī)測試的話請(qǐng)?jiān)趆osts中進(jìn)行域名綁定如 127.0.0.1 www.mysite1.com
NameVirtualHost *:8080
<VirtualHost *:8080>
ServerName www.mysite1.com
DocumentRoot "D:\Program Files\Apache2.2\htdocs"
</VirtualHost>
<VirtualHost *:8080>
ServerName www.mysite2.com
DocumentRoot "D:\Code\MySite"
</VirtualHost>
配置好后历恐,重啟apache服務(wù)弱贼,瀏覽器輸入www.mysite1.com:8080吮旅,就會(huì)自動(dòng)定向到D:\Program Files\Apache2.2\htdocs站點(diǎn)了
不同端口訪問不同網(wǎng)站
如果你想實(shí)現(xiàn)不同端口(http://localhost:8080/、http://localhost:8081/)訪問不同網(wǎng)站捺檬,
httpd.conf
最下添加如下
<virtualhost *:8080>
ServerName localhost
DocumentRoot D:/xampp/htdocs/dedecms_test
</virtualhost>
# dedecms_test #
<virtualhost *:8081>
ServerName localhost
DocumentRoot D:/xampp/htdocs/dedecms_test
</virtualhost>
https配置
https://my.oschina.net/u/265943/blog/115401
發(fā)現(xiàn)運(yùn)行起來證書出錯(cuò)
···
openssl genrsa 4096 -des3 > server.key
openssl req -new -key server.key > server.csr
openssl req -x509 -days 365 -key server.key -in server.csr >server.crt
···
···
C:\xampp\apache\bin>openssl genrsa 4096 -des3 > server.key
Generating RSA private key, 4096 bit long modulus
.......................++
..................................................++
e is 65537 (0x10001)
C:\xampp\apache\bin>openssl req -new -key server.key > server.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [AU]:zn
State or Province Name (full name) [Some-State]:anhui
Locality Name (eg, city) []:hefei
Organization Name (eg, company) [Internet Widgits Pty Ltd]:p2
Organizational Unit Name (eg, section) []:p2
Common Name (e.g. server FQDN or YOUR name) []:kedou.com
Email Address []:prou@qq.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
C:\xampp\apache\bin>openssl req -x509 -days 365 -key server.key -in server.csr >server.crt
C:\xampp\apache\bin>
···