How to download a copy of your website to your Mac and run it locally using MAMP

From TNG_Wiki
Jump to navigation Jump to search

If you want to try out a few changes to your TNG site without affecting the 'live' site on the Internet...or you just want a copy of your site locally on your Mac...then this is how to do it.

Note:

  • This tutorial assumes that you have followed the guide on how to install MAMP on your Mac and are comfortable with finding the MAMP application and htdocs folder. This tutorial does not use or discuss the MAMP PRO application.
  • Because this tutorial use images from a live website hosting, parts of the images have been blurred to protect information
  • This tutorial cannot cover how every web hosting company functions, nor discuss all the tools that your hosting company gives you access to
  • This tutorial assumes that there are not substantial differences between the PHP version running on your live website and the version of PHP that you will use with MAMP
  • Finally, it's interesting to note that you could use a very similar approach to migrate your TNG local website from one Mac to a new Mac

1. Login to your web hosting control panel and go to the File Manager. Find the folder that contains your live TNG website and create a zipped version of the folder...

Archive a folder on your webserver
Give the archive a name

2. Download a copy of the zipped version of your live TNG website to your Mac...

Download the archived file

Note - Depending on how your Mac and web browser are set up, the location that this file downloads to on your Mac may differ. Unless you have specifically made a change to your browser settings, it will likely download to your Downloads folder. Your browser may also be set to automatically unzip the downloaded file.

A zipped version of your website

3. Don't forget to delete the zipped version of your TNG website that is still sitting on your web server, using your web hosting File Manager...

Delete the zipped archive on the websever - 1
Delete the zipped archive on the websever - 2

4. Staying with your live site, go to phpMyAdmin that is part of your web hosting control panel and click on the database that you know is your TNG MySQL database...

Click on the database in phpMyAdmin

5. Click Export...

Click Export

6. Leave the Export method set to Quick and click Go to export (download) a copy of this SQL database to your Mac. You can now close your web browser. The rest of the work you will do will be locally on your Mac.

Choose Quick export and click Go

7. On your Mac you will either have a zipped file that was automatically unzipped, or you will have a zipped copy of all the files from your live TNG website. Double-click this zipped file to unzip it. You should also have a copy of the SQL export from phpMyAdmin that you downloaded a moment ago. These may have all downloaded to your Downloads folder on your Mac. Take careful note of the name of the exported SQL file.

Zipped file, unzipped folder and the SQL file


8. Go into your Applications folder and open the MAMP folder...

MAMP folder in the Applications folder


9. There are two items of interest in the folder. The first is the MAMP application and the second is the folder htdocs. Think of htdocs as the web server folder...all the websites you create will need to sit inside this folder. Open the htdocs folder...

htdocs folder and MAMP app

10. Move the unzipped folder containing all of your live site's TNG installation into the htdocs folder. Take a note of the name of the folder.

Place your unzipped folder into htdocs

11. Go back to the MAMP folder and double-click the MAMP application to start it running. We're now going to do a little trick to help you access your TNG website quickly in the future. With MAMP running, go up to the MAMP menu and select Preferences...

Choose preferences from the MAMP application

12. In the section My favorite link enter the name that you gave the TNG folder that is sitting in the htdocs folder and click OK...

Add the name of the folder into the My favorite link and click Go

13. Set the PHP version to version 8 and start the web server running by click Start...

Click Go after setting php to version 8

14. If the WebStart page hasn't launched your web browser, click the WebStart button to launch the WebStart page...

Click the WebStart button


15. You now need to create a MySQL database that matches with the name of the database that you have on your live site and that you have exported a copy of to your Mac. Go to the Tools menu and click on phpMyAdmin...

On the WebStart page


16. A new tab or page should load in your browser, showing you phpMyAdmin. Click New...

In phpMyAdmin click New


17. Give the database that you are creating the EXACT same name as the one you downloaded. In this example the database has been called account_genealogy. You don't need to include the ".sql" part. Don't change any other settings and click Create.

Use the same name for the local database and click Create

18. The empty database that you just created should appear in the left-hand column of databases. Click Import...

After the database appears, click Import


19. The import page loads. You now need to click on the Choose File button...

Click on Choose File

20. Find the SQL file that you exported from your live site. Select it and click Upload...

Select the local SQL file that you had downloaded


21. You can now see that the SQL file has been selected, ready for importing. Click Go...

Once the file is selected, click Go


22. You should now see a confirmation that all the data from the SQL file has been successfully imported into your database. In the left-hand column, you should also be seeing the TNG tables that have been created as part of the import process.

It's OK to now close the phpMyAdmin web page.

The database should now have been imported

The final part of the process is to change some of the settings associated with your TNG install. The first file you need to edit is the config.php file. Depending on how you set up your live site, this file will be either at the top level of the TNG folder or in a hidden folder that contains your configuration files (if you moved the config files to somewhere else).

Find the config.php file in your TNG folder

23. Once you locate the config.php file, right-click (or control-click) on it and Open With the TextEdit application that comes with all Macs (you might have other software such as Dreamweaver or BBEdit that you prefer to use when editing php files)...

Right-click and choose to edit the file


24. Adjust the settings at the start of the config.php file. You will possibly need to change the $database_host value to "localhost", as well as changing the $database_username to "root" and $database_password to 'root' (the default MySQL username and password that comes with MAMP)...

Edit the database details


25. Further down the settings in the config.php file, you will likely need to adjust the $rootpath to the path of the local copy of your TNG website (which will be the same as you see below if you have been following along with the tutorial) and change the $tngdomain value to (most likely) what you see here, using "localhost" as part of the webs address. Save the changes in the config.php file.

Edit the path and domain details


26. The other file you need to adjust is in the top lop level of the TNG folder and is called subroot.php. Right-click (or control-click) on the file and choose to edit it with TextEdit...

Find the subroot.php file


27. Change the settings for the subroot path to point to the location of the folder containing the config.php file on your Mac. In the example here, the path reflects the fact that the location of the configuration files is in the Applications folder, MAMP folder, htdocs folder, my-tng-website folder and that the location for the config.php file is a folder that was set up on the live site (to hide the config file location) and is called my-secret-config. Save the subroot.php file after making these changes.

Edit the file to include the location of the config file


28. Go back to the WebStart page (if MAMP isn't running, make sure that you start the application up and start the servers first). Remember when you set up a favourite link as a preference in MAMP? You should now be able to make use of that by clicking My Favorite Link to load the local copy of your website...

Click My Favorite Link on the WebStart page

Eeek! There's a possibility that this might happen on your Mac. Something is wrong and your Mac thinks it needs to download the local website. It's a bit confusing, but easy to fix. First, click Cancel and close your web browser.

The browser given a download error

The problem is likely due to a hidden file (called an htaccess file) that has been downloaded as part of the folder you zipped on your website and downloaded.

29. Go into your local website folder (inside htdocs) and choose to view the files as a list...

The list of TNG files


30. On your Mac keyboard, press the key combination Command-Shift-. (or Command-Shift-period). This is a keyboard short cut to turn something called "show invisibles" on.

Now you should see the culprit in question...a hidden invisible file that you downloaded. You need to delete the .htaccess file that has appeared. Don't worry, it won't cause any issues. Once you have done that, press Command-Shift-period to turn showing invisible files back to "off".

An invisible htaccess file


31. Now you can go back to the WebStart page and click My Favourite Link...

Go back to My Favourite Link on the WebStart page


And there you have it...a copy of your website now running locally on your Mac!

The TNG website loading locally


32. Finally, you might want to login as an Admin to your local version of your site and check the general settings, just confirm that the settings that you put in the config and subroot files are all correct.

Check root and Config path settings

Back to MAMP | Next - How to update TNG running on your Mac