簡體   English   中英

在端口80上托管多個網站

[英]Host multiple web sites on port 80

因此,我可能對這里發生的事情缺少一些基本的了解,但是我無法使它起作用。 我有兩個django網站,我希望能夠將它們都托管在同一個盒子上,都在端口80上。是否有使它正常工作的魔力? 這是我的網站可用/默認文件如下所示:

<VirtualHost *:80>
    WSGIScriptAlias / /path/to/proj/apache/django.wsgi
    AliasMatch ^/([^/]*\.css) /path/to/proj/static/
    Alias /media /path/to/proj/static/
    Alias /static/ /path/to/proj/static/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
    WSGIScriptAlias / /path/to/otherproj/apache/django.wsgi

    ErrorLog ${APACHE_LOG_DIR}/error2.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

顯然,這是行不通的,因為導航到該站點會遇到第一個站點,而永遠不會到達第二個站點。 所以我的問題是,如何設置它以便可以在端口80上托管2個網站。也許我可以像localhost / site1和localhost / site2那樣進行處理,但無論如何我都可以似乎無法解決這個問題。

我已經使用過ServerName屬性,但是我不太了解它是如何工作的,設置它似乎並沒有改變點擊那台計算機的ip僅顯示第一個網站,並且我不知道在哪里使用ServerName會影響任何事情。

有任何建議,或者讓我知道是否需要提供更多信息。

還要注意,如果我將第二個更改為端口8080,它們都可以工作,但是這樣做時,似乎無法在myip:8080上放一個域名。

我認為這里沒有什么要解釋的。 您只需要實際指定每個虛擬域的名稱即可。

注意: 不建議使用NameVirtualHost

<VirtualHost *:80>
    ServerName site1.ltd
    WSGIScriptAlias / /path/to/proj/apache/django.wsgi
    AliasMatch ^/([^/]*\.css) /path/to/proj/static/
    Alias /media /path/to/proj/static/
    Alias /static/ /path/to/proj/static/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerName site2.ltd
    WSGIScriptAlias / /path/to/otherproj/apache/django.wsgi

    ErrorLog ${APACHE_LOG_DIR}/error2.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM