部署Symfony2项目 [英] Deploying a Symfony2 project

查看:184
本文介绍了部署Symfony2项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在研究Symfony2项目。现在,已经完成并准备好部署了。我们将整个项目文件上传到服务器(通过ftp当然)和数据库。现在当我们打开任何页面时,我们只得到一个空白页(空源代码)。缓存是干净的,日志不显示任何新的。我们搜索了将Symfony2项目部署到主机的步骤,但是我们没有找到一个很好的解释(即使是关于Symfony不是版本-2)。
我们认为这可能是一个配置问题,但到目前为止还没有想法。
任何帮助将不胜感激。
提前感谢。



编辑:空白页面在Firefox中。谷歌浏览器正在说:


服务器错误网站在检索
时遇到错误http:// * .com/mammoky/web/app_dev.php/main。对于
维护或配置不正确可能会关闭。以下是一些建议:
稍后重新加载此网页。 HTTP错误500(内部服务器错误):服务器尝试
满足请求时遇到
意外情况。


error_log显示:


[2012年3月24日23:29:24] PHP解析错误:语法错误,意外的
T_STRING,期待T_CONSTANT_ENCAPSED_STRING或
/home/leadow33/public_html/mammoky/web/app.php第7行


它是:使用Symfony\Component\HttpFoundation\Request;


[ 2012年3月24日23:15:08] PHP警告:输入中的意外字符:
'\'(ASCII = 92)state = 1 in
/ home / leadow33 / public_html / mammoky / web /config.php第84行


它是:$ reflector = new \ReflectionExtension('intl');






编辑:我已经发布了我的解决方案,请查看这里。

解决方案

答案:



我得到了工作,这是我的经验:




  • 将整个项目文件夹上传到服务器。

  • 输入 www.your-website.com/项目名称/ web / config.php

  • 应该说:这个脚本只能从localhost访问。

  • 打开此网站: http://www.whatismyip.com ,它应该显示您的公共IP地址,复制它。

  • 从管理面板(如cPanel)打开config.php并编辑 config.php






  if(!in_array(@ $ _ SERVER ['REMOTE_ADDR'] ,array('127.0.0.1',':: 1',/ *你的IP这里* /))){
header('HTTP / 1.0 403 Forbidden');
die('这个脚本只能从本地主机访问);
}







  • 刷新您的 config.php 文件,该页面将告诉您系统是否缺少一些必需的条件,如:PHP版本,APC扩展,给/缓存和/写入权限等。

  • 提供所需条件后,您将看到一种配置项目以连接到数据库的形式,如果您有一个,这一步很简单。

  • 打开链接 www.your-website.com/project-name/web/app_dev.php ,它会帮助你开始使用Symfony2项目。

  • 如果您进入 app_dev.php 此消息:您不是允许访问此文件... 只需执行相同的操作 app_dev.php ,如步骤4和5所示(添加您的公共IP地址到数组)。

    Hakan Deryal的注释(注释):如果你没有修复IP地址,那么每次从DHCP获取新的IP地址时,都需要做最后一步。所以要解决这个问题,打开 app_dev.php 并注释掉 die('你不允许.. ,但是这不是推荐的方法,因为您禁用了文件的内置安全性。

  • 有一件事阻止了我,也可能阻止你,我部署了这个项目的服务器on,是区分大小写的(不像我的电脑上的localhost),所以它不断告诉我,模板(例如, Index.html.php )不存在,但是它确实存在,但我做了 return $ this-> render('...:index.html.php')与小 DefaultController.php 中,所以渲染具有相同字母大小写的确切的模板(文件)名称。



现在一切顺利,希望能帮到你。


We were working on a Symfony2 project. Now, it's done and ready to be deployed. We uploaded the whole project files to the server (via ftp of course) and the database as well. Now when we open any page of it we got just a blank page (empty source code). Cache is clean, logs do not show anything new. We googled the steps of deploying a Symfony2 project to a hosting but we did not find a good explanation (even these ones were about Symfony not-version-2). We believe it maybe a configuration issue, but no idea so far. Any help will be greatly appreciated. Thanks in advance.

Edit: the blank page is in Firefox. Google Chrome is saying something:

Server error The website encountered an error while retrieving http://*.com/mammoky/web/app_dev.php/main. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

error_log is showing:

[24-Mar-2012 23:29:24] PHP Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/leadow33/public_html/mammoky/web/app.php on line 7

It's: use Symfony\Component\HttpFoundation\Request; And

[24-Mar-2012 23:15:08] PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/leadow33/public_html/mammoky/web/config.php on line 84

It's: $reflector = new \ReflectionExtension('intl');


EDIT: I've posted my solution, check it out down here.

解决方案

Answer:

I got it to work, this is my experience:

  • Upload the whole project folder to the server.
  • Enter www.your-website.com/project-name/web/config.php.
  • It should say: "This script is only accessible from localhost".
  • Open this web site: http://www.whatismyip.com, it should show you your public IP address, copy it.
  • Open the config.php from the admin panel (like cPanel) and edit that config.php:

if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', /*your IP here*/))) {
    header('HTTP/1.0 403 Forbidden');
    die('This script is only accessible from localhost.');  
}


  • Refresh your config.php file, the page will tell you if your system is missing some required conditions like: PHP version, APC extension, giving /cache and /log folders permissions to write on, etc.
  • After you provide the required conditions you'll see a form of configuring you project to connect to a database if you have one, this step is pretty simple.
  • Open the link www.your-website.com/project-name/web/app_dev.php, it'll help you get started with Symfony2 project.
  • In case you got in app_dev.php this message: You are not allowed to access this file... just do the same thing to app_dev.php as you did in steps 4 and 5 (add your public IP address to the array).
    Note of Hakan Deryal (comment): If you don't have a fix IP address, you need to do this last step each time you get a new IP adrdress from the DHCP. So to solve that, open the app_dev.php and comment out the line die('You are not allowed to.., however this is not a recommended way because you're disabling the built-in security of the file.
  • One thing stopped me and may stop you too, the server I deployed the project on, was case-sensitive (unlike the localhost on my computer), so it kept telling me that the template (Index.html.php for example) does not exist, however it does exist, but I did return $this->render('...:index.html.php') with small i in DefaultController.php. So render the exact template (file) name with the same letters cases.

Now everything is going well, I hope that helps you.

这篇关于部署Symfony2项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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