moving site to new server

Hi.

Premise: I am not a coder.

I would like to move my site which has been made using yii (not by me) to another host.

Before going on with the domain transfer I want to make sure it’ll work fine, so I made a copy of all directories and files, I first tried to test it on my local pc (wamp environment), and all I get is the list of directories and files, thinking the problem was with my setup I uploaded all in a subdirectory on live site, and here again all I get is the list of directories and files.

I created a database, and imported the database, and then edited ../common/config/main-local.php like this:


'db' => [

'class' => 'yii\db\Connection',

'dsn' => 'mysql:host=localhost;dbname=newdb',

'username' => 'newdb_username',

'password' => 'new_db_psw',

'charset' => 'utf8',

],

In the requirements.php these are the warnings:

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

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

Memcache extension Warning MemCache

APC extension Warning ApcCache

Expose PHP Warning Security reasons "expose_php" should be disabled at php.ini

What am I missing, what else do I need to change?

Thank you

To try your app you need access by http://localhost/app_name/frontend/web and http://localhost/app_name/backend/web, if all run fine you can upload end deploy to the other server.

But after change the DNS make a several tests on a new host.

Thank you.

What do you mean by app_name?

Actual live site > example.com

Yii files are in the root of current server

I copied those files and put them in:

localhost/my-yii-test

In the other server I just created a subdirectory and copied all files in it, like this:

http :// mysite dot com/my-yii-test

I don’t know if it is common practice, but I see there is an htaccess file with redirects on the root of example.com

Please take a look here for further details of what I have been trying with some error logs:

http ://stackoverflow dot com/questions/32477738/transfer-yii-site-to-new-server

Please note: being new I am not allowed to embed links, that’s why I used spaces and “dot”

Thanks again.

EDIT:

I forgot to mention that when I navigate to frontend/web/index.php I get a blank page, both on local test, and web test; and when going to backend/web I get 403 on the web, and page not found on local.

In the local test by changing the htaccess file I managed to get directly to the "homepage" when putting localhost/my-yii-test in the address bar, so I guess the real problem is why I get a blank page.

I made a little progress, changing htaccess andsome parameters in config files, now the top menu is showing, but the pages return 404:

I am not sure if the pages are stored in database, or else, so any hint where to look at would be appreciated.

Made another little step.

Now I can see the login form when navigating to:

/my-yii-test/backend/web/site/login

Problem is how to find the password, I have access to database, but I don’t know how the password hash, and auth_key are used, and encrypted.

EDIT

On my local test I tried accessing with admin/demo, and now I get a blank page when going to backend/web/site/login

On the live server test it just tells me it’s the wrong user/password

Tried accessing some pages directly, and Looked at some error logs, and here are the reports:

The lines are:


$this->title = 'Signup';

$this->title = 'My Yii Application';

Other errors when trying to access other pages:

The line is:


$this->title = Yii::t('app', 'Pages');

> Class ‘Yii’ not found

Add


use Yii;

Thank you.

Where should I add it?

I tried adding it to

/my-yii-test/backend/modules/shopadmin/views/page/index.php

and get this error as well:

I have this at the beginning of the file


use yii\helpers\Html;

use yii\grid\GridView;

use yii;

I tried it on other couple of index.php files in the modules/shopadmin/views, and basicaly get the same error for them as well.

BTW when browsing to those pages all I see is a blank page.

It’s because you need to use Yii instead of yii.

Your question about where to add it indicates that you are not familiar with namespaces importing. Read this first http://php.net/manual/en/language.namespaces.importing.php

Thank you.

I changed yii to Yii, and get the same error.

I read the link, but it really did not help, as I guess I first would need to learn php, anyhow by “where should I add it” I meant which file more than where on the file, as by seeing the “use” used at the beginning of the file I guess that’s where it should be added?

Maybe I created some confusion with my trials, and the reports, the files I have are working fine on the actual server, and I would guess that for it to work on the new server should be more of configuration and setup, rather than code change?

i.e. database path, basepath, baseurl, and most probably the htaccess?

Will you please kindly zero it, and we start from the OP, perhaps going step by step of what you would think could be the issues to look at first?

Ok, looking at the OP - this probably is about the host configuration like Cálcio said.

Here is the default config for Apache and Nginx http://www.yiiframework.com/doc-2.0/guide-start-installation.html#recommended-apache-configuration

Make sure you point the domain (virtual if you want) to the right folder.

Thank you.

Yes I have read that, and http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html#deploying-an-advanced-application as well, as other docs; indeed the progress described in posts #3 and #4 are somehow thanks to that.

Like said right now when navigating to mysite dot com/my-yii-test part of the homepage (top menu and footer) is displayed, and it was achieved by editing

my-yii.test/.htaccess

my-yii.test/frontend/config/main.php

What is missing is the content, and so is for all other pages.

My guess is the content is in database, and that for some reason the database connection is not working, I edited:

my-yii.test/common/config/main-local.php

to the new database details, but it does not seem to work.

Another piece missing is the sub-menu of the main menu (top menu), meaning that when I click on the item (page) that has sub-pages the sub-pages link do not show in the menu (the original site does); maybe these too are in the database(?).

I’m afraid that we cannot help you without looking at this app and its configuration. So far few of our ideas were wrong and it’s pointless to flip the common solutions over and over again. This topic is two weeks old but you should be able to resolve the problem much much faster on your own.

I can see that you have got some ideas what is wrong with the app. Good! Test your suspicions one by one.

Db connection?

  • Check which one you are using in the current controller.

  • Check configs in frontend and backend as well.

Maybe view problems?

  • Use debugger tool or just plain “die(‘1111’);” in various places to see if you are in the right file.

And so on…

If there is a problem with the specific method of checking something (like, I don’t know, how to check the db connection I’m using right now) ask us.

First of all I really appreciate your patience, and once again thank you.

In case I will attach the files, one of the problems is I don’t know if I have looked at all of them - read I don’t know the list of files to look at for all the configurations

problem is I don’t know all the testing routines, please keep reading.

Where to check "current controller"? I mean how would I check that?

The only place I saw reference to the database is root/common/config/main-local.php

I believe I put the info correctly, is there a way I can check if the connection is working?

Will you please elaborate on how to do so: use of debugger tool, or the “plain “die(‘1111’);””, shall I add die(‘1111’); to files in frontend\views\site?

Like I did up here (this post), or shall I open new threads?

You said you are not a coder which makes it difficult for me to suggest you anything…

Are you familiar with MVC pattern?

Anyway in your previous posts you mentioned backend and frontend. This probably means that you have got app build on an advanced project template. Your one domain should point to frontend/web and other to backend/web. These two can get two different db connection configurations or use shared one from common/config.

There might be default controller in each called SiteController with actionIndex method in it so it can be accessed by (front or backend domain)/site/index url (or /index.php?r=site/index).

In this action you can add


var_dump(Yii::$app->db);die();

and see what’s inside.

Wouldn’t be better to just call some coder (maybe app’s author) to move it to another host?

Thank you.

I read about it in wikipedia, I get the concept, and that’s where I stop.

I understand your frustrtion trying to help an illiterate, and like said I appreciate your patience, though not a coder I usually am able to follow instructions, and try to give as much feedback as possible, though sometime due to my lack of knowledge I may be a bit confusing.

Yes it is the advanced one.

I found reference to the db only in the /common/config/main-local.php file, well actually there are some other references in a backup directory, but I guess they are not relevant to the functionality of the app.

/backup/cms/db_replace.php

/backup/database.php

/backup/tasks/fetch_db_dump.sh

Yes there are SiteController files in both frontend, and backend.

This is the actionIndex snip:


    public function actionIndex() {

    	return $this->render('index');

    }

I tried these:


    public function actionIndex() {

    	return $this->render('index');

	var_dump(Yii::$app->db);die();

    }


    public function actionIndex() {

    	//return $this->render('index');

	var_dump(Yii::$app->db);die();

    }


    public function actionIndex() {

    	return var_dump(Yii::$app->db);die();

    }

And none did anything.

I did create a test file (/common/config/db_test.php) with db connection, and data retrieval code snip from w3scool site, and when navigating to the file in the browser it displays the db info set in the SELECT statement, so I guess db info, and connection is fine.

I can’t afford that, plus other reasons.

Are you still testing it on your local machine? If so what is your host configuration?

No, I gave up testing there, I am testing on a live server as a subdirectory of a site: example.com/my-yii-test.

Do you have it set properly in subdirectory? Check

Considering the header (top menu), and footer are showing up correctly, and that when hovering over the menu items the path shown in the bottom left of browser is correct, I’d say I have set that correctly.

Anyhow I did check the links provided (which are for the basic) and checked frontend/config/main.php and I have this:


        'assetManager' => [

            'basePath' => '/user-path/public_html/my-yii-test/frontend/web',

        ],

        'request' => [

            'baseUrl' => 'http://www.example/my-yii-test'

        ],

        'urlManager' => [

            'baseUrl' => '/',

        ],

I added my-yii-test to urlManager base Url, but nothing changed.

I also tried adding

RewriteBase /my-yii-test

to htaccess in my-yii-test directory, still no joy.