Symfony4 deploy to shared hosting

后端 未结 2 798
予麋鹿
予麋鹿 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条回答
  •  梦毁少年i
    2021-01-03 17:21

    I'm using apache server for production (Shared hosting). The easy thing is edit .htaccess file.

    Add this at the bottom of .htaccess file

    # ENVIRONMENT VARIABLES
    SetEnv APP_ENV prod
    SetEnv APP_SECRET 79cfa09223f91b1a195134019e0b17ac
    

    This will solve the question.


    These are the things I faced personaly, so to help someone,

    And sometimes symfony4 throws error on php7.2 servers. To solve this, in .htaccess file add the following code,

    # php -- BEGIN cPanel-generated handler, do not edit
    # Set the “ea-php72” package as the default “PHP” programming language.
    
      AddType application/x-httpd-ea-php72 .php .php7 .phtml
    
    # php -- END cPanel-generated handler, do not edit
    

    This code automatically generated by my server. I think someone needs this.


    At first I tried to deploy my app without .htaccess file. But this throws error, no output in production server. I tried to switch php and finally i saw the above code generated by server itself and later I added the setenv to work with symfony4.

提交回复
热议问题