Symfony4 deploy to shared hosting

后端 未结 2 785
予麋鹿
予麋鹿 2021-01-03 17:07

I\'m using symfony4. Everything works in dev. But there is less tutorial for prod. How to deploy tutorial provides only less info (No info about shared hosting)

Ind

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-03 17:38

    You need the .env file that is on the server to have APP_ENV=prod The .env file is for the specific machine, it is ignored by git, while .env.dist is tracked. So edit the .env.dist and commit it.

    Put your project in the same dir as public_html as a sibling. Then remove the public_html dir and recreate it as a symlink pointing to your project public dir.

    Rename .env.dist to .env.

    Run composer require symfony/apache-pack it will create the .htaccess file and you should be good.

    Worked for me on A2hosted server.

    Update 2019-06-28

    Just deployed to Bluehost, they finally upgraded to PHP 7. I deployed into a sub-domain using the same process as above except one change. I had to add the following line to the public/.htaccess file generated by apache-pack in order to enable PHP 7.1

    AddHandler application/x-httpd-ea-php71 .php
    

提交回复
热议问题