How do I clone a wordpress site? [closed] - wordpress

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I need to clone a wordpress site into my local so that I can try changing it without jeopardizing the running website.
I am fairly new to wordpress. How do I do it?
Is copying the whole folder which include wp-admin, wp-content, wp-includes going to work?

I will try to explain how to do it fairly easily:
For copying / cloning website you will need to copy all the files and copy the database. You certainly can use a plugin for that but it is better to understand how it works under the hoods and do it manually and then migrations will become just a matter of minutes :)
Ok, so let's begin. First create a folder on your local server (or other server) which is going to be the root of your installation. Let's say your site you are copying is "oldsite.com" and the new destination is "localcopy.dev"
Copy all the files from oldsite.com via an oft or hosting panel file manager or via command line. Please note that if you will use ftp than copying process will be extremely slow, it will need to do a separate request for each file and considering that the worpress installation can contain up to 10 000 files it might take more than an hour. I would recommend to create an archive of all files from your hosting file manager and then just download the archive and extract it in your localcopy.dev root folder. That will take 2-5 minutes maximum.
Once you have your files migrated, you need to migrate database. That looks little tricky on the first sight but in a fact it is pretty basic thing. On your hosting, you need to access phpmyadmin. Open the database of the oldsite.com and go to export and export all the tables of the database. If it does not automatically export into a file, then you will need to indicate in export settings to generate export file. It will be a simple text file with .sql extension.
Now we need to modify this .sql file. Open it in any text editor and just find all "oldsite.com" and replace with "localcopy.dev". Once you are done save the file. This is required, because we are migrating to new domain name and need to point all old links to new domain.
Now on your local server (or other destinations server) create a database, open the database via phpmyadmin or other db management application and import the tables from the .sql file we already have.
Now go to the root folder of the localcopy.dev where you already extracted all the files and fine wp-config.php file. Open it and modify database name, database user, database pass with new values so that it can connect to new databse which is on your local server.
Open localcopy.dev in your browser. It should work fine but if it does not, for example, if you see white screen of death, it might be a problem with your .htaccess file. Try deleting it and refreshing the site. Then it should most likely work fine but you might need to log in and go to settings->permalinks and click save to generate new htaccess.

You need to copy the files as well as the database, and update the database to point to your local URL and directory structure.
Copying the files is easy (grab everything in the site root, not just the wp-* folders)...you will likely use FTP/SFTP/SCP to copy them down.
The database is a bit more tricky. There are MySQL dump tools and database copy tools.
Also take a look at WP Migrate DB Pro. It is a paid product, but if you have to do this a bit more than once...paying the cost is well worth the time and aggravation it will solve you.

It is safer to copy the whole wordpress folder and don't forget the .htaccess file as well.
Other than files, you need to make a copy of the database as well.
There are some wordpress plugins available that would ease the pain, for example Duplicator
Also if you are cloning the wordpress site to a new domain, there are some more steps to take (details are here)

Related

Wordpress wants to install itself, rather than run the blog

We have created a duplicate of our website on a new server as part of a migration. We have a wordpress blog that is part of our website.
The docroot of the wordpress site is set as an alias in our main site. The result is that to access the site home page, the following url is used: https://www.rephunter.net/blog/.
The new environment is not available to the public at this time, and is only accessible within our VPN. When the above link to the blog is followed, instead of the expected home page of our blog, we get the page at https://www.rephunter.net/blog/wp-admin/install.php, which wants to install a new site.
The configuration in the new environment is supposedly an exact copy of our production site from some time back. The permissions on the main files is the same.
What is it that is causing the attempted blog access to be redirected to the installation script?
EDIT:
The responses so far have not really absorbed the intent of the previous information. We are not migrating in the normal sense. Rather we are testing in a new virtual environment that will eventually lead to a more normal migration.
We have an exact duplicate of our original wordpress and database environment that is running in a virtual environment with an updated protocol stack that is only accessible if you are on the VPN for that environment. As far as we can tell, there is no difference in the configuration.
For example, the parameters in wp-config.php are exactly the same as in the original installation. When php runs, it sees the same environment, with host names and everything identical. It would not work otherwise.
Yet if there really were no difference, it would just run. But since WP is trying to install a new database, there is something different that we are missing.
To further illustrate this: supposed you took an image backup of the wordpress installation and the database, and put it in a different VM, and set up the DNS and everything as it needs to be--the new environment looks no different than the old one. All databases, wp-config settings, etc, are the same. So our main website and database functions very similarly.
As I mentioned above, the difference in the protocol stack should be considered. The old system is on PHP 5.6.27--the new one is on 7.3.4. So that could be causing some difference, which maybe somebody might recognize. Wordpress is 5.2.2 and should be compatible with both PHP levels.
We believe there is some relatively simple parameter setting that we are missing. For example, as in the first answer that $table_prefix is set wrongly. But that is not it in this case.
WordPress redirects you to that installation screen because the database it's connecting to is working (meaning, the username and password are correct), but the data it's expecting to be there isn't. Therefore, it assumes it's a new / empty database and prompts you to install WordPress.
I've seen this happen in two scenarios:
The database really is empty, and thus WP needs to install the standard tables and info
The table prefix in your wp-config.php file is incorrect for an existing database
Look at your wp-config.php file in the root directory of WordPress, and look for a line similar to this:
$table_prefix = 'wp_';
Then, open up the database (phpMyAdmin or some other interface to browse what the database structure actually is) and confirm that the table prefixes (the first few characters of the table names) actually match what's set above.
Hopefully this gives you something to go on! Let us know what you find
Migrating Wordpress websites can be quite tricky. I've worked as a WP developer for a number of years and always struggled with manually migrating websites.
There are a number of factors to consider:
WP stores a lot of installation specific information within the database. So you can't do a database dump and upload the export into a new database.
Changing the website url within the wp_options table in the databased there are still other references to the original url scattered throughout the db.
You could try a find and replace all using an editor that supports this sort of functionality (vscode, sublime, atom) but things always end up breaking and your doing tons of "find & replace" actions.
I have always relied on a 3rd party tool Backup Buddy as it simplifies the entire backup and migration process and offers the peace of mind of having easily deployable backups for your website.
Backup Buddy allows you to export your website as a zip and then you can move the zip to any server you want and the plugin provides an installer script (php) to guide you through the migration of your wp site to any host and database of your choosing.
Note: I am not in any way affiliated with iThemes or Backup buddy, and I do not stand to benefit in anyway if you decide to use the plugin. This is only advice on a tool that I have found helpful, reliable, have had success with, and currently actively use on a number of websites that I maintain.
WordPress display installation page because you have not update your wp-config.php file after migrating server so please follow below steps in future when you migrate your website.
Please follow this steps when you migrate your WordPress website from one server to another server.
Back up your website files/database
Export wordpress database.
Create database on your new host server.
Edit the wp-config.php File and edit this details.
Add new database name
Add new database username
Add new database user Password
Add new host as per your hosting provider or (localhost is default)
Import your database to new server.
upload the WordPress files to your new host
defining new domain URL & Search/Replace old domain URL

Wordpress - Website was hacked and it is redirecting to some malicious website [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
I have a WordPress website running, but recently my website has been hacked. It is not even possible to enter my website: if I browse to my website it is redirected to some other website.
I have try to clean up the code and checked for any script inject but I couldn't locate the malicius script. How can I overcome this?
I have tried to remove the unwanted Plugin
I have tried to update all the plugins.
I have tried to clean up all the files like functions.php,
header.php, footer.php but there is no use of it and I couldn't
locate the injected scripts.
You can scan the web-site on the local machine using software ai-bolit https://revisium.com/aibo/
create backup web-site
Download on local machine
unpack archive in folder ai-bolit
Notice: Do not unpack the archive into a directory with space character. For example,
C:\Documents and Settings\Michael\Downloads\aibolit-for-windows-en\ - will not work
C:\aibolit\ai-bolit-for-windows-en\ or d:\mysites\aibolit-for-windows\ - will work
For security website scan on your own
Unpack the backup archive of your website or place files which you want to check into the "site" folder
Run start.bat (for common check) or start_paranoid.bat (for "paranoid" check) to scan website files for viruses and hacker's scripts
Scanner will create AI-BOLIT-REPORT.html file upon completion
For malware analysis or website infection analysis by security experts ("paranoid" mode + quarantine file)
 
1. Unpack the backup archive of your site or place files which you want to check into the "site" folder
2. Run scan_and_quarantine.bat
3. AI-QUARANTINE-XXXXX.zip file and report AI-BOLIT-REPORT will be created upon completion (XXXXX is replaced by date and time numbers)
4. Send the file AI-QUARANTINE-XXXXX.zip to ai#revisium.com with the subject "Check the Report" for free malware analysis.
The archive will contain everything experts need for analysis.
First of all, install a wordpress security plugin ex. Wordfence. It will help you locate the malicious file in your public_html foolder and also lets you know if any of your file was modified.
Secondly, check your domain settings in your host. You can check to verify whether your domain is being redirected to other site.
Check and do the below list.
check the file edition date inside file manager or FTP.
check .htaccess
check wp-config.php
check the content text inside posts and pages.
check inside uploads folder.
Add Wordfence plugin
Add Anti-malware security plugin
I faced a similar issue.
When accessing the website directly from the browser, it's working well and no redirect happens but when opening the website from Google search results, it redirects to another malicious website only the first time the URL opened. In the second time, no redirect happened.
After some digging, there was a plugin installed and hidden (not being displayed in plugins list) called zend-fonts-wp.
Using Freesoul Deactivate Plugins I disabled this plugin from being loaded and delete it permanently from plugins folder. I also deleted two database tables injected by this plugin called wp_wusers_inputs and wp_wzen_time_table.
Attackers use several ways to redirect the user
Redirect users through malicious codes which they inject into the
website
Attackers might also execute .php codes
Attackers can add themselves to your website as ghost admins
By inserting codes in .htaccess/wp-config.php files
By inserting JavaScript in WP plugin files
Check these files for the following malicious codes:
Index.php
Index.html
-.htaccess file
Theme files
Footer.php
Header.php
Functions.php
Helpful resources - https://www.getastra.com/blog/911/wordpress-hacked-redirect-wordpress-website-redirecting-to-malicious-pages/
https://www.getastra.com/blog/911/wordpress-files-hacked-wp-config-php-hack/
I had faced the same problem got the solution worked fine with 3 simple steps.
step 1. backup/zip all your files and folder of wordpress site
step 2. donwload and extract fresh wordpress (do not install)
step 3. replace wp-config.php and wp-content folder from the backup or was created in step 1.

How to move Wordpress to another domain without the chance to make a proper backup first?

So my webhoster closed down, where I hosted my Wordpress blog. I was able to receive a zip file containing all my data. I now have a new webhoster and I extracted the zip file to its root directory.
Trying to open my website now gives me "Error establishing database connection". The web tells me it may be related to hardcoded urls in the Wordpress database, which I need to replace by the new url.
However the tutorials usually tell you to use the Wordpress interface to create a backup of my database first, which can then be edited in tools like phpmyadmin. I can not access the Wordpress interface anymore and so far did not manage to edit the database otherwise.
I tried placing a local copy of the blog in the "C:\xampp\htdocs" folder, hoping phpmyadmin would recognize the database and allow me to edit it. Not working, maybe I am doing something wrong?
Any ideas to revive my Wordpress blog?
Cheers
Okay I think I got it working. For people having the same issue:
I loaded the database locally by copying the *.myd, *.myi, *.frm files to a new folder in my local xampp installation (e.g. C:\xampp\mysql\data\myDatabase).
I then used phpmyadmin to export this database to a .sql file.
On my webserver I then installed a fresh wordpress blog. It might be enough to copy your existing wordpress stuff, without needing to do this step afterwards, not sure.
My webhost has phpmyadmin preinstalled, so I used that to delete the fresh wordpress databases and import the .sql file instead. Now everything is in place, but since I changed my domain I need to change the URL paths in the database.
I used this script (use it by placing it on your webserver in the wordpress root folder and calling it in the browser) to do a search&replace of my old url to the new url: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
After that I only had to manually fix the path to my header image that I had edited in the past in the theme's header.php file.
Phew. Thanks for your help f00644.

How to transfer a Wordpress site from Bitnami (local host) to a live host online? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm finding out that developing my Wordpress child theme and website on my Bitnami local server was a HUGE mistake.
There's apparently no easy way to move it to a live 3rd-party host online.
I've exported the bitnami_wordpress database (careful to select all the tables), then imported it into a new database on my hosting account.
I've installed wordpress, and then replaced the wp-content folder with my own.
I've adjusted the wp-config file.
Still, I lose all my pages. I lose all my media library. My widgets are no longer populated. And weirdly enough only SOME of my CSS seems to work.
And judging from the disparate and spotty "solutions" that I've found on the web, the only real solution seems to be (you guessed it): use Bitnami cloud hosting. However, I'm already a Bluehost customer.
I've even tried 3 plugins so far, and none worked. After all the work I've put into developing the child theme and populating it, this is a real nightmare.
Can anyone tell me what I'm doing wrong? (In simple terms - I don't know php...) I'm completely lost at this point.
I had a similar problem. To get my particular site working, I added the following code to my configuration file:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
After adding the lines, my CSS and uploaded images came back.
Don't forget to replace example.com with your site's domain name.
I found that code at: http://codex.wordpress.org/Changing_The_Site_URL.
Actual user results may vary.
Move all files with wp-admin, wp-content, wp-includes into your host.
Delete wp-config.php file.
Go to site URL EX: example.com and go through typical installation procedure.
Go to your database in your host and delete those 11 tables which have made.
Now you should export the local database and you should open it in any text editor and search and replace your local URL with new one.
Ex: localhost with example.com, then import it to your database of real server.
Now It should work.

Mirroring a Wordpress *configuration* between local and remote

Ok, so I'm familiar with creating local Wordpress builds, and have been chugging along happily with the technique outlined in Smashing's MAMP-based article. My question goes a step beyond this.
The article is great for developing generic themes, but when developing sites (not necessarily blogs) based in Wordpress, for me at least, it's a little painful come launch day.
I have to go back in and reconfigure the server's Wordpress to match what I've already done locally. Settings have to be entered again, plugins need be installed again, menus recreated, and css will have to be altered to reference the unique classes/id's Wordpress generates for posts/pages/custom taxonomies…sometimes things are missed in the process. What I want to know is this:
Is there an easy way to automate cloning or mirroring the build on my local machine to the remote server?
Even if you have to just LMGTFY me, that would help. I don't exactly know what I should be searching for. Searches dealing with 'mirroring wordpress configuration' and 'cloning wordpress configuration' returns tutorials on moving content, which I know how to do.
If it helps, I'm running OSX 10.6.8 with xcode dev tools, git, ruby, node, and homebrew. All of my live servers have ssh access as well as ftp, and I build with the most current versions of Wordpress.
Here are some easy steps to follow:
Download and install the WP Migrate DB plugin.
Go to Tools > WP Migrate DB and fill-in the blank fields(New address (URL), New file path and optionally check/uncheck the other options). Click on Export Database and save the export file to your computer.
Make a .zip archive with ALL of your files(the /wp-admin, /wp-content, /wp-includes directories and all files in the root directory).
Upload that file to your production server, where you want your WordPress site to reside.
Go to your cPanel(or use the unzip command through SSH) File Manager(or any other alternative that you might have) and unzip the file that you just uploaded.
If you don't already have a Database set-up on your production server - create one through the hosting control panel(for cPanel, it would be Creating a mySQL database in cPanel, for plesk it would be Plesk 7 Tutorial: Creating a database, for anything else, just google it up, or try your hosting's FAQ). Remember/write-down your Database Name, Database User and Password.
Edit the wp-config.php file and change the values for the DB_NAME, DB_USER, DB_PASSWORD and optionally DB_HOST - but this is usually localhost - if that doesn't work try asking your web host, or if you have phpMyAdmin, log-in to it and look at the very top of the page - in this case the DB_HOST would be localhost.
After you've done all of that, log-in to your DB administration tool(most of the time this would be phpMyAdmin, but it could be something else as well) and upload the database export file that you save to your computer in step 2. Note: If your hosting hasn't provided you with a DB administration tool, I would suggest that you upload the phpMiniAdmin(click on the "Download latest version" link and save the file to your computer) script to your production server. Then go to that script(if your website is located at http://example.com/, go to http://example.com/phpminiadmin.php) and enter your DB details. On top of that page, you will see an import link. Click on it and upload your DB export file. Note 2: phpMiniAdmin doesn't support gzip-compressed files, so if you did check the Compress file with gzip option in step 2, you will have to re-do that step with this option unchecked.
Log-in to your site and go to Settings > Permalinks in order to update your permalink structure.
Check the permissions of the /wp-content/uploads and /wp-content/plugins directories - make sure that you will be able to upload images and plugins without any problems.
That's pretty much it. It might seem like a lot, but I follow this process for almost every site that I upload to production servers and it can take me as less as a bit under 10 minutes to do all of that(considering that I usually use custom MySQL commands, instead of the WP Migrate DB plugin - I should probably start using it :) ). Once you get used to the process and you don't encounter any low-quality web hostings, you should be perfectly fine with these steps.
Note: Since you used ssh as one of your tags, I assume that you usually have ssh access to the production server. If you don't I'm still assuming that you have a cPanel access(if that's not true and you can't unzip files on the server, then upload all files manually via FTP client, instead of doing steps 3 and 4).
I guess the only way is to copy the database or part of it.
What I do is to copy the relevant tables and modify manually the site URLs in table options. There are only 2. There is also a nice plugin velvet-blues-update-urls to modify all links, after the site URLs are set manually to be able to access the backend, in case posts are also copied.
Next, copy all theme directory files to the same directory in the site, assuming you are using the same theme.
Both processes can be automated with a PHP script.
I am not sure this is what you want, but hope this helps.
Not sure that this is exactly what you need, but to move a site you can use the built in Wordpress "export" and "import" options. As far as I remember there was an option when importing to change URL's and the import would change a few things for you.
Even if this does not answer your exact question, hope it helps.

Resources