2014-01-07 53 views
1

我希望能夠在有兩個不同的文檔根同一個VAR/WWW文件夾和其它一些其他folder.Below是可用網站我的默認文件中的兩個端口上運行的Apache。但是,無論何時我點擊127.0.0.1,第一個虛擬主機中的索引都會顯示出來。 我希望能夠訪問/ home/somefolder/tmp中的索引,如果我點擊127.0.0.1:8080 url,但是我卻得到「瀏覽器無法連接到127.0.0.1:8080」。我錯過了什麼?的Apache2不工作的不同端口

<VirtualHost *:80> 
ServerAdmin [email protected] 

DocumentRoot /var/www 
<Directory /> 
    Options FollowSymLinks 
    AllowOverride None 
</Directory> 
<Directory /var/www/> 
    Options Indexes FollowSymLinks MultiViews 
    AllowOverride None 
    Order allow,deny 
    allow from all 
</Directory> 

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
<Directory "/usr/lib/cgi-bin"> 
    AllowOverride None 
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
    Order allow,deny 
    Allow from all 
</Directory> 

ErrorLog ${APACHE_LOG_DIR}/error.log 

# Possible values include: debug, info, notice, warn, error, crit, 
# alert, emerg. 
LogLevel warn 

CustomLog ${APACHE_LOG_DIR}/access.log combined 

Alias /doc/ "/usr/share/doc/" 
<Directory "/usr/share/doc/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride None 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.0/255.0.0.0 ::1/128 
</Directory> 

</VirtualHost> 
<VirtualHost *:8080> 
    ServerAdmin [email protected] 

    DocumentRoot /home/somefolder/tmp 
    <Directory /> 
      Options FollowSymLinks 
      AllowOverride None 
    </Directory> 
    <Directory /var/www/> 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride None 
      Order allow,deny 
      allow from all 
    </Directory> 

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
    <Directory "/usr/lib/cgi-bin"> 
      AllowOverride None 
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch 
      Order allow,deny 
      Allow from all 
    </Directory> 

    ErrorLog ${APACHE_LOG_DIR}/error.log 

    # Possible values include: debug, info, notice, warn, error, crit, 
    # alert, emerg. 
    LogLevel warn 

    CustomLog ${APACHE_LOG_DIR}/access.log combined 

Alias /doc/ "/usr/share/doc/" 
<Directory "/usr/share/doc/"> 
    Options Indexes MultiViews FollowSymLinks 
    AllowOverride None 
    Order deny,allow 
    Deny from all 
    Allow from 127.0.0.0/255.0.0.0 ::1/128 
</Directory> 

回答

3

你需要確保Apache是​​設置爲監聽8080端口,因此你需要

Listen 8080 

NameVirtualHost *:8080 

在主配置集,這將從發行版到發行版有所不同。

您可以檢查哪些端口Apache正在監聽使用以下命令:

sudo netstat -ntlp | egrep 'apache|httpd' 

聽起來像是你將看到80在那裏,但沒有8080

+0

沒想好+10 –

+0

感謝這個工作我的機器上,但在遠程機器這didnt工作。它給我下面的錯誤的「您沒有權限訪問/在此服務器上。」 – nnm

+0

我在上面的NameVirtualHost上輸入了一個錯字,現在已更正爲8080.您的錯誤聽起來像是缺少默認文檔或您的文檔根目錄不存在。檢查你遇到問題的根目錄的配置。 – arco444

0

試試這個,

Listen 80 
Listen 8080 

NameVirtualHost 127.0.0.1:80 
NameVirtualHost 127.0.0.1:8080 

<VirtualHost 127.0.0.1:80> 
#ServerName eightzero.com 
DocumentRoot /var/www/ 
</VirtualHost> 

<VirtualHost 127.0.0.1:8080> 
#ServerName eightzeroeightzero.com 
DocumentRoot /var/www-8080 
</VirtualHost> 

我希望這會幫助你。嘗試在使用apache conf文件進行更改後,提示重新啓動/重新加載httpd/apache2。 :)