I am configuring Zend application (ZF2) in ubuntu 13.10. Following the steps below :
/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>
Creating virtual host for it in /etc/hosts
127.0.0.1 zfapp.com
Add file in /etc/apache2/sites-available/zfapp.cof
sudo a2enmod rewrite
sudo a2ensite zfapp.conf
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/authwas 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?
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.
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.
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
Without code, it's hard to diagnose...
Maybe a problem of url rewriting :
Did you enable mod_rewrite ?
Did you set AllowOverride All ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With