Tag: WordPress Tutorials

  • How To Copy A WordPress Website Onto MAMP

    How To Copy A WordPress Website Onto MAMP


    This is a follow-on post from Configuring MAMP (with WordPress) and is a guide on how to copy a website onto MAMP. Or I can phrase this by saying, copying your own live WordPress website and have it run locally on your laptop or PC. MAMP is a small app that allows your computer to easily run a local web server environment for WordPress.

    The above can be used as a test environment for upcoming changes to your website if you don’t already have a Child Theme. This might also be used to have an isolated play-around area to see how your website looks in various forms.

    I’ve attempted to illustrate the high-level move below. We’re downloading the MySQL database and WordPress files and throwing them into MAMP.

    Move a website into localhost.


    Assuming MAMP is already installed, we need to run through the following list to achieve a local copy of your WordPress website:
    1. Get a copy of your WordPress database.
    2. Download a capture of your WordPress files.
    3. Import a WordPress database using myPHPAdmin.
    4. Configure index.php to allow connectivity to your database.
    5. Update the WordPress database for WP-Admin access.


    Download Your WordPress Database

    1. Open your hosting provider cPanel.

    CPanel WordPress Website.

    2. Open phpMyAdmin and select Export at the top menu bar.

    phpMyAdmin Menu.

    3. A quick export in the SQL format is fine.

    phpMyAdmin Export.

    4. When you hit go you’ll begin the download of your MySQL database.


    Download Your WordPress Files

    There are many ways your website files can be downloaded, a few of which will be shown on your control panel.

    CPanel Export.

    Today, let’s choose Backup.

    CPanel WordPress Backup.

    Go ahead for the download.

    CPanel Generate Backup.

    You’ll receive an email to where the backup has been saved to – grab it using File Manager or FTP. Also, the MySQL log file will be included as an attachment. Perhaps an idea for another blog to restore this one day.


    Importing The Database

    Before we start, the default maximum import size in phpMyAdmin is 2MB. My whytepete.com hosted version of phpMyAdmin came with a value of 50MB though.

    phpMyAdmin Import.

    My WordPress database size is only 5MB – this’ll of course vary depending on content volumes. I had to amend the php.ini file to allow the import.

    1. Find the php.ini file(s).
    This is where a tool like Agent Ransack is useful for me.

    Agent Ransack.

    2. Check MAMP to confirm running version.
    It’s likely the most recent version MAMP will be running as default anyway.

    MAMP PHP Config.

    3. Before continuing, lets confirm the differences within each of those php.ini files.
    WinMerge does the trick, there’s only one difference as shown below between version 7.17 and 7.0.0. There are a few additions and changes to default values per major version by the looks of it.

    WinMerge.

    4. Stop MAMP’s Apache & MySQL services and edit the relevant php.ini file.
    It’s 100% worthwhile reading through the comment section at the top.

    PHP INI File.

    5. Edit the following where required.

    memory_limit
    Maximum amount of memory a script may consume (Default – 128M)
    post_max_size
    Maximum size of POST data that PHP will accept (Default – 8M).
    upload_max_filesize
    Maximum allowed size for uploaded files (Default – 2M).

    The above should be set from biggest to smallest as reflected by their default values. If we amend the upload_max_filesize value to 25M, it’ll still be bound by the post_max_size value. This is what I done as my database fits within the 8M limit.

    6. Open phpMyAdmin & create a new database.

    phpMyAdmin Create MySQL Database.

    7. Select your new database on the left-hand toolbar.
    The ‘selection’ of a database is a bit quirky, we just need to make sure it’s highlighted before importing.

    phpMyAdmin MySQL.

    8. Click on the Import tab and browse for your downloaded WordPress database.

    phpMyAdmin Max Import size.

    9. Hit Go!

    phpMyAdmin SQL.

    10. Success!

    phpMyAdmin Databases.

    Configuring PHP & WordPress

    Now that we have our database imported to MySQL Server, we need to configure PHP & WordPress.

    1. First, lets look at the WordPress files you need from your download.
    If you have a full backup of your website directories, you’ll need to look in homedir > public_html.

    Homedir Public HTML Files.

    2. All those files should be copied into MAMP > htdocs.
    Replacing existing files such as index.php.

    MAMP htdocs Files.

    3. Now, navigate to the website to see what’s happening.
    A popular error message this is.

    Error establishing a database connection.

    4. Amend the wp_config.php file as shown.
    Taking note of the file path within the Notepad++ header.

    The changes of note are:

    define(‘DB_NAME’, ‘whytepete’);
    The WordPress database name.
    define(‘DB_USER’, ‘local_user1’);
    MySQL username with permissions over the WordPress database.
    define(‘DB_PASSWORD’, ‘unsafe123’);
    The associated password for the above user.
    define(‘DB_HOST’, ‘localhost’);
    The address of your server hosting MySQL.
    $table_prefix  = ‘wp_’;
    You can find your table prefix by looking at all your tables within the WordPress database.

    5. Refresh your browser and… HURRAY!

    localhost website

    Navigation & WP-Admin Access

    After getting your local website up and running, you’ll quickly realise links navigate to your website rather than the appropriate localhost/subdir. Typing URLs manually works fine though.

    localhost website on desktop

    Also, if we navigate to localhost/wp-admin you’ll be redirected to your actual webpage WP-Admin login page. If you’re not redirected straight away it’ll at least happen when you try login.

    WordPress Login URL

    The fix is to update the Options table within the WordPress database as shown.

    local phpMyAdmin MySQL

    And the last step is to fix the login!

    phpMyAdmin Fixing WordPress Login.

  • How to Install WordPress with MAMP on Windows

    How to Install WordPress with MAMP on Windows


    MAMP is a “one-click solution for setting up your personal webserver”. If you don’t have hosting or a domain name sorted out, you can go ahead and build your WordPress website using this free bit of kit. I promote because it’s really simple to use!

    This post will come in 5 parts.
    1. A quick install of MAMP.
    2. Creating a MySQL Database.
    3. Installing WordPress.
    4. Choosing a WordPress theme.
    5. WordPress editing & adding content.


    Installing MAMP

    1. Download MAMP and run the installation exe.
    Warning, a reboot is required at the end.

    2. Choose language.

    3. Untick those pre-selected check boxes.
    MAMP PRO is for the web devs & MAMP Viewer is for alternative platform (iOS) viewing of your website.

    4. Don’t not accept the license agreement.

    5. Chose a directory.

    6. Select the Start Menu folder name.

    7. Next, next & done.

    8. Reboot & launch MAMP.
    Your firewall may alert to allow MySQL & Apache communications.

    9. Click ‘Open start page’.

    Look here for further documentation on configuring MAMP. For now, just having it running as default is good.


    Creating a MySQL Database

    Following on from the MAMP installation, let’s first look at the MySQL side.

    1. Click the phpMyAdmin link as shown at http://localhost/MAMP/

    2. Have a poke around, get to know phpMyAdmin a little bit.

    3. Click on the SQL tab and have a go at some queries.
    The syntax surprise was comments being ‘#’ not ‘—‘.

    4. Drop any test databases and create a new database for your local website.
    I’ve uncommented the code below however keep in mind all commands will have to be run individually. Highlighting a set of SQL won’t work, so use comments. Also, try not to hit f5 😉

    Keep a note of all this information (database name / username / password).


    Installing WordPress

    1. Navigate to localhost in your browser.
    We now need to dump a WordPress install into that Document root directory.

    2. Download WordPress.

    3. Extract the contents of the WordPress zip into the following directory:
    Over-writing existing files will work.

    4. Navigate to ‘localhost’ in your browser. The WordPress Configuration page should show.

    5. We need the database info before continuing.

    6. Enter database info.

    7. Crack on with the install.

    8. The famous five-minute WordPress installation process eh?

    9. Now login and say hello to the WordPress dashboard!


    Finding a WordPress Theme

    WordPress release their own theme every year, so if you followed the above you’ll have the Twenty Seventeen theme or future equivalent installed, including a few previous versions. These are great themes to get you started out and familiar with WordPress, although you’ll likely want another theme sooner or later.

    If you’re wondering where we can get a good WordPress theme, I’ve used the following:
    WordPress have their own selection of free themes, including the popular yearly edition (Twenty Seventeen / Twenty Sixteen / etc).
    ThemeForest, I’ve purchased from them before and all positive really. Support can be in the form of a comments section on the ThemeForest webpage or the sellers own support system if they have one.

    There’s MANY to choose. Googling ‘WordPress Themes’ will absolutely lead you to a theme, but I usually just want to know the good ones! I posted my first question to Quora to find out more!

    Have a proper browse and download the theme files when you have decided. You may make some bad decisions along the way like I did! It’s not always easy getting your vision moulded into a theme. Watch out for things like flexibility with plugins or when the theme last had an update. For further reading, this post helped me – 10 Things to Consider when Picking WordPress Themes and Plugins.

    To install a new theme, it’s as simple as downloading the theme, extract and dump the contents into your MAMP folder.

    Navigate to Appearance > Themes on your WordPress menu and you’ll see the new theme.


    Editing your WordPress Theme

    1. Activate your chosen theme.

    2. The first thing I’d then do is jump to Appearance > Customize and have a play around.

    3. Publish once done & then head into Posts on the WordPress menu.

    4. Add a new post and write about that thing you love so much.

    5. Publish the post and have a look.

    Last note. A lot of themes you’ll find to be responsive, which means when you reduce the size of your browser window your website will respond appropriately. This effectively simulates mobile browsing.

    You could be up and running in no time and the beauty of all this is… it’s all free software for those who want to get started. You don’t need to pay a thing until you’re all trained up! Even when it does come to paying for your domain name and hosting, the minimum cost is around £15 which is not a bad investment.