0

After Symfony 4 deployment, I have several errors. Only home page working, when trying to navigate to another page, web server returns 404, database connection has extrage behaviour, does not connect to the database... all is working properly in dev environment, but when I chage to PROD, all fails. In the server, enabling local symfony application server in port 8000, all works fine in dev environment. I have followed all steps in https://symfony.com/doc/current/deployment.html but I'm unable to make the application works fine in PROD.

Please, help

BR

2
  • Check your symfony log files, there should be come clues there.
    – ehymel
    Jul 6, 2019 at 18:59
  • Nothing there.... Jul 7, 2019 at 17:47

2 Answers 2

1

It is because you are missing rewrite rules .htaccess file, here is working solution tested:

in your project directory run, this will create .htaccess in project dir for you

sudo composer require symfony/apache-pack

then modify/add your virtual host directive in your apache virtual config file.

for Windows Xampp it is here -> C:\xampp\apache\conf\extra\httpd-vhosts.conf


for Linux default Ubuntu it is here -> /etc/apache2/sites-enabled/yoursite.conf

here is how it looks like on Windows Xampp

<VirtualHost 127.0.0.1:80>
DocumentRoot "C:\xampp\htdocs\final\public"
DirectoryIndex index.php

<Directory "C:\xampp\htdocs\project\public">
    #AllowOverride All # for older version of apache less than 2.4
    #Order Allow,Deny # for older version of apache less than 2.4
    #All from All # for older version of apache less than 2.4
    Require all granted
</Directory>
</VirtualHost>

here is how it looks like on Linux

<VirtualHost *:80>
ServerName company.com
DocumentRoot /var/www/company.com/web

<Directory /var/www/company.com/web>
    Options Indexes FollowSymlinks
    AllowOverride All

    # Use these 2 lines for Apache 2.3 and below
    ##Order allow,deny
    ##allow from all

    # Use this line for Apache 2.4 and above
    Require all granted
</Directory>

ErrorLog /var/log/apache2/events_error.log
CustomLog /var/log/apache2/events_access.log combined

restart your apache

sudo service restart apache2

done, should just work!

source: https://www.youtube.com/watch?v=OVbErFBUinI

0

I cant comment because less than 50 reputations thatswhy i answer:

You have to do:

clear cache warmup prod cache (i think you have done?)

Next, install apache config:

composer require symfony/apache-pack

this create your apache config files which you have to edit. Description you find here: Symfony- Configuring Webserver

( I think missing .htaccess gives the error ) try: yourhost/projectFolder/public if your site will be shown, be sure, server is misconfigured or .htaccess is missing.

4
  • Hi, I have done all of these things yet. .htaccess file present too. I followed Symfony docs step by step. All works fine when I work in DEV environment, but in PROD no activity against database happens. No error, but no action. It's like database does not exists. For example, I have a users table that has each user password. When login in PROD (APP_ENV=prod), you can login with any credentials, it does not validate against database, no action against database works... Extrage a lot! I have tried with httpd and nginx we servers, and nothing is working... instead with symfony local web server! Jul 8, 2019 at 14:26
  • but here is only one problem. Symfony is crying very loud if Database Connection fails. im sure Symfony is give 500 error and not 404. I think routing is the problem. check your routes.yaml or routing annotations available in prod. Jul 8, 2019 at 17:04
  • Hi Daniel, thanks for your interest. I've checked all routes, all configuration issues, installed on httpd and nginx... Finally, the problem is that the $form->isValid() is working in DEV environment, and NOT in PROD environment. I mean, same form, same data, in DEV is valid, in PROD is not valid. So, all logic is not called. But the question is... why???? Same code, same data, different environment, same code works different????? I'm really worried about it. I've commented this out and now works, but the question is why same code works in DEV and not in PROD if ($form->isValid()) {} Jul 9, 2019 at 10:37
  • debug your form and im sure you get this problem solved fast. Here you will found a debug tutorial: symfonycasts.com/blog/symfony-debugging-form-errors Jul 10, 2019 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.