Zend Framework 1 apache2 vhost configuration

919 Views Asked by At

Today I uploaded my Zend Framework 1 web project to my web server (debian) with apache2 running on it.

I developed the project on a mac with XAMPP. I copied the configuration to the vhost and .htaccess-file.

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 (in 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]

This is what I got from many different sources and after searching for hours this worked for my local development environment. When I open the website, I can see the start page. But controller calls do not work (except the index controller). I always get the error "Not Found".

In /etc/apache2/ports.conf I added

NameVirtualHost *:80

Of course I've added the website via a2ensite and restarted the apache2 web server. Can someone help me please?

1

There are 1 best solutions below

1
On

So after recognizing that the .htaccess is not even working (by simply setting a redirect to any domain) I found the solution:

Open /etc/apache2/apache2.conf and edit the directory setting for /var/www as following:

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

Restart apache

service apache2 reload

I'm not sure if this is a good solution, but for me it works.