Moving Site to New Server ~ Error

Once again thanks for your time.

I’m not sure what you have asked me to check.

I have changed permissions, deleted the .htaccess code…

I am absolutely clueless as to what i am meant to do.

Is the index file in the root the page i am meant to be accessing?

ie http://ipaddress/~username/index.php

The {ipaddress} page isn’t working

{ipaddress} is currently unable to handle this request.

HTTP ERROR 500

I have changed the hosts file so it points to the actual site address, but no idea if that makes a difference.

What am i meant to change or check exactly?

For a start I think I would temporary replace index.php (http://ipaddress/~username/index.php) with the standard script I linked to. Change the $yii and $config paths to actual values. Use a standard config for testing or try pointing $config to the local config. Without .htaccess you should be able to reach the default route (start page) using http://ipaddress/~username/index.php.

Even if you don’t have a local lab server environment available, you may want to download Yii 1.1 just to gain some experience from reading the code. E. g. check out the blog demo <framework dir>/demos/blog. And for trying it out, it’s possible to upload the Yii 1.1 content to a subdir on the server. IIRC it will use a file based DB out of the box.

Have a look at the urlmanager settings in config.

With ‘urlFormat’=>‘get’ the route will be <webroot>/<optional subdir>/index.php?r=<controller>/<action> (default use to be site/index)

With ‘urlFormat’=>‘path’, ‘showScriptName’ => false, (and working .htaccess) the route will be <webroot>/<optional subdir>/<controller>/<action>. Without .htaccess, at least you should be able to see the default start page (site/index) using the route <webroot>/<optional subdir>/index.php.

You may also want to read better explanations in the guide, e.g. the section User friendly URL’s

I hope this will help you solving this.

Yes, that’s expected. Note that you must have path to a valid config so it’s meaningless to comment out all assignments to $config in the start script.

I’m not sure about the exact path to the framework and demo dir in the Yii 1.1 download (I used to move some dirs). I’m sure you’ll find the blog demo and figure out how to call the start script in the blog subdir.

I definitely recommend you try the blog demo (you already mentioned that the requirements script passed ok). Probably a good idea to check with the latest requirements.php (from the downloaded Yii 1.1).

No success with blog demo? If possible you may also want to temporarily enable "show php errors" in the server.

I uploaded and tried accessing demos/blog/index.php but I receive the same 500 error.

The two file references are correct.

$yii=dirname(FILE).’/../../protected/framework/yii.php’;

$config=dirname(FILE).‘protected/config/main.php’;

No errors appear in cPanel > Errors.

Error Reporting and Display Errors are both ‘on’ in the php.ini that is in the root.

I don’t get any ‘fails’ in the Requirements but i do get some warnings. Assume these shouldn’t matter though?

PDO PostgreSQL extension Warning All DB-related classes Required for PostgreSQL database.

PDO Oracle extension Warning All DB-related classes Required for Oracle database.

PDO MSSQL extension (pdo_mssql) Warning All DB-related classes Required for MSSQL database from MS Windows

PDO MSSQL extension (pdo_dblib) Warning All DB-related classes Required for MSSQL database from GNU/Linux or other UNIX.

PDO MSSQL extension (pdo_sqlsrv) Warning All DB-related classes Required for MSSQL database with the driver provided by Microsoft.

PDO ODBC extension Warning All DB-related classes Required in case database interaction will be through ODBC layer.

Memcache extension Warning CMemCache

APC extension Warning CApcCache

Below i have posted the details that appear at the right side of phpmyadmin of the server with the ‘current live site’

Database server

Server: Localhost via UNIX socket

Server type: MySQL

Server version: 5.5.53-0ubuntu0.14.04.1 - (Ubuntu)

Protocol version: 10

User: user@localhost

Server charset: UTF-8 Unicode (utf8)

Web server

Apache/2.4.7 (Ubuntu)

Database client version: libmysql - 5.5.53

PHP extension: mysqli Documentation

Below is the details that appear on the server I am moving the site to.

Database server

Server: Localhost via UNIX socket

Server type: MySQL

Server version: 5.5.52-cll - MySQL Community Server (GPL)

Protocol version: 10

User: user@localhost

Server charset: UTF-8 Unicode (utf8)

Web server

cpsrvd 11.60.0.35

Database client version: libmysql - 5.1.73

PHP extension: mysqli Documentation

Does anything here make a difference?

Just to be sure:

Did you upload the complete Yii 1.1 package content to a subdir on your server (e.g. yii1117)?

You tried to access the blog demo at <your tmp domain>/yii1117/demos/blog and you didn’t see the start page. Instead you got a 500 error.

Edit: I actually just tried the same thing. The start page should show up with a text like this:

Next step is to make the runtime (and assets) directories writable (777 to keep it simple).

Did it work? Ok, now you should know what a basic start script (index.php) and config file (protected/config/main.php) looks like.

Next step will be to modify the site you’re trying to install.

Somebody told you it’s just to copy the files to the new server. That might be true if the same domain (mywebsite.org) is pointed to the new server. But what if it doesn’t work. Not a good idea.

I mentioned that the start script has dependencies on the domain (mywebsite.org). If it don’t match you will fall back to a “local” config. (There may also be domain dependencies in the config file or elsewhere.) E.g you could add a config/main.php and use a basic start script.

By now you should know enough about the basic start script and config to make the neccessary changes for at least bringing up the start page.

I uploaded the Demos folder to my root, but as mentioned I cannot access demos/blog/index.php as I receive the same 500 error.

I downloaded yii-1.1.17.467ff50.zip, and uploaded ‘framework’ and ‘demos’ to a new folder i created in the root 'testing.

When I try accessing the demos/blog/index.php in that i get the proper page.

The files being accessed/referenced in both instances are identical though. ?!

This Works:

h ttp://{ipaddress}/~usrname/testing/demos/blog/index.php

$yii=dirname(FILE).’/../../framework/yii.php’;

$config=dirname(FILE).’/protected/config/main.php’;

This doesn’t

h ttp://{ipaddress}/~usrname/demos/blog/index.php

$yii=dirname(FILE).‘http://{ipaddress}/~usrname/testing/framework/yii.php’;

$config=dirname(FILE).‘protected/config/main.php’;

This is a path in the servers filesystem, relative to the directory of the script.


dirname(__FILE__).'/../../framework/yii.php'

This is the scripts dir with a web url appended. Will not work.


dirname(__FILE__).'http://{ipaddress}/~usrname/testing/framework/yii.php'

Yes, although i have tried ANY type of reference. I was attempting to reference the yii file in the testing/framework just to see.

In the testing folder I upload BOTH the demos and framework folders.

The demos/blog/index.php works.

However i uploaded JUST the demos folder into the root, and placed the reference to the yii file ‘as it is/where it appears’ in the existing website/root, like so

$yii=dirname(FILE).’../../protected/framework/yii.php’;

$config=dirname(FILE).’/protected/config/main.php’;

500 error.

I had a comrade see if he could get it to work locally and the site (and blog) works (identical to the current live site on existing server).

Did you remove the .htaccess in root?

Also the ./protected/framework instance of Yii may have some problem/version diff/dependence of domain. Normally the framework code should not be tampered with, but who knows.

Renmoving everything in htaccess was the very first thing i ever tried.

The demos/blog references two files:

config/main.php

framework/yii.php

BOTH the:

root /protected/framework/yii.php AND

root /testing/protected/framework/yii.php

are identical. But only the testing/demos/blog index works.

The yii.php references /YiiBase.php

I have compared both of the copies of this file - the original/existing and the new one downloaded.

Line 83:

Original: return ‘1.1.14’;

New: return ‘1.1.17’;

Different versions (plus some other slight code changes), but that should have nothing to do with why the demos/blog doesn’t work.?

I replaced the original protected/framework folder with the newly downloaded framework folder (1.1.17).

No change, 500 error.

If I understand your situation

You have <webroot>/demos/blog/index.php (not working)

and <webroot>/testing/demos/blog/index.php (working)

Same framework in two places

<webroot>/protected/framework/yii.php

and

<webroot>/testing/framework/yii.php

Then the $yii and $config variable in index.php should be assigned


$yii=dirname(__FILE__).'../../protected/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';

and


$yii=dirname(__FILE__).'../../framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';

respectively

What about the 500 error. What exactly do you see. I assume you made the runtime and assets directories writable for the web server process.

At least the two blog instances should work. Very strange.

For some debug info you can uncomment this line in index.php

// defined(‘YII_DEBUG’) or define(‘YII_DEBUG’,true);

OK some progress.

In the <root>/demos/blog/index.php I simply added a slash/ at the start of the $yii

$yii=dirname(FILE).’/../../protected/framework/yii.php’;

$config=dirname(FILE).’/protected/config/main.php’;

Once i did that, i could now access <root>/demos/blog/index.php however an error appeared:

include(Controllers.php): failed to open stream: No such file or directory.

I did a search and found this: http://www.yiiframework.com/forum/index.php/topic/51257-includecontrollersphp-failed-to-open-stream-no-such-file-or-directory/

Post #5 says:

if you are use specific Controller in your module add also the ‘application.modules.invmgvt.components.*’,

I added this and now the <root>/demos/blog/index.php WORKS!

OK now to the main site.

I have gone into <root>/index.php and removed the slash/ at the start of the two config references:

$configLocal = include dirname(FILE) . ‘protected/config/main.php’;

$configServer = $env==‘local’ ? array() : include dirname(FILE) . ‘protected/config/’.$env.’.main.php’;

I similarly tried adding the absolute url

$configLocal = include dirname(FILE) . ‘http://www.mysite.org/protected/config/main.php’;

$configServer = $env==‘local’ ? array() : include dirname(FILE) . ‘http://www.mysite.org/protected/config/’.$env.’.main.php’;

Now i no longer receive the 500 error, but instead get the error:

I tried adding the same line - ‘application.modules.invmgvt.components.*’, - to the <root>/protected/config/main.php

but that has not fixed it.

Any help is appreciated on this.

What you found searching the forum is not relevant for the blog demo:

application.modules.invmgvt.components.*

is for a customization (module) added by a specific user

Main site: By now you should be able to understand the start script minimum requirements and how to modify the references to config and framework.

Your script obtains the servers domain and checks if it’s <mysite.org>. Obviously it isn’t, so it will use the local config (only) in your case.

You probably should try with a simplified start script pointing to a good config.

You’ll have to check what’s in

<webroot>/protected/config/main.php (local config)

and (something like)

<webroot>/protected/config/<mysite.org>.main.php (server config)

Check what’s in both files since they are merged together in the <mysite.org> case.

Do you know where I can the code for a simplified start script and config?

So the code in both of the below files is quite different.

<webroot>/protected/config/main.php

<webroot>/protected/config/production.main.php

However I don’t see anything in either that I have any clue as to what I can add/change.

I tried putting the code from production.main.php into main.php but receive the same error:

Here is the production.main code:

And main.php

Is the Internal Server Error - include(Controller.php) message the issue that should be fixed? The file exists in the Components folder so why does this message appear. What should be be looking at?

The Controller in Components directory may be a customized controller extending from the frameworks CController. It should be loaded because import lists ‘application.components.*’. Strange.

The server config just overlays the mail and db application components. Can be managed in the local config. Also there is an additional parameter “‘mpdf5Path’=>’/vendors/MPDF54/mpdf.php’,” (seemingly for pdf generation).

In the local config there is a dependency on $env but the code referring to $isLocal is commented, so unless referred to from elsewhere (CApplication? code), should not be a problem.

(Also search all files for YII_ENVIRONMENT, may be a dependence somewhere on "local" or <mydomain.org>)

There is a lot of rules for the urlManager component. By setting showScriptName to true you won’t need the redirection in .htaccess.

First goal should be to see your applications start page. Tell us exactly what you see (screen shot).

Simple start script.


<?php

error_reporting( error_reporting() & ~E_NOTICE );


$yii = dirname(__FILE__) . '/protected/framework/yii.php';

$config = dirname(__FILE__) . '/protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG', 1);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);


require_once($yii);

Yii::createWebApplication($config)->run();



Local config, better readability


<?php


// uncomment the following to define a path alias

// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable

// CWebApplication properties can be configured here.


$isLocal = $env == 'local';


return array(

  'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',

  'name' => 'XX',


  // preloading 'log' component

  'preload' => array('log'),

  'language' => 'en',


  // autoloading model and component classes

  'import' => array(

  'application.models.*',

  'application.components.*',

  'application.vendor.*',

  'application.helpers.*',

  //'application.extensions.jtogglecolumn.*',

  'ext.mail.YiiMailMessage',

  'ext.jui.EJuiDateTimePicker',

  'application.extensions.easyPaypal.*'

  ),

  

  'modules' => array(

  // uncomment the following to enable the Gii tool

    'gii' => array(

      'generatorPaths' => array(

        'bootstrap.gii'

      ),

      'class' => 'system.gii.GiiModule',

      'password' => 'XX',

      // If removed, Gii defaults to localhost only. Edit carefully to taste.

      'ipFilters' => array('127.0.0.1', '::1'),

    ),

  ),


  // application components

  'components' => array(

    'user' => array(

      // enable cookie-based authentication

      'allowAutoLogin' => true,

      'class' => 'WebUser'

    ),


    'akthumb' => array(

      'class' => 'ext.thumb.AkThumb',

    ),


    'clientScript' => array(

      'coreScriptPosition' => 2, //CClientScript::POS_END

      'defaultScriptPosition' => 2, //CClientScript::POS_END

      'defaultScriptFilePosition' => 2, //CClientScript::POS_END

      /*

      'class' => 'application.vendor.yii-EClientScript.EClientScript',

      'combineScriptFiles' => !$isLocal, // By default this is set to true, set this to true if you'd like to combine the script files

      'combineCssFiles' => !$isLocal, // By default this is set to true, set this to true if you'd like to combine the css files

      'optimizeScriptFiles' => !$isLocal, // @since: 1.1

      'optimizeCssFiles' => !$isLocal, // @since: 1.1

      'optimizeInlineScript' => false, // @since: 1.6, This may case response slower

      'optimizeInlineCss' => false, // @since: 1.6, This may case response slower

      *

      */

    ),


    // uncomment the following to enable URLs in path-format

    'urlManager' => array(

      'urlFormat' => 'path',

      'showScriptName' => false,

      'rules' => array(

        'category/front/<slug:[\w\-]+>' => 'category/viewBySlug',

        'r/<type:[\w\-]+>/<category_id:\d+>' => 'resource/list',

        'r/front/<slug:[\w\-]+>/<type:\d+>' => 'resource/viewBySlug',

        'r/front/<slug:[\w\-]+>/<type:\d+>/<category_id:\d+>' => 'resource/viewBySlug',

        'event/list/<type:[\w\-]+>' => 'event/list',

        'event/front/<slug:[\w\-]+>' => 'event/viewBySlug',

        'newsletter/front/<slug:[\w\-]+>' => 'newsletter/viewBySlug',

        '/login' => 'site/login',

        '/logout' => 'site/logout',

        'page/<view:\w+>' => 'site/page',

        'p/<slug:[\w\-]+>' => 'cms/viewBySlug',

        '/contact' => 'site/contactus',

        'search' => 'site/search',

        'sitemap' => 'site/sitemap',

        '/enews' => 'subscriber/subscribe',

        '/newsletter' => 'newsletter/list',

        '/registerMember' => 'user/registerMember',

        '/registerSaved' => 'user/registerSaved',

        'activateUser/<token:[\w\-]+>' => 'site/activateUser',

        '<controller:\w+>/<id:\d+>' => '<controller>/view',

        '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

        '<controller:\w+>/<action:\w+>' => '<controller>/<action>',

        'login' => 'site/login',

        'iforgot' => 'site/forgot',

      ),

    ),


    'db' => array(

      'connectionString' => 'sqlite:' . dirname(__FILE__) . '/../data/testdrive.db',

    ),


    // uncomment the following to use a MySQL database

    'db' => array(

      'connectionString' => 'mysql:host=127.0.0.1;dbname=XX',

      'emulatePrepare' => true,

      'username' => 'XX',

      'password' => 'XX',

      'charset' => 'utf8',

    ),


    'errorHandler' => array(

      // use 'site/error' action to display errors

      'errorAction' => 'site/error',

    ),


    'log' => array(

      'class' => 'CLogRouter',

      'routes' => array(

        array(

            'class' => 'CFileLogRoute',

            'levels' => 'error, warning',

          ),

        // uncomment the following to show log messages on web pages

        /*

        array(

          'class'=>'CWebLogRoute',

        ),

        */

      ),

    ),


    'mail' => array(

      'class' => 'ext.mail.YiiMail',

      'transportType' => 'smtp',

      'transportOptions' => array(

        'host' => 'idreamhtml.com',

        //'encryption' => 'ssl', // use ssl

        'username' => 'XX',

        'password' => '',

        'port' => 25, // ssl port for gmail

      ),

      'viewPath' => 'application.layouts.mails',

      'logging' => true,

      'dryRun' => false

    ),


    'image' => array(

      'class' => 'application.extensions.image.CImageComponent',

      // GD or ImageMagick

      'driver' => 'GD',

      // ImageMagick setup path

      'params' => array('directory' => '/opt/local/bin'),

    ),

  ),


  // application-level parameters that can be accessed

  // using Yii::app()->params['paramName']

  'params' => array(

    // this is used in contact page

    'adminEmail' => 'XX',

    'defaultPageSize' => '25',


    'googleMapApiKey' => 'XX',


    // PayPal Settings

    'PAYPAL_API_USERNAME' => 'XX',

    'PAYPAL_API_PASSWORD' => 'XX',

    'PAYPAL_API_SIGNATURE' => 'XX',

    'PAYPAL_MODE' => 'sandbox1' // sandbox/live default=sandbox

  ),

);



Thanks.

I updated the index.php and main.php with what you posted. See error when accessing the index.php attached.

As you can see the the actionIndex in SiteController is called. This is the default route. In actionIndex an attempt is made to retrieve what seems to be a "featured video".

The db table is not found in the configured db. Check which table name is in the $tablename variable (in protected/model/video.php). Seems to be missing in the db.

Assuming you’ve exported (at least) db structure from the old server and imported into the new server.

I had exported the db from the current existing live site phpmyadmin, and imported it via phpmyadmin onto the new server as normal.

The db’s are identical.

(I read that when importing a db through phpmyadmin, it can change any uppercase values to lowercase. Could that have anything to do with this?)

Can i somehow remove the reference to the video table to see if that makes a difference?

When looking at all the table names in the db, there is nothing named ‘Video’, although it finds the word in other tables.