Question

I am configuring Zend application (ZF2) in ubuntu 13.10. Following the steps below :

  1. Place code in /var/www/ with name zfapp

Virtual host config :

 <VirtualHost *:80> 
  ServerName zfapp.com DocumentRoot /var/www/zfapp/ 

  <Directory /> 
    Options FollowSymLinks 
    AllowOverride All 
  </Directory> 

  ErrorLog /var/log/apache2/error.log 

   # Possible values include: debug, info, notice, warn, error, crit, 
   # alert, emerg. 
   LogLevel warn 
   CustomLog /var/log/apache2/access.log combined 

</VirtualHost>
  1. Creating virtual host for it in /etc/hosts

    127.0.0.1 zfapp.com

  2. Add file in /etc/apache2/sites-available/zfapp.cof

  3. sudo a2enmod rewrite

  4. sudo a2ensite zfapp.conf

  5. sudo service apache2 restart

However when I browse to the site (zfapp.com/api/user/auth); It gives following error:

Not Found The requested Url /api/user/auth was not found on this server

I have a javascript MVC project in which i am using PHP as server side language.

Here is the project directory structure:

ProjectDir javascriptMVC folder-> models/controllers jsfiles api folder -> Zend project

I have made a symbolic link api which points to api/public inside javascriptMVC directory, which i use in AJAX calls to PHP server. like /api/user/auth. The same structure works on old Ubuntu machine.

I think it has something to do with Apache configuration; or perhaps I have to set any Alias?

Was it helpful?

Solution

Thanks all,

I have found the problem.

In apache 2.4.6 and ubuntu 13.10 we need to update apache2.conf change in

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

with

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

and create your virtual host file something like this,

<VirtualHost zfapp.com:80>
    ServerName zfapp.com

    DocumentRoot /var/www/zfapp/index

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

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined
</VirtualHost>

I have found solution from: https://askubuntu.com/questions/423514/how-to-enable-mod-rewrite-for-virtual-host

by the way, thanks @Bilal , @jmleroux

OTHER TIPS

Without code, it's hard to diagnose...

Maybe a problem of url rewriting :

Did you enable mod_rewrite ?

Did you set AllowOverride All ?

@Bilal probably means your ZF2 routing configuration: http://framework.zend.com/manual/2.0/en/modules/zend.mvc.routing.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top