apache 配置 虛擬目錄 ssh

配置虛擬目錄

通常我們可以在htdocs下面建立個文件夾MySite,然后在瀏覽器輸入:http://localhost:8080/MySite 這樣就可以看到我們自己的站點了。然而有時我們想把站點放到其它目錄下面,這時就需要配置虛擬目錄了
比如我們在D盤建立如下文件夾D:\Code\WebSite,然后通過http://localhost:8080/DemoSite來訪問這個站點

打開httpd.conf文件,搜索<IfModule alias_module> 節(jié)點,然后在節(jié)點內輸入以下內容:

<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禁止訪問錯誤
修改\xampp\apache\conf\httpd.conf

<Directory />
     AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

xampp中的phpmyAdmin的配置在
xampp\apache\conf\extra\httpd-xampp.conf

多主機頭綁定

(就是在一個端口上綁定多個域名,然后每個域名可以指向不同的目錄進行訪問,主機頭是IIS里面的說法),打開httpd.conf文件,在文件最后添加如下內容

多主機頭配置無需放在特定的節(jié)點下面,一般直接在配置文件底部添加即可
NameVirtualHost addr[:port] 為一個基于域名的虛擬主機指定一個IP地址(和端口),聲明主機頭必須加這條指令,否者主機頭配置不會生效,VirtualHost節(jié)點下面ServerName就是要綁定的域名,DocumentRoot表示此域名指向的目錄
本機測試的話請在hosts中進行域名綁定如 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服務,瀏覽器輸入www.mysite1.com:8080,就會自動定向到D:\Program Files\Apache2.2\htdocs站點了

不同端口訪問不同網(wǎng)站

如果你想實現(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)運行起來證書出錯
···
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>
···

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容