Isaac Pak
Isaac Pak

Reputation: 4981

Symfony app 403 Forbidden error: You don't have permission to access / on this server

I'm trying to run a symfony app on a CentOS7 linode server, but I'm getting an error:

Cannot serve directory <path to project>: No matching DirectoryIndex (index.html, index.php) 

I have a vhost setup for this subdomain with this config:

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName mister
     ServerAlias project.mystuff.com
     DocumentRoot /var/www/html/project
     ErrorLog /var/www/html/project/logs/error.log
     CustomLog /var/www/html/project/logs/access.log combined
     <Directory "/var/www/html/project" >
         #Options FollowSymLinks
         Options -Indexes
         AllowOverride All
         Require all granted
     </Directory>
</VirtualHost>

My current settings are:
1) My webserver user and group is apache
2) My permissions to the /var/www/html/project are 755 with apache:apache

I've tried the following suggestions on the internet to no avail:

1) Changed Options -Indexes to Options +Indexes
2) Added DirectoryIndex index.html
3) I get server errors if I change root ownership of /var

Upvotes: 6

Views: 24543

Answers (2)

Stephane Lefebvre
Stephane Lefebvre

Reputation: 1

Based on your Apache configuration, it appears you're trying to serve your Symfony project from /var/www/html/project. However, by convention, Symfony applications should be served from the public directory located within the root of your Symfony project. Trying to serve from the root directory could cause issues, such as a 403 error. Could you confirm whether your DocumentRoot is set to the root directory of your Symfony project or the public directory within it? If it's set to the root directory, changing the DocumentRoot to the public directory might solve your problem

Upvotes: 0

Alvin Bunk
Alvin Bunk

Reputation: 7764

I'm using CentOS 6 and Apache. Try this change:

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName mister
     ServerAlias project.mystuff.com
     DocumentRoot /var/www/html/project/web
     ErrorLog /var/www/html/project/var/logs/error.log
     CustomLog /var/www/html/project/var/logs/access.log combined
     <Directory "/var/www/html/project/web" >
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Require all granted
     </Directory>
</VirtualHost>

Also verify you can use wget or curl to get your Symfony index.html page on the localhost. CentOS might have enabled SELinux or even iptables.

Use sestatus to see if it is set to enforcing - if so you need to allow web or disable SELinux temporarily.

xabbuh is correct. The "web" directory is the folder you need to use as your web root. If updated my post to reflect the changes needed.

Upvotes: 5

Related Questions