The Web Server Bundle allow us to use the PHP built-in web server in local or dev environment but you can run you symfony application without it in 3 steps !
1- Install the apache pack
The most easiest way to add the rewrinting rules is to install apache pack . It will add a .htaccess
in public
directory
$ composer require symfony/apache-pack
2- Add a local domain
$ echo "127.0.0.1 mydomain.local" >> /etc/hosts
⚠️ be aware that .dev will force the redirection to https :-(
3- Configure the host
$ cd /etc/apache2/sites-available
$ touch myproject.conf
$ vim myproject.conf
add this :
<VirtualHost *:80>
ServerName myprojet.local
ServerAlias www.myproject.local
DocumentRoot /var/www/html/myproject/public
<Directory /var/www/html/myproject/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>
Run the following command:
$ sudo a2ensite myproject.conf
$ sudo service apache2 reload
Links : https://symfony.com/doc/current/setup/web_server_configuration.html