How to Deploy a Symfony Website to Prod


create the symfony folder with all the Website (generally in /var/www)

change right first to a non admin/sudo user :
# sudo chown -R user: user /var/www/symfony
Allow the user www-data access to the files inside the application folder. Give this user a read + execute permission (rX) in the whole directory.
# sudo setfacl -R -m u:www-data:rX symfony
Give read + write + execute permissions (rwX) to the user www-data in order to enable the web server to write only in these directories.
# sudo setfacl -R -m u:www-data:rwX symfony/var/cache symfony/var/logs
Finally, we will define that all new files created inside the app/cache and app/logs folders follow the same permission schema we just defined, with read, write, and execute permissions to the web server user. This is done by repeating the setfacl command we just ran, but this time adding the -d option.

# sudo setfacl -dR -m u:www-data:rwX symfony/var/cache symfony/var/logs

# export SYMFONY_ENV=prod
# composer install --no-dev --optimize-autoloader
# php bin/console doctrine:schema:validate
# php bin/console doctrine:schema:create
# php bin/console cache:clear --env=prod --no-debug

Bonux : create a swap file for VPS
# dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
# mkswap /var/swap.img
# swapon /var/swap.img
# echo "/var/swap.img none swap sw 0 0" >> /etc/fstab


2019-04-16 22:17:58


Add a Comment

Login or Register to post a Comment.