dphphvs496524
2015-06-30 12:43
浏览 19
已采纳

在共享主机上部署Symfony2

I can not find reply to my question. I am trying to understand how i should deploy symfony2 app on shared hosting. I know i should rename my "web" catalog to "public_html", but i have many sites in this catalog. My catalog's structure is like:

-public_html
  -www.firstsite.com
  -www.secondsite.com
  ...
  -www.nextsite.com
-private_html

So where i should put my files? app,src,vendor under public_html, and files from web i should put directly to "public_html"? Or catalog web should be in public_html and other files under public_html? So i will have:

-public_html
  -...
  -web
-private_html
-app
-src
-...

EDIT: Now i have whole app in "public_html/example/" It's work fine, but it is safe?

图片转代码服务由CSDN问答提供 功能建议

我找不到回复我的问题。 我想了解我应该如何在共享主机上部署symfony2 app 。 我知道我应该将我的“web”目录重命名为“public_html”,但我在这个目录中有很多站点。 我的目录结构如下:

  -public_html \  n -www.firstsite.com 
 -www.secondsite.com 
 ... 
 -www.nextsite.com 
-private_html 
   
 
 

所以 我应该把我的文件放在哪里? app,src,public_html下的供应商和web上的文件我应该直接放到“public_html”? 或者目录web应该在public_html和public_html下的其他文件中? 我将有:

  -public_html 
 -... 
 -web 
-private_html \  n-app 
-src 
 -... 
   
 
 

编辑: 我现在整个应用程序都在“public_html / example /” 工作正常, 但这样安全吗?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongzou1964 2015-06-30 13:23
    已采纳

    You should create a folder for your new website inside "public_html". Let's say you have the domain "example.com".

    You will have: public_html/example.com, public_html/example2.com, ..

    Inside the folder example.com you will copy the folders: app, src, public.. (all Symfony's project main folders and files).

    To answer to your question. "EDIT: Now i have whole app in "public_html/example/" It's work fine, but it is safe?". Yes, it's safe.

    Just search on google for: "prevent directory traversal", if you want to make sure that it's secure.

    已采纳该答案
    打赏 评论
  • douba4933 2016-09-17 19:00

    Alternative solution could be installing/deploying Symfony in a folder outside "public_html", let's name it "symfony_app".

    Then, your directory structure could look something like this:

    -public_html
      -www.firstsite.com
      -www.secondsite.com
      ...
    -symfony_app
    

    And then, you should make a symlink of a Symfony "web" folder in the "public_html" folder.

    For example:

    ln -s /home/your_username/symfony_app/web /home/your_username/public_html/www.symfony-site.com
    

    ** folder named "www.symfony-site.com" must not exist in "public_html" before creating symlink!

    Last step would be adding new subdomain in cPanel. There you should connect your new subdomain with "www.symfony-site.com" symlink inside "public_html".

    打赏 评论

相关推荐 更多相似问题