2012-08-24 112 views
1

Zend框架對我來說是新的,我正在從一本書開始工作,所以我可以基本掌握一些東西(本書是Zend Framework初學者指南)。服務器設置的項目與虛擬主機配置

我有我的項目設置和有一個名爲「測試」

我還添加了一個虛擬主機文件夾中創建它,虛擬主機文件包含:

<VirtualHost *:80> 
    DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public" 
    ServerName .localtest 

    # This should be omitted in the production environment 
    SetEnv APPLICATION_ENV development 

    <Directory "C:/Program Files/Zend/Apache2/htdocs/test/public"> 
     DirectoryIndex index.php 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 

</VirtualHost> 

我已要求從虛擬主機文件內阿帕奇的conf文件

我還添加了一行到SYSTEM32 hosts文件:

127.0.0.1 test.localtest 

我的問題是,當我瀏覽到http://test.localtest/我得到了Zend服務器測試頁,當從我正在讀我應該得到的Zend框架項目主頁飛濺,這是我可以通過瀏覽http://test.localtest/test/public/

上午到達我錯過了什麼?

回答

2

嘗試改變

<VirtualHost *:80> 
    DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public" 
    ServerName .localtest 

<VirtualHost *:80> 
    DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public" 
    ServerName test.localtest 

編輯

好吧,我必須檢查我的系統上,它完美地工作,但我使用Ubuntu希望這有助於

編輯這個文件
C:\Program Files\Zend\Apache2\conf (Zend Server on Windows machines) 

,並添加該代碼

<VirtualHost *:80> 
    ServerName test.localtest 
    DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/test/public" 

    SetEnv APPLICATION_ENV "development" 

    <Directory "C:/Program Files/Zend/Apache2/htdocs/test/public"> 
     DirectoryIndex index.php 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

然後編輯這個文件

C:\WINDOWS\system32\drivers\etc\hosts 

,並添加此行

127.0.0.1 test.localtest 

,然後不要忘記您重新啓動Apache服務器( wamp或者xampp或者你正在使用的任何東西)

,然後打開此鏈接

http://test.localtest 

嘗試編寫與http://的URL有時瀏覽器不無http://

工作嘗試,如果它不工作

+0

感謝您的答覆,但只是給了我Zend服務器測試頁相同的結果..: ( – MartinJJ

+0

@ user1117324我已經編輯了C:\ WINDOWS \ system32 \ drivers \ etc到C:\ WINDOWS \ system32 \ drivers \ etc \ hosts的答案,C:\ WINDOWS \ system32 \ drivers \ etc是一個目錄。 – Karma

2

一件事發表評論最大家都錯過了Zf需要FollowSymlinks來工作大部分時間。

這是目錄定義我通常在我的虛擬主機

<directory "C:\www\project"> 
    Options Indexes FollowSymlinks 
    AllowOverride all 
    Order Deny,Allow 
    Allow from all 
</directory> 

不知道的DirectoryIndex將如何影響這個使用。

確保mod_rewrite的Apache中啓用:

LoadModule rewrite_module modules/mod_rewrite.so //make sure this line is uncommented httpd.conf 

使虛擬主機在Apache中啓用:

Include conf/extra/httpd-vhosts.conf //make sure this line is uncommented httpd.conf 

確保這條線是出現在你的虛擬主機文件通常高於虛擬主機的定義:

NameVirtualHost *:80 
+0

我錯過了vhosts文件中的這行代碼NameVirtualHost *:80非常感謝:) – MartinJJ