How to Copy a PHP Website

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Copy the entire PHP site to create a mirror of the site or to transfer it to another location.

You've spent a great deal of time and money to set up and configure your PHP website just right. Now, for some reason, you need to copy it to another web server or to a different folder on your current web server. You have several different options for how to do this. Use a PHP script to copy the file to another location. You just need to create the script, load it to your web server and run it. All of the files on your site will be copied to the new destination.

Advertisement

Step 1

Open a text editing (Notepad) or web authoring application on your computer. Click on "File" and then "New" to create a new file. There also may be a "New" icon on the toolbar.

Video of the Day

Step 2

Type in the following PHP code to copy files from one location to another:

Advertisement

"bool copy (string $source, string $dest [, resource $context])"

Leave out the quotation marks when typing the code. Change "source" to the file location of the PHP file that you want to move. Change "dest" to the destination location to where you are moving the PHP file to.

Advertisement

Step 3

Type in the whole script to copy all of the files on your web server to another location. To save some time when you have a lot of files, use the following script to copy the entire public_html directory to another location:

Advertisement

""

Advertisement

Omit the quotation marks at the beginning and end of the code. Save the file as a PHP file and upload it into your public_html folder on your web server. Run the script by typing in the file location in the address bar of a web server. Input the destination you want the files copied to and then allow the script to do its job.

Video of the Day

Advertisement

Advertisement

references

Report an Issue

screenshot of the current page

Screenshot loading...