Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zf2 setup on ubuntu 13.10 with Apache virtual host

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?

like image 752
Abdul Rauf Avatar asked Feb 20 '14 10:02

Abdul Rauf


People also ask

Where is Httpd Vhosts conf in Ubuntu?

On Ubuntu systems, Apache Virtual Hosts configuration files are located in /etc/apache2/sites-available directory. They can be enabled by creating symbolic links to the /etc/apache2/sites-enabled directory, which Apache read during the startup.

What is Virtual Host in Ubuntu?

The term “Virtual Hosting” refers to the hosting of many domains on a single server. In Linux-based systems such as Ubuntu 22.04, a Virtual Host is a configuration directive in Apache that permits you to operate several websites on a single server.


2 Answers

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

like image 77
Abdul Rauf Avatar answered Sep 28 '22 18:09

Abdul Rauf


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

Maybe a problem of url rewriting :

Did you enable mod_rewrite ?

Did you set AllowOverride All ?

like image 22
jmleroux Avatar answered Sep 28 '22 18:09

jmleroux