Moving a wordpress blog to a new host with the same domain name - wordpress

I have just signed up to a new webhost with the same main domain name as my previous host. I downloaded the whole site via FTP and also exported the database in phpMyAdmin.
After changing the wp-config.php file so that the database name, username and password matched the details for my new host, I uploaded the files to the public_html folder (same directory as on the old host) and also imported the database.
Whilst I can log in, nothing has really saved. I had to set the theme again, none of the posts display etc. The information is all in the database, so I don't understand what has gone wrong.
What do you think the problem could be?

Check if you got all the files. Important files that could be missing are .htacces files: they are 'hidden' (that's what the . kinda says, and some FTP programs just ignore them
Check if you are actually working on the correct host. If the DNS isn't pointing correctly (it can differ between sessions if it isn't propagated!), you're messing with 2 servers :)

The way you described, everything should work. Also make sure you clear your cache and cookies so that the new server is recognized with your install. Also make sure that your URL settings have not changed in the general tab in the admin side.

Related

WP site keeps getting hacked for a cryptojacker - How to find the leak?

I've got a site that has been hacked for the fourth time now this month. With scripts hosted on autofaucet.org. (sloppy code even, found their names. Some Russian dudes. But that's off topic) I've taken some measurements to prevent a new hack, but alas...
I've installed a clean WP installation on the server, with clean files and a clean DB.
reinstalled the plugins clean
I have All In One WP Security & Firewall plugin for file scanning, firewall, hide inlog page, etc.
Changed all the wordpress passwords.
I've notices the encoded code is being placed in files called assets.php.
I'm curious how a hacker would inject/place the code on the server. How to prevent it better and what questions to ask the webhost company. I've asked them before and they just say it's my fault, update the wp installation and move on. What should they check if the code is injected from their side?
Your log files (of the web server) e.g. /var/log/nginx/access.log with the nginx web server will tell you who it was. Look for the change date/time of the assets.php file. Then check server access logs for IP addresses from that exact time. Then search logs for that IP address. You will find the first accesses by that IP address. That was likely the hack.
Usually Wordpress plugins are to blame as long as you keep the WP site updated. So, you could disable plugins not needed urgently, and disable the others one by one, or all for testing.
As a workaround, you can make the index.php (or other) file under attack read-only. In the past I have worked around particular attacks by chown root.root filetobeattacked.php which usually works (but may hinder updates, so it's a temporary solution). If you are not root on the server (shared hosting) perhaps chmod 444 filetobeattacked.php could work.
I had same issue before. It might be the wordpress core files.
Delete all files except wp-content, then download and replace it with the new wordpress files.
Search for 'autofaucet.org' inside wp-content, and remove if necessary.
Open wp-contents/themes/ then check functions.php - check if any additional code is there on top. Check the last updated files and time inside the theme and plugins.
Export database files and searcg for 'autofaucet.org' and remove if any item found.

phpadmin password change - creates error establishing database connection on wordpress

I have created a wordpress VM in GCP and all works perfectly. After the creation it is recommended that you change the temp passwords (makes sense). When I change the temp password on phpmyadmin the wordpress vm loses it's host. When i change the password back again to the original temp password the wordpress site comes back up again.
So I assume there is a connection between myphpadmin credentials and the wordpress host but I don't know where this relationship resides in the database and how to change both sets of credentials so that i can change the phpmyadmin password and maintain the connection to the wordpress site.
Happy to provide more info - im actually sure this is a very basic issue but struggling to find articles to help.
Cheers
The credentials you enter in phpmyadmin is actually not to access phpmyadmin itself, but rather for phpmyadmin to access the database. Then, the phpmyadmin is pointed to the same database as your wordpress site, so if use the same credentials for both and you change said credentials, you need to specify the new ones for both the phpmyadmin and wordpress.
This is not specific to GCP.
I just wanted to update my own question in case someone else is a new as me. I am also sure there are more efficient ways to achieve the answer but this is how I did it.
My struggle was that I did not know how to access wp.config.php file which contained the password of my wordpress data base. So I was changing myphpadmin password and then losing the data base as the credentials were different. Then I was at a loss as to how to actually change the wp.config file to match the new password.
To do this I did a number of steps. I will also add helpful links to resources below.
I installed an FTP client and established a connection with my google cloud vm.
I located the wp.config file, in my case this was /var/www/html
I exported the file and updated the password to match myphpadmin password.
I re-imported but as I didn't have permissions to re-import to the same location (never did figure this out) I re-imported to the user folder found /home/
I then went back to my googlecloud console, SSH in and as the root user moved the file from the folder I re-imported to the correct folder as mentioned above (/var/www/html). This then overwrote the existing file and updated my password.
Helpful resources
Setting up FTP: https://onepagezen.com/google-cloud-ftp-filezilla-quick-start/
Moving files through SSH: https://www.siteyaar.com/fix-sftp-ftp-permission-denied-on-google-cloud/#solutions
FTP error handling: https://onepagezen.com/fix-ftp-permission-errors-google-cloud/
I hope this is helpful later down the line for someone else. Also please if you are reading this and are able to help other users (as well as myself) cut down on these steps, submit additional responses.

Final steps for moving Wordpress site to another server

Ive read many other threads here and also guides as this is my first time moving a Wordpress site to another server and I think Ive done everything correct so far but not sure.
So far Ive done the following:
Backed up WP files and moved them to public_html of new server and ip
Created a new Mysql db along with user and imported the old DB
Checked the imported DB in phpmyadmin and everything seems to be
there Changed wp-config file to the new db details
Also defined the site url in wp-config like so:
define( 'WP_SITEURL', 'http://www.example.com' );
Finally Ive changed my local hosts file to the following:
new.ip.here example.com
when I visit example.com it seems to redirect to www.example.com which I believe should be my site as it is still on the old/current server.
I logged in to WP anyway and did a test post but the post then appeared on the site on the old server which I guess confirms what I said above?
When I run the following ping commands I get these results though
ping example.com - new ip returned
ping www.example.com - old ip returned
Have I done everything correct so far and if so how can I test the site on the new server if its redirecting me away?
thanks
Something I do each time to be sure that I didn't forget anything is to search for my old domain name in all the base and change to the new one. Because sometimes there are hard links in posts or pages...
If you made your own theme, verify there too... Sometimes people make this mistake to put hard links...
For your host files, this will work only for YOUR computer. Check if the DNS are correct instead. then the changes ill apply to everyone.
I had created the new mysql db and user in ssh and not cpanel, even though Id checked the permissions and everything seemed in order when I logged into mysql admin in cpanel for this ip it showed no dbs and users at all for that account, strangely though the db I had imported was there in phpmyadmin.
I created a brand new db & user in mysql admin and then used both the domain plus with 'www' in my hosts file and it looks like I can see the site on my new server now and done a test post which only appears there so I think this has fixed it.

What step have i missed? Transferring wordpress site

So i have recently tried to transfer my wordpress site to another server.
I have followed a few guides, but i definately seem to be missing a step.
Basically what i have done is:
export original database (phpMyAdmin)
Save all relevant files (ftp)
install fresh wordpress on new server. (wp backend)
'drop' all table fields in new wordpress (phpMyAdmin)
import original database to new location (phpMyAdmin)
transfer theme, plugins, uploads. (ftp)
activate theme, plugins. (wp backend)
update permalinks. (wp backend)
The problem is, i am left with a default looking wordpress installation, and not my orginal page-home.php and corresponding css.
Also, if i go to wordpress backend SETTINGS > READING > Frontpage:static; i only have the option of 'about', not home, i should have 'home'...
Sorry if i am vague, let me know if any screenshots are required.
We really need a little more info like:
when you say plain, do you mean just the theme is not set and you're on the default theme, or there is no theme, or do you mean even your content is not there?
the site you removed it from, where was the installation located? Was is in the public_html folder or a subfolder of that? Did you put it in the same place, ie not inadvertently put it in a different folder
(I've actually typed the bulk of the post and come back to the top for this one, but):
Are you sure you're checking the right site?
Have you kept the same domain name?
Has the domain name propagated to the new server?
Is the CSS being loaded from the correct domain (has anything been hardcoded to the old server)
Let's go through a few broader options:
1. Check how many WordPress installs are on your domain
First off, it sounds like you may have two WordPress installations. If you have the backend setup correctly with your themes but you're seeing a plain site, it sounds like you're looking at another install. I'm not saying you do have multiple installs, but it is a place to start looking.
A question to ask yourself here is: In this plain looking site, do you see your content, or the content of a default site? If you see your content, you may jump ahead to section 2.
If you're saying there is a home page but you're not seeing it as available under static pages, either:
You're looking at another site (but there should be a home page* even in a default setup—from memory), or
You're Home Page title may have changed, or have become "unpublished", ie reverted to a draft, or pending review. Check the page:
actually exists,
has the title you're looking for
the slug hasn't changed
(*note: although it could be a Welcome Page I'm thinking of here.)
Double check the database
The easiest way to do this is to go into your database and see how many WP databases there are. Check each database and look for the underlying table structure, it sounds like you should be able to identify it pretty easily. If it's not a multisite install, the table prefixes should be wp_ unless you changed them somewhere.
While you're playing around in the database, Take note of the database name and table prefix.
Double check the folder structure
Have a look for a second instance of your folder structure, maybe you dropped it into the wrong place).
2. Check the WordPress installation is actually connected to the database
Check the WordPress configuration file wp-config.php is connected to the database. Check wp-config.php sample from codex, you'll want to see the correct database name and table prefix in there.
From here you should also check the username has been setup correctly and is as you expect it. Remember, the database name will likely have a different prefix between hosting providers, unless you've managed to keep the same login name with each provider. ie, I'm talking about the database prefix here, not the table prefix.
(another note: most database connection issues will result in errors appearing on the page in lieu of your site, which leads me to believe it's at least partially setup correctly.)
TEST: What you can do is rename the old wp-config.php to something else and don't create a new one, then visit the website and it will lead you into setting it up again where you can enter the database details (your site info will still be intact, this will only reset your config file, not the database, although it could reset the connection between the filesystem and database).
3. Domain name propagation and DNS settings with your new host
As I mentioned previously, are you checking the right server? Are you sure the domain name has been propagated (if you're using the same domain name that is).
Check the IP address with your DNS provider (for your domain name) is correctly pointed to your new server
Then check that from your command line by typing ping {your-domain-name} and see that your IP address comes up
Check the DNS settings with your web host are setup correctly and that your domain name points to where you want it to point to (ie, public_html or the relevant subdirectory there-of). (This resally does come back to point one, which if you covered it, this shouldn't be an issue
Check that you dropped the files (and all the files) into the correct physical directory, ie public_html (or sub-dir)
If none of these help, please leave a comment with any further developments you've made and as much info as possible, and we can start looking in other areas.
*notes about the database name:
when playing with WordPress directly, ie in the configuration files or the backend administration settings, the database will include your {username}[underscore or hyphen]{database-name}
when playing in phpMyAdmin, they will already be included and you will just provide the {database-name}.
Fellow this steps
export your sql from cpanel---phpmyadmin
make zip of your files in cpanel
import the file in new domain and extract it
create a database link to the new domain
go to new database which you have reacted through phpmyadmin--delete all the tables which was installed by wordpress.
import that sql file which you have downloaded from old website
and in phpmyadmin change the url to new domain name
Regards
Follow these steps:
export database from phpmyadmin.
zip your WordPress project via c-panel.
upload zip file on new domain via c-panel.
extract zip file.
create new database and import old database in new phpmyadmin.
configure user name and password and database name.
change url in database table. from wp_operation table home_url and site_url
Thanks

How do I create a wordpress database on XAMPP server?

I created a WordPress site on phpfog, then used git to download it locally. The way phpfog is set up I can't get to the wordpress database and access it from my localhost installation. I need to set up another database. So far, I haven't been able to get it to work. Phpmyadmin won't open.
(I've also tried a new installation of Wordpress and the same thing happens)
I think the problem is that i need a database. But, where do I put it? What directory?
Here is where I'm at right now:
in the wp-config.php file, I've changed the parameters "user" to 'root' and the password to 'mypassword'
in mylini, I've changed the password param to 'mypassword' and the port to '3306'
in config.inc.php, I've changed "user" to 'root' and 'password' to ''
When I try to connect to phpmyadmin, I get this.
Error
MySQL said:
Cannot connect: invalid settings.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
I've tried a number of ideas on various forums, but nothing gets me past this yet. Any ideas would be awesome.
Greg
First - It's hard to know how to answer as your question is rather vague. There's two very different things involved. First, setting up xampp. Then setting up wordpress. I couldn't quite figure out which you were referring to for each error, so here's a long winded explination/answer in case any thing helps:
Are you on Linux I presume? On windows it was a bit of a hassle and wamp was 20x easier. But, you might consider a preconfigured stack that includes xampp (and necessary includes) and a few other goodies, some come with wordpress installed. I haven't personally used them, but wish I had - google ought to help out there.
I'm assuming you went to (http://)localhost/phpmyadmin, right?
First you need to get there before you hook up wordpress. As for hooking up xampp, it does take some configuration, so make sure you follow the docs - it's not quite a one click install.
Once you have xampp setup, you need to create a new database in localhost/phpmyadmin for wordpress. Then go back to your file folders, which should be located in xampp/htdocs/yourwordpressinstall.
config.inc.php - is that your wordpress directory?
It needs to be wp-config.php (if it's not already there, save wp-config-sample.php as such). Open that, change server to localhost, database to the name of the database you just created. The username and password are the ones when you installed xampp. By default, I think they're User: Root, and PW: unset(blank). If you go to phpmyadmin there's a link to security and it'll show you there. localhost/phpmyadmin
Now, you should be able to type in the location of the filefolders.
localhost/wordpress/
- assuming your server is started, and the wordpress root folder is name "wordpress" and is in the xampp/htdocs/ folder.
From there you should see wordpress.
However, if you've exported your database, you'll need to change the site_url and home_url options to the new url. I'd suggest using the plugin wp db migrate (something like that) which will allow you to export the database from wordpress and auto set the values. Once the plugin is installed it's under the tools menu.
If you google migrating wordpress, you'll find plenty of tutorials and guides for moving wordpress from local to live, or as you're doing, online to local.
Sorry, I have to run, so I'm not sure if I really got to exactly what you needed, but that should get you started and give you the keywords to let google and other tutorials/docs get you the rest of the way.
I would recommend developing locally. That is, you develop stuff on your own machine with a dummy database. When you are happy with your changes, you upload them to your server, which works with your real (production) database.
To hook your local copy up with a database:
Install MySQL on your local machine
Open an interface to MySQL. On a UNIX-like system, you could type mysql on the command line
CREATE DATABASE ''databasename'';
GRANT ALL PRIVILEGES ON ''databasename''.* TO "''username''"#"''hostname''" IDENTIFIED BY "''password''"; (if hostname is %, you can log in from all hosts)
FLUSH PRIVILEGES;
Update your local wp-config.php with your local credentials and database name

Resources