How to deploy Symfony2 on a shared-hosting?

人走茶凉 提交于 2019-11-29 21:54:06
Julien Rollin

In your configuration, apache uses public_html as the document root

If Symfony2 is installed in directory /home/u105859802/public_html/amateur1, the Symfony public directory to serve is /home/u105859802/public_html/amateur1/web/

You should use

RewriteBase /amateur1/web/

But beware, it is not safe
You have to protect your symfony directories! (configuration is accessible)

Why don't you try moving your symfony files in your private area ?
You can rename the Symfony web directory to public_html

See how to do that in documentation cookbook

So, my recommendation structure looks like below :

  • /home/u105859802/
    • vendor
    • src
    • app
    • bin
    • public_html (web by default in symfony2) <- the only public directory

In most of the shared hosting, you can't override Apache settings in that case may need to wright a redirection rule in .htaccess file

Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule !^projectName/ /projectName/web/app.php/%{REQUEST_URI} [L,NC]

this is the rule I used in my project . You may need to provide full paths to your assets other ways they will not get loaded .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!