BanjoSf4
BanjoSf4

Reputation: 149

Deploy Symfony 4 project on OVH

I'm trying to deploy my site created with Symfony 4 on OVH. I have my two .htaccess files (1 at the root in the www folder where my code is and the other in my public folder) :

RewriteEngine on
RewriteBase /

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L] `

and in my public folder :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

and yet I have a 404 error that appears when I try to access my site.

Does anyone have any idea where the problem may come from?

Upvotes: 1

Views: 1280

Answers (1)

Rmy5
Rmy5

Reputation: 577

OVH is your hosting service, it does not give us any information about your server's config and installs. Do you use Nginx or Apache ? PHP FPM or PHP CGI ?

Since you are using .htaccess files I'm assuming you have Apache installed.

Symfony has a recipe for installing the proper rewrite rules to run on Apache. You can run it by executing the following command : composer require symfony/apache-pack

Depending on your PHP install (CGI or FPM) there are different configurations for running Symfony on Apache. For PHP-CGI:

<VirtualHost *:80>
    ServerName domain.tld
    ServerAlias www.domain.tld

    DocumentRoot /var/www/project/public
    <Directory /var/www/project/public>
        AllowOverride All
        Order Allow,Deny
        Allow from All
    </Directory>

    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeeScript assets
    # <Directory /var/www/project>
    #     Options FollowSymlinks
    # </Directory>

    ErrorLog /var/log/apache2/project_error.log
    CustomLog /var/log/apache2/project_access.log combined
</VirtualHost>

All these informations can be found in the official documentation: Symfony Web Server Configuration

Upvotes: 2

Related Questions