Reputation: 147
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
Upvotes: 0
Views: 511
Reputation: 20615
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
Upvotes: 1
Reputation: 856
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.
Upvotes: 0