Jump to content

Migrating website from dev server to live server.


Recommended Posts

Hello All,

  I am trying to migrate my website smoothly from dev to prod. I followed this process:

Old Server:

  1. Download the database export.
  2. Download the site folder.

New Server:

  1. Install Processwire from scratch. Was able to get through.
  2. Delete the site folder and Empty the database.
  3. Upload the site folder from the old host.
  4. Import the database from the old host.
  5. Empty site/assets/cache folder and also dropped the caches table from database.
  6. Update the config.php where necessary (database credentials, etc.).

Now when I open my admin panel or website, it gives a whole page of these errors:

Warning: fopen(/var/www/html/GF_website/processwire-dev/site/assets/logs/exceptions.txt): failed to open stream: Permission denied in /var/www/html/GF_website/processwire-dev/wire/core/FileLog.php on line 164

 

Fatal error: Exception: Unable to create directory /var/www/html/GF_website/processwire-dev/site/assets/cache/FileCompiler/site/modules/ (in /var/www/html/GF_website/processwire-dev/wire/core/FileCompiler.php line 239) #0 /var/www/html/GF_website/processwire-dev/wire/core/FileCompiler.php(1068): ProcessWire\FileCompiler->initTargetPath() #1 /var/www/html/GF_website/processwire-dev/wire/core/ProcessWire.php(808): ProcessWire\FileCompiler->maintenance() #2 /var/www/html/GF_website/processwire-dev/wire/core/Wire.php(417): ProcessWire\ProcessWire->___finished(Array) #3 /var/www/html/GF_website/processwire-dev/wire/core/WireHooks.php(951): ProcessWire\Wire->_callMethod('___finished', Array) #4 /var/www/html/GF_website/processwire-dev/wire/core/Wire.php(485): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessWire), 'finished', Array) #5 /var/www/html/GF_website/processwire-dev/wire/core/ProcessWire.php(885): ProcessWire\Wire->__call('finished', Array) #6 /var/www/html/GF_website/processwire-dev/wire/core/ProcessWire.ph in /var/www/html/GF_website/processwire-dev/index.php on line 64
 

Hey now… Error: Exception: Unable to create directory /site/modules/ (in wire/core/FileCompiler.php line 239)

 

Not sure what I did wrong. Any help is appreciated.

Thank you.

 

 

Link to comment
Share on other sites

You need to give the correct rights via CHMOD or CHOWN to some folders. for example the logs directory and the files in it need read and write access. Also it seems that you didn't upload the modules folder. Please assure that the folders 

site/assets/files
site/assets/cache
site/assets/logs 

exist and have the correct rights

Link to comment
Share on other sites

2 hours ago, dotnetic said:

You need to give the correct rights via CHMOD or CHOWN to some folders. for example the logs directory and the files in it need read and write access. Also it seems that you didn't upload the modules folder. Please assure that the folders 

site/assets/files
site/assets/cache
site/assets/logs 

exist and have the correct rights

@dotnetic

I gave all those three folders the read and write permissions. Also I replaced the site folder on the new server with the site folder from the old server. The templates and modules folder have been included in there too. What is the standard procedure? Do I need to install PW on the new server with a blank profile, and then replace the site folder? It seems easy, but I am still missing something.

Link to comment
Share on other sites

It might be that the PHP runs as a different user as the webserver, and therefore has no acces if you only gave rights for the owner and the group. Please check back with your hoster

Link to comment
Share on other sites

@Siddhi Jagtap u.file perms is no write.

/site/assets/* need tobe readerable/writedable to.apache

sound like apache .run as account that.not you - 

mabe find new web host that less truble or u.can

find out.user what apache run as - "apache", "nobody", "buldnog", etc. if user "apache": https://processwire.com/docs/security/file-permissions/#determining-what-user-apache-runs-as

chgrp -R apache /site/assets

find /site/assets -type d -exec chmod 775 {} \;

find /site/assets -type f -exec chmod 664 {} \;

https://processwire.com/docs/security/file-permissions/#how-to-change-permissions-of-existing-files

but also visitarlos cont'la lachpud may helper - https://processwire.com/docs/security/file-permissions/

  • Like 3
Link to comment
Share on other sites

Thanks all. It now works find. Had to adjust the permissions of the folders. I am now trying to map my website to a live URL say www.something.com. As per a few forum posts, I put the site directory, wire directory, .htaccess and index.php in my docroot folder and also made sure to give read and write permissions to the necessary folders which is site/assets, site/modules, site/assets/cache, site/assets/files, site/assets/logs. But when I open the website domain, I get these errors. My docroot points to /var/www/html/test_website.


Warning: file_put_contents(/var/www/html/test_website/site/assets/cache/FileCompiler/site/templates/home.php): failed to open stream: Permission denied in /var/www/html/test_website/wire/core/FileCompiler.php on line 400

Warning: fopen(/var/www/html/test_website/site/assets/logs/file-compiler.txt): failed to open stream: Permission denied in /var/www/html/test_website/wire/core/FileLog.php on line 164

Anything I might be missing while mapping?

Link to comment
Share on other sites

6 hours ago, Siddhi Jagtap said:

Thanks all. It now works find. Had to adjust the permissions of the folders. I am now trying to map my website to a live URL say www.something.com. As per a few forum posts, I put the site directory, wire directory, .htaccess and index.php in my docroot folder and also made sure to give read and write permissions to the necessary folders which is site/assets, site/modules, site/assets/cache, site/assets/files, site/assets/logs. But when I open the website domain, I get these errors. My docroot points to /var/www/html/test_website.


Warning: file_put_contents(/var/www/html/test_website/site/assets/cache/FileCompiler/site/templates/home.php): failed to open stream: Permission denied in /var/www/html/test_website/wire/core/FileCompiler.php on line 400

Warning: fopen(/var/www/html/test_website/site/assets/logs/file-compiler.txt): failed to open stream: Permission denied in /var/www/html/test_website/wire/core/FileLog.php on line 164

Anything I might be missing while mapping?

this is surely related to the file/folder permission issue. Please try clearing cache as well. 

But I would like to suggest another way of moving PW work from dev machine to Production Live.  Once you finished the development, you can follow as below steps

  • install this module Profile Exporter for ProcessWire 2.5+ (  Admin => Module => New , then use the Module Class Name method )
  • upon successful installation Admin => Export Site Profile 
  • This will give you a form to give a name, title and image for the profile and lets you export into zip format
  • Upload this file into Production/Live server root (wherever you like to install  PW)
  • Upload the PW  Master version and extract it
  • Copy/Move your site profile backup file and extract it 
  • Now, you will have site profiles folders like site-classic, site-blank, and site-the-name-you-have-given
  • go to the installation URL and you choose your site-the-name-you-have-given from the menu and install it
  • this will import the database, files, assets and everything. 

I hope this works for you. 

  • Like 1
Link to comment
Share on other sites

2 minutes ago, JeevanisM said:

this is surely related to the file/folder permission issue. Please try clearing cache as well. 

But I would like to suggest another way of moving PW work from dev machine to Production Live.  Once you finished the development, you can follow as below steps

  • install this module Profile Exporter for ProcessWire 2.5+ (  Admin => Module => New , then use the Module Class Name method )
  • upon successful installation Admin => Export Site Profile 
  • This will give you a form to give a name, title and image for the profile and lets you export into zip format
  • Upload this file into Production/Live server root (wherever you like to install  PW)
  • Upload the PW  Master version and extract it
  • Copy/Move your site profile backup file and extract it 
  • Now, you will have site profiles folders like site-classic, site-blank, and site-the-name-you-have-given
  • go to the installation URL and you choose your site-the-name-you-have-given from the menu and install it
  • this will import the database, files, assets and everything. 

I hope this works for you. 

I had initially tried using Profile Exporter following the same process as you mentioned. When I arrived at the installer and selected the site-the-name-you-have-given profile, it kept giving me an error saying ' Profile not found'. I ultimately gave up and did the migration manually.

I actually am struggling post the migration now. I was able to map my website domain. The homepage.php file which is essentially my homepage opens on loading the domain(have included this file in my home.php file). However the server is unable to find any of the other pages. All of them are in the site/templates folder along with the homepage.php. But when I say add a link redirecting to ./about.php, the URL caught is www.mywebsite.com/about.php. This gives me a URL not found error. Also for most of the other pages, the data from the admin panel is not getting rendered. On some it does and on other it does not. It gives an error saying 'Trying to get property of non-object'. I am not sure what is going on and if I messed up with the migration.

 

Other things I did:

- whitelisted my domain in config.php

-changed permissions of site/assets to read and write 

-changed the owner of the site folder to the apache owner

 

Any suggestions would really help.

Thanks.

Link to comment
Share on other sites

Quote

But when I say add a link redirecting to ./about.php, the URL caught is www.mywebsite.com/about.php

how are you linking to the about page ?  can you put this below code in your home page and try clicking the link working or not ? 


 

   <!-- top navigation -->
    <ul class='topnav' role='navigation'><?php

        // top navigation consists of homepage and its visible children
        $homepage = $pages->get('/'); 
        $children = $homepage->children();

        // make 'home' the first item in the navigation
        $children->prepend($homepage); 

        // render an <li> for each top navigation item
        foreach($children as $child) {
            if($child->id == $page->rootParent->id) {
                // this $child page is currently being viewed (or one of it's children/descendents)
                // so we highlight it as the current page in the navigation
                echo "<li class='current' aria-current='true'><span class='visually-hidden'>Current page: </span><a href='$child->url'>$child->title</a></li>";
            } else {
                echo "<li><a href='$child->url'>$child->title</a></li>";
            }
        }

        // output an "Edit" link if this page happens to be editable by the current user
        if($page->editable()) {
            echo "<li class='edit'><a href='$page->editUrl'>Edit</a></li>";
        }

    ?></ul>

 

 

and please check the about page has templates set and published and no permission issue 

 

image.png.9efb8060bae30b7a878f98246228778c.png

Link to comment
Share on other sites

12 minutes ago, Siddhi Jagtap said:

It gives an error saying 'Trying to get property of non-object'.

depends on the way you are getting the page URLs. If you are getting page links using page ID, please check the if the correct Page ID exists. You can check this in admin section. If the page IDs are not matching, it may throw error. Another possible situation for non object error is, when you try to output a string/url instead of an object. An explanation is here

Link to comment
Share on other sites

17 minutes ago, JeevanisM said:

how are you linking to the about page ?  can you put this below code in your home page and try clicking the link working or not ? 


 

   <!-- top navigation -->
    <ul class='topnav' role='navigation'><?php

        // top navigation consists of homepage and its visible children
        $homepage = $pages->get('/'); 
        $children = $homepage->children();

        // make 'home' the first item in the navigation
        $children->prepend($homepage); 

        // render an <li> for each top navigation item
        foreach($children as $child) {
            if($child->id == $page->rootParent->id) {
                // this $child page is currently being viewed (or one of it's children/descendents)
                // so we highlight it as the current page in the navigation
                echo "<li class='current' aria-current='true'><span class='visually-hidden'>Current page: </span><a href='$child->url'>$child->title</a></li>";
            } else {
                echo "<li><a href='$child->url'>$child->title</a></li>";
            }
        }

        // output an "Edit" link if this page happens to be editable by the current user
        if($page->editable()) {
            echo "<li class='edit'><a href='$page->editUrl'>Edit</a></li>";
        }

    ?></ul>

 

 

and please check the about page has templates set and published and no permission issue 

 

image.png.9efb8060bae30b7a878f98246228778c.png

The about page is actually not a child of the homepage. They are independent of each other. I checked the above and the 'about' template has been set for the about.php page without any access issues. Also I am using stuff like <?php echo $page->about_us_img->url; ?> OR <?php echo $page->about_us_title; ?> to pull data. This is working fine on the dev server so I am not sure if it is still an issue with the code.

When I am linking the pages, I have a navbar on the Homepage. It has an About Us section and I put the href value as ./about.php for example. It takes me to a page www.mywebsite.com/about.php and it is unable to find that URL on the server.

Link to comment
Share on other sites

8 minutes ago, Siddhi Jagtap said:

Also I am using stuff like <?php echo $page->about_us_img->url; ?> OR <?php echo $page->about_us_title; ?> to pull data. This is working fine on the dev server so I am not sure if it is still an issue with the code.

well, just for a testing, can you try to put a test  link using this 

 

<?php echo $pages->get(1001)->url; ?> // where (1001) is the page ID, you can see this page ID from admin. 

image.png.a6629d3782f71f9a1c2db5c6020205eb.png

Link to comment
Share on other sites

9 minutes ago, JeevanisM said:

well, just for a testing, can you try to put a test  link using this 

 

<?php echo $pages->get(1001)->url; ?> // where (1001) is the page ID, you can see this page ID from admin. 

image.png.a6629d3782f71f9a1c2db5c6020205eb.png

Tried this for the About page. The URL echoed is /about-us/ (which is what is set under admin for the about.php page). It takes me to www.mywebsite.com/about-us/ and gives me the URL not found on server error.

Also another thing I observed that on the admin panel, when I click on View for the About page, it takes me to www.mywebsite.com/test/about-us and gives the same URL not found error. The 'test' folder is where the site dir, wire dir, .htaccess and index.php files are. Essentially that is the document root where the domain is pointing. However on the admin panel as you can see that folder name is still appearing after the domain address. Could this discrepancy causing all this? Just a guess, not sure.

What should the admin URL be after migration? Does that change too?

Thanks.

  • Like 1
Link to comment
Share on other sites

 

59 minutes ago, Siddhi Jagtap said:

When I arrived at the installer and selected the site-the-name-you-have-given profile, it kept giving me an error saying ' Profile not found'. I ultimately gave up and did the migration manually.

There is a quick dirty fix is to rename the exported folder name into ' site ', this will bypass the profile not found error. 

Link to comment
Share on other sites

1 minute ago, JeevanisM said:

 

There is a quick dirty fix is to rename the exported folder name into ' site ', this will bypass the profile not found error. 

Ok. So when I select that rename it and select the profiler, I run the installer like normal. And then after that would I need to move the site wire htaccess index.php out of the processwire folder to the document root. Would that work smoothly?

Link to comment
Share on other sites

9 minutes ago, Siddhi Jagtap said:

Tried this for the About page. The URL echoed is /about-us/ (which is what is set under admin for the about.php page). It takes me to www.mywebsite.com/about-us/ and gives me the URL not found on server error.

Also another thing I observed that on the admin panel, when I click on View for the About page, it takes me to www.mywebsite.com/test/about-us and gives the same URL not found error. The 'test' folder is where the site dir, wire dir, .htaccess and index.php files are. Essentially that is the document root where the domain is pointing. However on the admin panel as you can see that folder name is still appearing after the domain address. Could this discrepancy causing all this? Just a guess, not sure.

What should the admin URL be after migration? Does that change too?

Thanks.

ok, then I guess we need to check the .htaccess file. Is there any .htaccess file in root folder ? trying to meddle with the URL and root folder ? 

and I migrated  one of my old PW site backup   as a subfolder to my main website, my admin URL go like this 

https://mymainwebsite.com/subfoldername/adminname/  

Link to comment
Share on other sites

3 minutes ago, Siddhi Jagtap said:

Ok. So when I select that rename it and select the profiler, I run the installer like normal. And then after that would I need to move the site wire htaccess index.php out of the processwire folder to the document root. Would that work smoothly?

I dont usually do this, I am not expert in PW but usually, I just follow the normal installation and website works right away. There will be some mismatch with external links / images which can be solved easily. I usually get my navbar menu using page ID only. 

 

 

Link to comment
Share on other sites

1 minute ago, JeevanisM said:

ok, then I guess we need to check the .htaccess file. Is there any .htaccess file in root folder ? trying to meddle with the URL and root folder ? 

and I migrated  one of my old PW site backup   as a subfolder to my main website, my admin URL go like this 

https://mymainwebsite.com/subfoldername/adminname/  

Ok so the admin panel url sounds about right. There is a .htaccess file in the root folder. What do I need to do with it?

Link to comment
Share on other sites

8 minutes ago, Siddhi Jagtap said:

Ok so the admin panel url sounds about right. There is a .htaccess file in the root folder. What do I need to do with it?

If you open the .htaccess file, you can see a section like below 

image.png.66201292a072e46b9596fae5c81f111c.png

usually, the website should work straight away, but in you case, just try if you can add your subfolder name as rewrite base.

Link to comment
Share on other sites

1 hour ago, JeevanisM said:

If you open the .htaccess file, you can see a section like below 

image.png.66201292a072e46b9596fae5c81f111c.png

usually, the website should work straight away, but in you case, just try if you can add your subfolder name as rewrite base.

Ok, so I tried adding some gibberish to the .htaccess file and my home page still loads without a 500 error. So maybe the server is not reading the htaccess file.

My site folder is in the root directory it self. Do I still need to add anything to Rewrite base?

Link to comment
Share on other sites

1 hour ago, Siddhi Jagtap said:

Ok, so I tried adding some gibberish to the .htaccess file and my home page still loads without a 500 error. So maybe the server is not reading the htaccess file.

My site folder is in the root directory it self. Do I still need to add anything to Rewrite base?

hmmm,  we seem missing something obvious. lets see..

  • try installing a fresh latest master branch of PW in the folder ' test ' in your server root (inside public_html if you are in cpanel )
  • if this works, you should access the admin :  http://yourwebsite.com/test/admin (you can give different admin name if you want)
  • try to see the pages and if it works 

if the above works - you can try same method but this time install your actual site profile backup (taken from your development ). So you can rule out issue of the server problems. If the issue persists, its something mal-configured in your site profile. you can enable debug inside site/config.php 

$config->debug = true;

 

Link to comment
Share on other sites

3 hours ago, Siddhi Jagtap said:

Ok. So when I select that rename it and select the profiler, I run the installer like normal. And then after that would I need to move the site wire htaccess index.php out of the processwire folder to the document root. Would that work smoothly?

I dont understand this fully, but ideally, all your PW related files/folders should be inside that ' test ' only, if you want this website work in the subdomain way. If the website should be as the main domain, all your PW files should be the public_html folder (docroot), whichever the case, you should do this in the installation steps, not after that .

 

to give you a clear understanding, below is my folder structure , bhimon is my subfolder where I installed my PW backup and website is accessed as 
http://www.jeevanism.com/bhimon

image.png.94684e854de1f1c95779c91a4ccfed11.png

Link to comment
Share on other sites

3 hours ago, Siddhi Jagtap said:

Ok, so I tried adding some gibberish to the .htaccess file and my home page still loads without a 500 error. So maybe the server is not reading the htaccess file.

You are right!

If you add some gibberish, the server has to respond with a Error 500.
If it doesn't, the htaccess is not read by the server, and therefore URLs like /about-me/ won't work, aka as rewriting.

This should be your first task. Get the htaccess to work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...