2011-05-01 50 views
0

我創建了一個項目學生/var/www/但我無法使用虛擬熱點訪問它。如何在瀏覽器中訪問我的zend項目?

zf.sh create prohect student 

我創建了一個文件學生的/ etc/apache2的 /站點可用這樣的:

<VirtualHost *:80> 
     ServerName student.dev 
     ServerAlias student.dev 
     DocumentRoot /var/www/student/public/ 
</VirtualHost> 

然後我在終端運行以下命令:

sudo a2ensite student 

我在/etc/hosts中有以下行

127.0.0.1 student.dev 

後,我重新啓動Apache服務器:

sudo /etc/init.d/apache2 restart 

但是,當我在瀏覽器中訪問http://student.dev/它給了我以下錯誤:

The server encountered an internal error or misconfiguration and was unable to complete your request. 

但是,當我訪問http://localhost/student/public/index.php直接就說明我歡迎成功如此

Welcome to the Zend Framework! 
This is your project's main page 

編輯:

.htaccess文件公用文件夾中

SetEnv APPLICATION_ENV development 

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L] 

回答

1

你錯過了你的虛擬主機配置的<Directory>配置。

你的配置有像她那樣:

<VirtualHost *:80> 
    ServerName student.dev 
    DocumentRoot /var/www/student/public/ 
    <Directory /var/www/student/public/> 
     AllowOverride All 
    </Directory> 
</VirtualHost> 

AllowOverride設置告訴apache .htaccess文件在您的公共目錄可能會覆蓋常規設置。

+0

我試過這個,但同樣的錯誤。我在上面的問題中添加了我的**。htaccess **文件內容.. – Awan 2011-05-01 10:27:30

+0

Apache mod_rewrite是否已安裝,已配置並處於活動狀態? – markus 2011-05-01 11:03:58

+0

非常感謝..我用'sudo a2enmod rewrite'啓用它,它現在正在與您的上述解決方案一起工作。再次感謝.... – Awan 2011-05-01 11:20:13

相關問題