Ask your Symfony questions! Pay money and get answers fast! (more info)

Symfony Installation Help Symfony

  • SOLVED

I need help on transferring an existing Symfony installation from one dedicated host to a new dedicated host. I have run the check_configuration.php file and all is good on the Apache server environment end (minus the accelerator). The database file is uploaded, a user has been created to access the database, and the files have all been uploaded.

My config:
I've edited the databases.yml file with the proper credentials
I've edited the propel.ini file to reflect the changes with the propel.database.createUrl and propel.database.url

I'm getting a blank page and I've checked my access logs, but don't see anything that helps me out. I've tried accessing the backend.php and I get the same result.

I'm unsure if my VirtualHost settings are correct and I'm not sure if that would be causing the database to not connect. The server is a dedicated Linux box from Singlehop running Cpanel and WHM. If you can answer the question without logging into the server, that would be ideal. I will raise the value of the question if a server login is required because of the extra work involved.

Answers (6)

2010-05-18

José Antonio answers:

Hello Morgan,

You should check this options before access to your application.

1. The ProjectConfiguration class access to the rigth Symfony's lib directory address.

<?php
require_once '/path/to/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration {
public function setup() {

}
}


2. Check if all the PHP's libraries that you uses in the firts server are loaded in this one. For example, MCrypt, XSL or any other.

3. Check if the server show you the errors in the (Apache) configuration file.

Meabe you can fix your problem with this advices.

Sorry my english.

2010-05-18

Jakub Zalas answers:

Also, check if apache has permissions to write to the cache and log directories.


Morgan Long comments:

Permissions are written correctly.


Jakub Zalas comments:

<blockquote>
Warning: session_start() [function.session-start]: SAFE MODE Restriction in effect. The script whose uid is 503 is not allowed to access /tmp owned by uid 0 in /home/digtess1/public_html/lib/symfony/storage/sfSessionStorage.class.php on line 92

Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: files (path: ) in /home/digtess1/public_html/lib/symfony/storage/sfSessionStorage.class.php on line 92
</blockquote>

Looks like you don't have permissions to write into /tmp directory. By default session files are stored there. You can modify it with ini_set:


ini_set('session.save_path', '/home/digtess1/tmp');


Replace '/home/digtess1/tmp' with directory you have access to.


Jakub Zalas comments:

A bit more of explanation: you cannot write to /tmp because safe mode is turned on. Otherwise other users of the system could read your session files.


Morgan Long comments:

I think you're on to something there. The prior developer modified that class file to add this:
if(isset($_COOKIE['local_companyid']) && $_COOKIE['local_companyid']!="")
{
$this->write("companyid",$_COOKIE['local_companyid']);
}


I created a directory within public_html for tmp files. Now I'm getting a 404 error. index.php forwards to /default/error404.


Jakub Zalas comments:

Use development controller to see what's wrong ('*_dev.php'). Alternatively you can check apache's error log file.


Morgan Long comments:

Of course I just realized that storing sessions in the public_html folder is probably not the safest way of handling them. I checked my PHP config and safe mode is turned off. What am I missing here to get those sessions to write to that directory without changing the structure of sfSessionStorage.class.php?

The frontend_dev is telling me I have a database connection error. I'm going to mess with that for a bit and see if I can get it running.


Jakub Zalas comments:

It could be that you just have different database configuration for your dev environment.

Don't use public_html location for your session files. It can be any location in your home directory which is not public.


Jakub Zalas comments:

BTW you don't have to change sfSessionStorage to change the session location path. You can put that ini_set line in your controller.

2010-05-18

Arturo Linares answers:

Apparently symfony is crashing. Try entering in dev mode to see what's going on. Edit web/index.php and set the environment to 'dev' to see the errors.

2010-05-18

Eduardo Raffoul answers:

Can you show us your VirtualHost setting? Do you have the file structure of the symfony project as symfony creates it or did you move some folder outside your /httdocs/web/public folder? What version of symfony are you using, did you tried to run the configure:database command?

By the way, try to access via dev environment. You have to do this (just for this test)



//In /web/frontend_dev.php
// Comment this

if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
{
die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}


You have to comment the code above so you can access to the dev environment in the server. Remember to uncomment it after you try.

So check what happens when you access this way.


Morgan Long comments:

Checked the frontend_dev and I got the "You are not allowed to access this file. Check frontend_dev.php for more information." message. Same for backend_dev.php.


Morgan Long comments:

Sorry, overlooked the frontend_dev log. Here's the log info:
May 18 10:11:55 symfony [info] {sfPatternRouting} Connect "/"
May 18 10:11:55 symfony [info] {sfPatternRouting} Connect "/symfony/:action/*"
May 18 10:11:55 symfony [info] {sfPatternRouting} Connect "/:module"
May 18 10:11:55 symfony [info] {sfPatternRouting} Connect "/:module/:action/*"
May 18 10:11:55 symfony [info] {sfPatternRouting} Connect "/captcha"
May 18 10:11:55 symfony [info] {sfPatternRouting} Connect "/captcha/:random"
May 18 10:11:55 symfony [info] {sfPatternRouting} Connect "/captcha_demo"
May 18 10:11:55 symfony [info] {sfFrontWebController} Initialization
May 18 10:11:55 symfony [info] {sfPatternRouting} Match route [homepage] for "/"
May 18 10:11:55 symfony [info] {sfWebRequest} Request parameters array ( 'module' => 'content', 'action' => 'home',)


Eduardo Raffoul comments:

But you have to comment the lines that im showing you. Access the web/frontend_dev.php file (in an editor) and comment the lines that i showed you above, after you do it it should look like this:
<?php

// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it or make something more sophisticated.
/*
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
{
die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
*/

require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');

$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true);
sfContext::createInstance($configuration)->dispatch();


Morgan Long comments:

Sorry about that. The dev file was already commented. Result:

Warning: session_start() [function.session-start]: SAFE MODE Restriction in effect. The script whose uid is 503 is not allowed to access /tmp owned by uid 0 in /home/digtess1/public_html/lib/symfony/storage/sfSessionStorage.class.php on line 92

Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: files (path: ) in /home/digtess1/public_html/lib/symfony/storage/sfSessionStorage.class.php on line 92


Eduardo Raffoul comments:

It looks like a problems permission. Before checking anything else on server, ¿Did you run the 'symfony fi' command?

Try executing (via cli):
php symfony fi
php symfony cc


Eduardo Raffoul comments:

By the way, if your server gives you a sudo user, run the fi command with the sudo user:
sudo php symfony fi


Morgan Long comments:

Executed both.

Below is the VirtualHost from the httpd.conf for this directory. Maybe that will shed some light on things.

<VirtualHost 173.236.56.42:80>
ServerName digtess.org
ServerAlias www.digtess.org www.digtess.com digtess.com
DocumentRoot /home/digtess1/public_html
ServerAdmin [email protected]
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/digtess.org combined
CustomLog /usr/local/apache/domlogs/digtess.org-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User digtess1 # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup digtess1 digtess1
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup digtess1 digtess1
</IfModule>
ScriptAlias /cgi-bin/ /home/digtess1/public_html/cgi-bin/


# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/digtess1/digtess.org/*.conf"

</VirtualHost>


Morgan Long comments:

I'm getting this error when I php symfony cc:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so: undefined symbol: sqlite3_libversion in Unknown on line 0

Is the sqlite extension required? I thought only pdo.so was required.


Eduardo Raffoul comments:

So, if fi and cc commands doesn't resolve your problem you must check permissions on your server. As Jakub Zalas remarks, the key here is the /tmp permission. If you cant change the permission on that directory, you have to change the location where symfony stores the session files.

And about the sqlite extension, it is mandatory (obviously) if you're using sqlite. I just made a test. I commented in my local php.ini the pdo_sqlite.so extension and everything works fine. So i have to ask, what database are you using?


Morgan Long comments:

I commented on the permissions problem below.

The sqlite extension is on in my web php.ini file. I went ahead and turned on all of the pdo extensions because I wasn't sure which one I would need. I think possibly I need to go to the server php.ini and not the web php.ini to activate that extension. I will try that.


Eduardo Raffoul comments:

Im not sure what do you mean with 'web php.ini'. But is not a good practice to activate all the extensions, as it will slow down your server. Maybe the cli's php.ini is not the same of server's php.ini, and that's causing a problem when you execute a command via cli. But, again, if you're using a database different than sqlite you don't need it.


Morgan Long comments:

Sorry for the delayed response. Some things have come up this afternoon.

I think I've narrowed down the problem to possibly a virtual host setup problem.

I added the DocumentRoot path to my httpd.conf file to point to the web/ folder as suggested in the Symfony documentation, but that doesn't seem to do any good. I rebuilt the conf file and restarted the Apache service.

Also, what are the permissions supposed to be for the config/ folder?


Eduardo Raffoul comments:

I dont see anything weird in your vhost.conf ¿Did you try with the solution proposed for Jakub Zalas and glkz, of changing the session_cookie_path?


Eduardo Raffoul comments:

I see now something that makes me think (in bold)

<VirtualHost 173.236.56.42:80>
ServerName digtess.org
ServerAlias www.digtess.org www.digtess.com digtess.com
<strong>DocumentRoot /home/digtess1/public_html</strong>
ServerAdmin [email protected]
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/digtess.org combined
CustomLog /usr/local/apache/domlogs/digtess.org-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User digtess1 # Needed for Cpanel::ApacheConf
<IfModule mod_suphp.c>
suPHP_UserGroup digtess1 digtess1
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup digtess1 digtess1
</IfModule>
ScriptAlias /cgi-bin/ /home/digtess1/public_html/cgi-bin/


# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/digtess1/digtess.org/*.conf"

</VirtualHost>

Are you sure that that is the right DocumentRoot path? It should point to your /web directory in your symfony project, i'd like you to check that.


Morgan Long comments:

Went to the httpd.conf file for that virtual host and added /web to make it DocumentRoot /home/digtess1/public_html/web

The path still doesn't seem to be correct. Whenever I go to my IP address with that ~digtess1 directory, I get a 404 error. So I figure at the very least it should be detecting an index.php file (DirectoryIndex is set to index.php).

I'm beginning to wonder if it's easier to just do a fresh Symfony project install, then copy my app, config, and web files to their respective folders.


Eduardo Raffoul comments:

Why dont you try with a simple vhost.conf file, like this, just to check:

<VirtualHost 173.236.56.42:80>
ServerName digtess.org
DocumentRoot "/path/to/your/project/web"
DirectoryIndex index.php

<Directory "/path/to/your/project/web">
AllowOverride All
Allow from All
</Directory>

Alias /sf /path/to/your/project/lib/vendor/symfony/data/web/sf

<Directory "/path/to/your/project/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>

</VirtualHost>



Morgan Long comments:

I can't find the second part with the Alias in my file structure. I'm looking in project_root_directory/lib/vendor/symfony/data/web/sf and that folder doesn't exist.

I created an include for my httpd.conf file and added the first part of that and it didn't help. I also went through and deleted the .htaccess files in case they were conflicting with the httpd.conf.


Eduardo Raffoul comments:

Honestly, it's not clear enough to me what the problem might be. If you want, i could access to your server and check it personally. If you want, contact me at eraffoul (at) gmail (dot) com.


Morgan Long comments:

I think we're going another route. Thanks for your help. I've selected you as the winner.

2010-05-18

casivaagustin answers:

- Check the configuration of the virtual host, check that the paths of sf libs works fine.

- Recheck The database credential in databases.yml and propel.ini

- Clean the Cache, Rebuild All clases (build-all or build-form, model, filter) and then reclean the chache (cc).

- Set the correct permision on cache, log and uploads folder (project:permissions maybe help)

If does not works, please put the Vhost configuration, database.yml, propel.ini, and check the dev environment for see debug info and paste for us.

Cheers

2010-05-18

glkz answers:

Also, check php memory limit. Try to set the php memory limit 64M or greater.


Morgan Long comments:

Memory limit is set to 64M


glkz comments:

<blockquote>
Of course I just realized that storing sessions in the public_html folder is probably not the safest way of handling them. I checked my PHP config and safe mode is turned off. What am I missing here to get those sessions to write to that directory without changing the structure of sfSessionStorage.class.php?
</blockquote>

You can change the cookie path from apps/{app_name}/config/factories.yml
<blockquote>
all:
storage:
param:
class: sfSessionStorage
session_cookie_path: /home/username/tmp
</blockquote>
After this, clear cache.