Search code examples
phpapachepermissionssymfony

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 pak11273@gmail.com
     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


Solution

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

    <VirtualHost *:80>
         ServerAdmin pak11273@gmail.com
         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.