在共享主机上部署Symfony2

时间:2015-06-30 12:43:51

标签: php apache symfony

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

-public_html
  -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
-app
-src
-...

编辑: 现在我在“public_html / example /”中有完整的应用程序 它工作正常,但它是安全的吗?

2 个答案:

答案 0 :(得分:1)

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.

答案 1 :(得分:0)

替代解决方案可能是在“public_html”之外的文件夹中安装/部署Symfony,我们将其命名为“symfony_app”。

然后,您的目录结构可能如下所示:

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

然后,你应该在“public_html”文件夹中创建一个Symfony“web”文件夹的符号链接。

例如:

ln -s /home/your_username/symfony_app/web /home/your_username/public_html/www.symfony-site.com
在创建符号链接之前,

**名为“www.symfony-site.com”的文件夹不能存在于“public_html”中!

最后一步是在cPanel中添加新的子域。在那里你应该将你的新子域与“public_html”中的“www.symfony-site.com”符号链接连接起来。