Symfony without the Web Server Bundle 📡

26 / 02 / 2019

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

Run the following command:

$ sudo a2ensite myproject.conf
$ sudo service apache2 reload

Enjoy 🎉

Links :

Thanks for reading, I hope you liked it, don't forget to share it !
LinkedIn Twitter