簡體   English   中英

Zend Framework 1 apache2 vhost 配置

[英]Zend Framework 1 apache2 vhost configuration

今天我將我的 Zend Framework 1 web 項目上傳到我的 web 服務器(debian),上面運行着 apache2。

我用 XAMPP 在 Mac 上開發了這個項目。 我將配置復制到 vhost 和 .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 服務器。 有人能幫助我嗎?

因此,在認識到 .htaccess 甚至不起作用(通過簡單地設置重定向到任何域)后,我找到了解決方案:

打開 /etc/apache2/apache2.conf 並編輯 /var/www 的目錄設置,如下所示:

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

重啟apache

service apache2 reload

我不確定這是否是一個好的解決方案,但對我來說它有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM