Moving Site to New Server ~ Error


All i need to do is move a site - that I did not build, but worked out uses the YII framework - to a new server.

I have downloaded all files, uploaded them to the new server.

DB has been downloaded, a new one created in cPanel/MySQL, old one imported.

I have opened the files in protected/config (main.php, console.php) and edited them with the new db/user/pass.

I downloaded/uploaded the Requirements folder and everything has passed.

I have checked php.ini and PDO support is enabled (sqlite, mysql)

PHP Version 5.4.45

When i visit h ttp://serverip/~username/index.php I get:

The {serverip} page isn’t working

{serverip} is currently unable to handle this request.


I tried editing my hosts file (thinking maybe it is the ‘temp’ url causing the problem)…



but that makes no change/difference.

I deleted everything in .htaccess but that makes no difference.

Can someone PLEASE help me understand what else I need to do? ANY help is appreciated.

Have you checked the server’s error log? It should say something about the error 500.

Thanks for the response.

The only thing appearing is:

/home/username/public_html/.htaccess: Invalid command ‘sudo’, perhaps misspelled or defined by a module not included in the server configuration, referer: h ttp://ipaddress/~username/index.php

Searched the entire site for ‘sudo’ but found nothing of note.


According to the message it should be in "/home/username/public_html/.htaccess"

It’s strange though that the message say “referer: h ttp://ipaddress/~username/index.php”

What’s in /home/username/public_html/index.php?

(In linuxes "sudo" is a prefix used for running a command with "su" privileges.)

Not sure what you mean by what’s in /home/username/public_html/index.php?

I’m just trying to access the index page in the root.

(I don’t know if that error appeared after i deleted everything in the .htaccess file as a test.)

Yes, that would be the index.php in the webroot. What’s in it? If I understand correctly you don’t know any details of this app, neither does this forum. The start script content can give a clue about Yii major version (1.1 or 2.0) as well as some of the possibly non-standard directory structure. Or better, show us the complete dir structure.

Did you install the app directly under the webroot and was it previously installed the same way?

One thing you should do is to empty the <app webroot>/assets and (e.g.) protected/runtime dirs (also check that web users have write access).

Did the .htaccess file look similar to this? The the app would be configured for "path format" url and to hide the start script. Without the rewrite in .htaccess, you should still be able to access the app (e.g. server/username/index.php/controller/action where possibly site/view is the default controller/action)

(Not sure about this but you might need Option FollowSymlinks or SymlinksIfSameOwner in .htaccess)

Thanks for the reply, it is very much appreciated.

Site has to be Ver 1 (older site, found ‘copyright 2008-2013’ reference).

Below is the index.php code:


error_reporting( error_reporting() & ~E_NOTICE );

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

if ($_SERVER['HTTP_HOST'] == 'localhost') {

    $env = 'local';

} elseif ($_SERVER['HTTP_HOST'] == '' || $_SERVER['HTTP_HOST'] == '') {

    $env = 'production';


define('YII_ENVIRONMENT', $env);

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

$configServer = $env=='local' ? array() : include dirname(__FILE__) . '/protected/config/'.$env.'.main.php';

// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG', $env == 'local' ? 1 : 0);

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

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

if (file_exists(dirname(__FILE__) . '/maintenance.flag')) {

    echo "<h1 style='font-family: Helvetica; arial;'>Site is in maintenance mode. Check back after sometime.</h1>";




$config = CMap::mergeArray($configLocal, $configServer);


Here is the directory structure:

I haven’t installed the app. From what I read all I needed to do was upload all the files from the existing to the new server (both under public_html). Import the db, then update the db references in the protected folder.

Should I be ‘installing’ yii on the server?

Assume this would make sense if i was to delete everything in the /assets folder and /protected/runtime folders?

Should both these main folders have 777 permission?

Below is the .htaccess code

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript


# Set up caching on static resources for 1 year based on Google recommendations

<IfModule mod_expires.c>

ExpiresActive On

<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|js|css|gif|jpg|jpeg|png|swf)$">

ExpiresDefault A29030400



RewriteEngine on


order deny,allow

allow from all


RewriteCond %{HTTP_HOST} ^([a-z.]+)?mysite\.org$ [NC]

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteRule .?{REQUEST_URI} [R=301,L]

# if a directory or a file exists, use it directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php

RewriteRule . index.php

There is no /controller or /site folder.

However there is a /protected/controllers folder (not containing an action/ folder) and a /protected/views/site folder.

In this case the Yii framework has been placed under the /protected/framework dir

The server config will be dependent on the actual domain. It will never kick in in the temp domain case.

The local config is in the normal config dir. The server config is in subdir /protected/config/production.

Debug enabled in local mode only. (You may want to enable debug temporarily)

Effective config will be the local config merged with server config ("" only)

The Yii app normally consists of index.php, assets dir and protected dir (minus the framework dir). Some more dirs under webroot may be Yii app (config) related.

Yii seems to be already included (in /protected/framework).

/assets folder can be safely emptied. Normally /protected/runtime too. (Keep a copy of original content)

Or perhaps 775 with web user group?

I’m not a .htaccess expert.

The first part obviously is dependent on actual domain.

/protected/controller for controllers (actions are methods in the controller)

/protected/views/<controller>/<action> for views

Have a look at the app template dir structure (scroll down)

Example entry script.

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.


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.



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


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



This doesn’t

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



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


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


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



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:



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




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







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