Symfony without the Web Server Bundle

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 an .htaccessin public directory

composer require symfony/apache-pack

2- Add a local domain

vim /etc/hosts mydomain.local

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
# 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

sudo a2ensite myproject.conf

sudo service apache2 reload

4- Enjoy !

Links :