5

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.

13
  • 1
    Did you tried to use the app_dev.php ? what you get ? still blank ?
    – dotoree
    Mar 24, 2012 at 21:53
  • Yep, still blank. I discovered in Chrome is showing this message: 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. Does that make some sens? Mar 24, 2012 at 22:00
  • 3
    "We uploaded the whole project ... (via ftp of course)" - if you can, move towards version control software for deployment, or failing that, rsync - either would make deploying much easier for you. FTP is not good way to deploy code changes.
    – halfer
    Mar 30, 2012 at 21:47
  • 1
    Symfony2 is a professional framework, it is meant to be used on a VPS or a dedicated server with a SSH access. Deploying on a shared hosting using FTP will only result in future troubles and will just cost you more money in the long run. Apr 1, 2012 at 15:19
  • 1
    @HubertPerron, alright, no problem, we just reserved a "starter" hosting for the test, our site's still on development phase . we'll move to a dedicated server having SSH access. Thanks a lot for the advice Hubert. Apr 1, 2012 at 16:53

4 Answers 4

24

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.

3
  • 5
    That's not a good way to deploy an application. app_dev.php should only be used for development purposes, and should be disabled or protected in production environment due to security reasons. With the steps above, you are disabling the built-in security features, which may result in a compromised system. Mar 30, 2012 at 23:08
  • Yes I confirm, it's not the best way, it's just the way I got it work , if you have a best alternative of some steps above then please post it. I'm just experiencing the thing I need an expert. Mar 30, 2012 at 23:31
  • I think I solved the problem you talked about "disabling the built-in security features" of the file app_dev.php by adding the IP address to the array of "allowed accesses" in this file. Mar 31, 2012 at 11:29
3

In my case it was the php version* and I catched the error by running config.php with removed lines for checking ip address. On my hosting I just changed the default version of PHP for my scripts.

*Since namespaces are only from 5.3.

0
0

production isnt app_dev but app.. The page might be the same did you do a view source? Did you try to run the config.php that comes with the framework zip ?

8
  • Source is also blank. Running config.php (very good idea that I forgot about it) is saying: This script is only accessible from localhost. Mar 24, 2012 at 22:11
  • 1
    @Nadj At the top of config.php you should have an array of allowed IP addresses. You could add yours temporarily there and reupload the file. Mar 24, 2012 at 22:43
  • @jperovic, I did but still see the problem: This script is only accessible from localhost. So weird, this is the code: if (!in_array(@$_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1', 'my.ip.adr.ess', ))) { header('HTTP/1.0 403 Forbidden'); die('This script is only accessible from localhost.'); } Mar 24, 2012 at 23:02
  • 1
    Weird indeed, cause I did this many times and it worked. Are you sure you put your public IP address? I use this service to find it: whatismyip.com Mar 24, 2012 at 23:06
  • Address of the website you mean? Yes it is, I'm already opening the CPanel through the address: my.ip.addr.ess:2082. am I right? Mar 24, 2012 at 23:19
0

If your installation runs on a shared webserver, try setting the following line into the app.php:

date_default_timezone_set('America/Los_Angeles');

This solves the problem in my case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.