将 Symfony 2.5.3 网站部署到生产服务器 [英] Deploying Symfony 2.5.3 website to production server

查看:23
本文介绍了将 Symfony 2.5.3 网站部署到生产服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发基于 Symfony 框架的开发环境中的网站,现在是时候将它部署到实时站点了,在开发环境中我们运行命令 php app/console server:run 运行网站,但我不确定需要做什么才能让用户在实时服务器上看到网站内容,在我将代码上传到实时服务器后,我看到的只是 Symfony 的根目录结构,我已经通过 如何部署 Symfony 应用程序 我正在挠头,因为有更重要的是,按照步骤操作后没有任何区别,我仍然看到目录结构.

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 command php app/console server:run to run the website but I am not sure what needs to be done to make the user see website contents on live server, after i uploaded the code to live server all I see is root directory structure of Symfony, I have gone through How to Deploy a Symfony Application and i am scratching my head as there is got to be more to it because after following the steps no difference was made and i still see directory structure.

我确实注意到,当我点击 web 文件夹时,我看到了网站,所以我创建了以下 .htaccess 文件,该文件有效,但 URL 看起来像 www.domain.com/web 我怎样才能让它www.domain.com

I did notice that when I click on the web folder I see the website so I created the following .htaccess file which works but the URL looks like www.domain.com/web how can i just make it www.domain.com

<IfModule mod_rewrite.c>
RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ web/$1 [QSA,L]
</IfModule>

如果我能在这里得到一些帮助,我将不胜感激,如果它有助于我尝试使用 Apache 在基于 Linux 的服务器上进行部署.

I will really appreciate if I can get some help here, if it helps I am trying to deploy on Linux based server using Apache.

解决方案在您的 .htaccess 文件中添加以下内容,它会起作用,因为这解决了我的问题,请记住也清除浏览器缓存

SOLUTION Add the following in your .htaccess file and it will work as this is what solved my problem and please remember to clear your browser cache as well

<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>

推荐答案

关注完所有如何部署 Symfony 应用程序,在您的 Symfony 应用程序的根目录中创建 .htaccess 文件并在其中添加以下代码,这就是解决了我的问题.

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>

这篇关于将 Symfony 2.5.3 网站部署到生产服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆