2015-06-22 117 views
2

今天我上傳了我的Zend框架1個Web項目到我的網絡服務器(Debian的)與在其上運行的Apache2。Zend框架1周的Apache2虛擬主機配置

我開發與XAMPP Mac上的項目。 我複製的配置,虛擬主機和的.htaccess文件。

vhost (/etc/apache2/sites-available/***.***.de.conf)

<VirtualHost *:80> 
# The ServerName directive sets the request scheme, hostname and port that 
# the server uses to identify itself. This is used when creating 
# redirection URLs. In the context of virtual hosts, the ServerName 
# specifies what hostname must appear in the request's Host: header to 
# match this virtual host. For the default virtual host (this file) this 
# value is not decisive as it is used as a last resort host regardless. 
# However, you must set it for any further virtual host explicitly. 
ServerName ****.****.de 

ServerAdmin ******@******.com 
DocumentRoot /var/www/****.****.de/public_html 

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
# error, crit, alert, emerg. 
# It is also possible to configure the loglevel for particular 
# modules, e.g. 
#LogLevel info ssl:warn 

ErrorLog ${APACHE_LOG_DIR}/error.log 
CustomLog ${APACHE_LOG_DIR}/access.log combined 

# For most configuration files from conf-available/, which are 
# enabled or disabled at a global level, it is possible to 
# include a line for only one particular virtual host. For example the 
# following line enables the CGI configuration for this host only 
# after it has been globally disabled with "a2disconf". 
#Include conf-available/serve-cgi-bin.conf 
SetEnv APPLICATION_ENV "development" 
<Directory /var/www/****.****.de/public_html> 
    DirectoryIndex index.php 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
</Directory> 

的.htaccess(中的public_html)

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

這是我從許多不同來源和搜索時間這個工作對我的本地開發環境之後得到。當我打開網站時,我可以看到開始頁面。但是控制器調用不起作用(索引控制器除外)。我總是得到錯誤「未找到」。

在/etc/apache2/ports.conf我加

NameVirtualHost *:80 

當然,我已經通過a2ensite添加的網站,並重新啓動的Apache2 web服務器。 有人可以幫我嗎?

+0

檢查重寫模塊在Apache中啓用('大概a2enmod rewrite'),並重新啓動再 – rjdown

+0

我沒有檢查這一點,但能夠重寫模塊後,仍不能正常工作(同樣的錯誤與以前一樣)。 – hapablap

+0

OK,現在我試圖以測試的.htaccess甚至工作,並增加了一個永久重定向(重寫規則* HTTP://www.neuedomain.tld/ [L,R = 301]),但它不工作。所以似乎.htaccess甚至沒有被使用? – hapablap

回答

1

因此認識到的.htaccess甚至沒有工作(通過簡單地設置一個重定向到任何域)我找到了解決辦法後:

打開/etc/apache2/apache2.conf中和編輯目錄設置/ VAR/WWW如下:

<Directory /var/www/> 
    Options Indexes FollowSymLinks 
    AllowOverride All 
    Require all granted 
</Directory> 

重新啓動Apache

service apache2 reload 

我不知道這是否是一個很好的解決方案,但對我來說它的工作原理。

+0

這是有道理的,如果你的Apache的版本爲> = 2.4,說明「訂單允許,拒絕」和「從所有允許」是無用的。從這個版本開始,你必須使用「要求所有授予」或「要求本地」,或者你想授予的任何東西,使其工作。不錯的工作,但發現這一點! –