Deploying Symfony 2.5.3 website to production server

后端 未结 4 1216
渐次进展
渐次进展 2021-01-23 17:16

I have been working on a website in development environment built on top of Symfony framework and now it is time to deploy it to live site, in development environment we run the

相关标签:
4条回答
  • 2021-01-23 17:50

    After following all the How to deploy a Symfony App, in the root of your Symfony application create .htaccess file and add the following code in it, this is what solved my problem.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.domain.com$
    RewriteCond %{REQUEST_URI} !web/
    RewriteRule (.*) /web/$1 [L]
    </IfModule>
    
    0 讨论(0)
  • 2021-01-23 17:59

    If you are running ubuntu do the following

      sudo nano /etc/apache2/sites-enabled/000-default.conf
    

    change document root to and save

      DocumentRoot /var/www/html/web
    

    Then run

      sudo service apache2 restart
    

    Then run

     cd /var/www/html
    
     php app/console cache:clear --env=prod --no-debug
    

    all done

    0 讨论(0)
  • 2021-01-23 17:59

    I don't know how it is done professionally because I don't use symfony, but I will tell you how I did it when I was testing on Linux.

    Let's say you have your www directory in /home/user/www/ (it doesn't really matter). I would put whole symfony directory (with all directory structure) to some other directory (let's say /home/user/applications/my-symfony-webpage - the last being your directory with symfony files structure).

    Last thing you need to do to make it work is to create a symlink which will direct from /home/user/www/ to /home/user/applications/my-symfony-webpage/web.

    It can be done with this command: ln -s /home/user/applications/my-symfony-webpage/web /home/user/www/ (I think you need to delete www directory first if it's meant just for symfony installation).

    That's my solution, I doubt it's the only one and probably not the best one. I think you can create redirects with apache to direct some domains to some directory in your file structure (in your case to web directory of course). You can look it up online.

    0 讨论(0)
  • 2021-01-23 18:13

    You have to configure your Apache to point your project folder web as document root.

    You can find information about to configure your server here: Configuring a Web Server (The Symfony CookBook)

    0 讨论(0)
提交回复
热议问题