I want to share my Symfony 4 apache vhost config

The short story with Symfony 4 virtual host setup

i we just started to learn Symfony and was surprised with not found on just fresh apache setup environment.
Followed the tutorials and everything was “Ok” till the moment with routes. There was no problems with the index page, with the index.html.twig too.
But what a surprise with the “rewrited” urls. I got many 404 “Not found” pages until the moment i we found a good example of a apache.conf virtual host. This link: How To Deploy a Symfony Application to Production on Ubuntu 14.04

But i learn Symfony 4, so i had to change the app.php to index.php (default file at the moment) and added: ServerName my-test.vio on top. You can change it with you test server name. And don’t forget to edit your /etc/hosts file.

BTW you can’t use anymore *.dev extension for setup Apache vhosts. Try something like .test, .vhost

[php]

<VirtualHost *:80>
ServerName tut-crud.vio
DocumentRoot "/var/www/html/tut-crud/public"
<Directory /var/www/html/tut-crud/public>
AllowOverride None
Order Allow,Deny
Allow from All

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>

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

ErrorLog /var/log/apache2/symfony_error.log
CustomLog /var/log/apache2/symfony_access.log combined
</VirtualHost>

[/php]

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll Up