2012-06-13 47 views
3

我試圖在localhost上設置一個虛擬主機。我在我的Ubuntu 12.04 LTS上安裝了symfony 1.4,但是我遇到了一些問題。apache2和virtualhost的問題

我安裝了apache2,php5和mySql。本地主機的作品,所以我認爲阿帕奇沒關係。

你可以找到symfony的安裝和配置說明here

幾天後,這是我的配置文件:

的http.conf:

ServerName 127.0.0.1 

的/ etc/apache2的/網站可用/測試:

# Be sure to only have this line once in your configuration 
NameVirtualHost 127.0.0.1:8080 

# This is the configuration for your project 
Listen 127.0.0.1:8080 

<VirtualHost 127.0.0.1:8080> 
    DocumentRoot "/home/user/test/web" 
    DirectoryIndex index.php 
    <Directory "/home/user/test/web"> 
    AllowOverride All 
    Allow from All 
    </Directory> 

    Alias /sf /home/user/test/lib/vendor/symfony/data/web/sf 
    <Directory "/home/user/test/lib/vendor/symfony/data/web/sf"> 
    AllowOverride All 
    Allow from All 
    </Directory> 
</VirtualHost> 

和本地主機:8080不起作用。

UPDATE: 好吧,經過多次修改,我的httpd.conf是一樣的:

ServerName 127.0.0.1 

而且我的/ etc/apache2的/網站可用/測試:

Listen 127.0.0.1:80 

<VirtualHost 127.0.0.1:80> 
    DocumentRoot "/home/user/test/web" 
    DirectoryIndex index.php 
    <Directory "/home/user/test/web"> 
    AllowOverride All 
    Allow from All 
    </Directory> 

    Alias /sf /home/user/test/lib/vendor/symfony/data/web/sf 
    <Directory "/home/user/test/lib/vendor/symfony/data/web/sf"> 
    AllowOverride All 
    Allow from All 
    </Directory> 
</VirtualHost> 
+0

是否在端口80或8080的運行Apache? (檢查'ports.conf') – j0k

+0

你有沒有嘗試給所有目錄的物理路徑?其他人似乎沒問題。 – qais

+0

@ j0k我在端口80上運行Apache。'NameVirtualHost *:80 Listen 80' – jhrs21

回答

0

確認你有您的網站測試成/etc/apache2/sites-enabled/。如果不這樣做:

sudo a2ensite test 

該命令將啓用該網站test。記得重新啓動apache。

+0

是的,這是相同的 – jhrs21

1

如果Apache使用端口80,刪除此行中你的conf:

NameVirtualHost 127.0.0.1:8080 

然後通過80全部更換8080和嘗試http://localhost。它應該工作。

編輯:

關於錯誤could not bind to address 127.0.0.1:80 no listening sockets available,看來你有其他的服務器偵聽端口80

也許這是一個更好的主意,回來的8080端口(在httpd.conf ),然後更新ports.conf設置:

NameVirtualHost *:8080 
Listen 8080 

如果你沒有一個ports.conf文件中,找到Listen你主要配置文件並進行更新。

+0

每一個變化之後,我必須到我的網站添加到與合作命令a2ensite? – jhrs21

+0

不,但您需要重新啓動Apache。 – j0k

+0

好吧,我只注意到兩者都是相同的文件。現在,當我重新啓動我的apache時,我收到了以下消息:「Restarting web server apache2 [Sat Jun 16 12:31:00 2012] [warn] NameVirtualHost *:80 has no VirtualHosts [Sat Jun 16 12:31:00 2012] [警告] NameVirtualHost *:80沒有VirtualHosts(98)地址已經在使用:make_sock:無法綁定到地址127.0.0.1:80 沒有監聽套接字可用,關閉 無法打開日誌 行動'開始'失敗 Apache錯誤日誌可能有更多的信息。 「 – jhrs21

0

錯誤消息。

(98)地址已在使用:make_sock:無法綁定解決127.0.0.1:80沒有聽插座可用,關停無法打開日誌

它可以通過註釋掉Listen 80行,來解決在你的httpd.conf文件中。

問候 拉哈基倫