20

I'm trying to make an alias on my server which directs all traffic that comes into example.com/z/ to a different directory than the rest of example.com, where example.com has a Laravel 4.2 install and example.com/z/ has a Lumen install which runs a service.

This is my original vhost:

<VirtualHost *:80>
 ServerName example.com
 DocumentRoot /data/user/public_html/public
 <Directory /data/user/public_html/public>
  Options +FollowSymlinks
  AllowOverride All
 </Directory>
</VirtualHost>

And this is the vhost with the /z/ alias added in:

 <VirtualHost *:80>
  ServerName example.com
  DocumentRoot /data/user/public_html/public
  Alias /z/ /data/user/service/public
  <Directory /data/user/service/public>
   Options +FollowSymlinks
   AllowOverride All
  </Directory>
  <Directory /data/user/public_html/public>
   Options +FollowSymlinks
   AllowOverride All
  </Directory>
 </VirtualHost>

When a navigate to exmaple.com/z/ I get a 403 page and in the logs this error:

 Directory index forbidden by Options directive: /data/user/service/public

And if I go to anything else under /z/ (example: /z/abcd) I get a 404 page, but it looks like the Laravel 404 page instead of the Lumen 404 page.

Any ideas on how I can get this working?

Samsquanch
  • 8,866
  • 12
  • 50
  • 89

3 Answers3

15

The message is telling you didn't added the option Indexes

<Directory /data/user/service/public>
   Options +FollowSymlinks +Indexes
   AllowOverride All
</Directory>

Your alias probably will have to be

Alias /z /data/user/service/public

or

Alias /z/ /data/user/service/public/
Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
  • When I add this I get the directory listing (in my case index.php and test.php). Trying to navigate to either of these files results in a 404 page. – Samsquanch Apr 29 '15 at 17:18
  • `script '/data/user/service/publicindex.php' not found or unable to stat, referer: http://example.com/z/` – Samsquanch Apr 29 '15 at 17:24
  • Note that it is merging it `/.../publicindex.php` and it should be `/data/user/service/public/index.php` – Antonio Carlos Ribeiro Apr 29 '15 at 17:26
  • I was thinking that was the issue and changed it accordingly, which both got rid of the directory listing and made navigating to `test.php` work. Now I'm running into the issue of `example.com/z/` is returning a 404 from what looks like Lumen, but `example.com/z/test` (a route which is set up to just return 'test') is 404ing in what looks to be Laravel. Ideas on what's going on now? This is similar behavior to what I was running into originally with no trailing slash on the alias. – Samsquanch Apr 29 '15 at 17:29
  • It's also worth noting that I've tried both variations of the alias you posted (both with and without trailing slash) with the same result either way. – Samsquanch Apr 29 '15 at 17:31
  • Both `/z/index.php` and `/z/index.php/test` 404. But `/z/test.php` (a separate file in the public directory) works. – Samsquanch Apr 29 '15 at 17:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/76567/discussion-between-antonio-carlos-ribeiro-and-samsquanch). – Antonio Carlos Ribeiro Apr 29 '15 at 17:35
  • `AllowOverride All` is what I was missing that made the difference. – site May 25 '21 at 20:11
1

Directory index forbidden by Options directive: /data/user/service/public

Apache has not found file specified by DirectoryIndex - default to index.php index.html and cannot show indexes follow you're configuration Are you sure there is one of this files present in /data/user/service/public ?

Be sure of this and add and .htaccess into you're public directory

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

from http://lumen.laravel.com/docs/installation#pretty-urls

or add a directory block to parent level (if there is some symb link)

  <Directory /data/user>
        Options -Indexes FollowSymLinks
        AllowOverride all
        Order Allow,Deny
        Allow from all
    </Directory>
bastien
  • 190
  • 1
  • 9
1

Untested, but adding Require all granted should remove some of the sharing restrictions.

The other thing to consider is ensuring your folder is actually owned by Apache's owner (www-data, apache, or even your username or something else depending on your installation). If the folder can't be read by Apache, it will trigger an error.

I also switched the Directory to refer to the Alias rather than the file path.

 <VirtualHost *:80>
  ServerName example.com
  DocumentRoot /data/user/public_html/public
  Alias /z /data/user/service/public
  <Directory /z>
   Options +FollowSymlinks +Indexes
   AllowOverride All
   Require all granted
  </Directory>
  <Directory /data/user/public_html/public>
   Options +FollowSymlinks
   AllowOverride All
  </Directory>
 </VirtualHost>
smcjones
  • 5,490
  • 1
  • 23
  • 39