This is a step-by-step guide to creating a fully functional offline mirror of your phpBB site using MAMP. This is very useful for any phpBB admin because it lets you:
- Make modifications to templating, theme or core files for development purposes
- Carry out database maintenance and experiment with user permissions or new forums
- Test new extensions, styles, smiley packs, official updates etc.
- Easily deploy updates to your live forum without having to re-upload everything
- Create a LAN and connect physical mobile or tablet devices for testing responsive design
...without fear of damaging or rendering inaccessible your actual live website. The method preserves the users, forums, extensions, styles and all configuration from the time you 'snapshot' your live forum - so it's nicer to work on than just an empty default forum with no content.
It's all thanks to MAMP, a free program which basically simulates your own private webserver on your computer. It's creates two virtual servers bundled into one - Apache for the serving the website and MySQL for your database. By downloading your website's live files and database, and then correctly configuring MAMP, you can run this 'snapshot' of your site offline.I love being able to do this because I work half of the year in some of the remotest places in the world with very poor internet access (on an ocean-going vessel that can be away from land for months). MAMP lets me keep working on new features and projects for the forum without any internet access at all providing I have everything downloaded before I go.
Anyway, here's how to do it:
1. Download all your live forum's files using SFTP from your server onto your local computer.
If you have the ability to, I would recommend compressing (.tar, .gz etc) your site's files server-side first if you can. This will reduce the total download size and also speed things up due to just being a singular file - phpBB has thousands of folders, subfolders, files etc. which all need to be processed over SFTP, slowing down transfers by a large margin.
2. Download an .SQL copy of your forum's live database.
To do this with your actual live phpMyAdmin on the internet through cPanel or whatever, just browse to your database, click the 'Export' tab, set 'Export method' to 'Quick' and then click 'Go'. It can be also be compressed if you have a particularly large database. Doesn't really matter and totally up to you.
2. Copy all of your forum's files into the MAMP 'htdocs' folder.
Do not make an extra folder called 'my website' or something like that, just dump all the files into htdocs as if it were the root directory of your server.
3. Edit the following lines in config.php file in the root directory:
4. Boot up MAMP and start Apache and mySQL servers.
Code: Select all
$dbhost = 'localhost'; $dbname = 'nameofyourdatabase'; $dbuser = 'root'; $dbpasswd = 'root';
On the MAMP welcome page open navigation link 'Tools' > 'phpMyAdmin'.
This will load virtual phpMyAdmin on your local computer. It looks a bit older than the most up-to-date phpMyAdmin user interface which you may see on your hosts' control panel but is perfectly good. Helps distinguish between the two :)
5. Now we will import your database file into virtual phpMyAdmin.
Go to the 'Import' tab along the top, leave all the settings as default (but do ensure character set to UTF-8), and then click 'Go'.
This may take a long time. Don't close your browser window or refresh the page - just give it time to import everything.
If you get an error saying that the filesize of your database is too large (by default MAMP is configured for pretty small databases), you can change the maximum uploadable filesize by editing MAMP's configuration files.
6. Edit the config SQL to make the site work on MAMP's localhost
Go into the database in phpMyAdmin and browse to the 'phpbb_config' table. Find the following rows and change the data to the following:
7. Now go back to your phpbb root folder and delete the cache
Code: Select all
cookie_domain from '.yourlivecookiedomainname.' to '.localhost.' cookie_name from 'yourlivecookiename' to whatever you want (make sure it's different from your live cookie name) cookie_secure from '1' to '0' (if your site runs is SSL) server name from 'yourdomain.com' to 'localhost:8888' server port from '0' to '8888' server protocol from 'https://' to 'http://' (if your live site runs is SSL) site_home_url from 'https://yourdomain.com' to 'http://localhost:8888'
In your root installation folder navigate to 'Cache' and then 'Production'. Delete everything in this folder (they are all just cache files). This is an important step - if you don't delete these files the changes you just made in phpMyAdmin won't be recognised by the forum software because it will still have the previous settings cached.
8. Delete your browser cache, localstorage and cookies.
If you don't want to do this just run a browser in development mode like Chrome or Safari and adjust the settings to disable cache etc.
9. Edit .htaccess if you are usually HTTPS
One last bit if your site runs on HTTPS - if you have forced HTTPS rewriting in your .htaccess file then delete those lines from your .htaccess file. Otherwise you won't be able to connect to the HTTP version of localhost that MAMP supports.
Visit localhost:8888 in your browser and your phpBB forum will appear there ready for use. Happy development! :)
Tips for developing and deploying patches with MAMP:
Keep an accurate list of all the html, css, php, js etc. files you modified, and another list for any completely new files you made. This way when you want to deploy the updated patch to your live server, you can just upload the files from these lists to your server and bam, site updated. This is better than re-uploading the whole website again.
Also keep a log of any changes to your ACP configuration so you can do them again on your live site after deployment of the files. Why not just import the database from MAMP to live you ask? Because if you imported that database you would overwrite any new users, posts, topics etc. that had been made during your development cycle. Eek!
If you are connected to the internet whilst running MAMP it will of course fetch any external scripts, files etc. that the site normally needs to function, as if the site were online. However if you are completely disconnected from the net things like these will need to be stored locally on your computer, and stuff like ReCaptcha won't work because it won't be able to connect to Google etc (just disable it temporarily).
Go wild with extensions or styles or whatever it is you're dreaming of doing with the site. If you mess up somewhere it's not a big deal and you can just get the files from your backup and start again. You did make a few back ups didn't you? :) Also bear in mind that MAMP runs in HTTP only so don't expect to be able to test anything to do with SSL, HTTPS or secure cookies etc.
If your live server uses an older version of PHP then you can change MAMP's config files to simulate that version of PHP so that everything is compatible. By default it runs the latest version (7 upwards) and this may break some people's sites if they're using older code.
to 'phpBB • How to create an offline mirror of your forum with MAMP'Posts ViewsLast post
How do I block the mentally defective people on this forum to prevent them from ruining my threads?Certain people on the forum show signs of psychosis and/or just enjoy derailing threads. Since I am not a professional in the mental health field, I...Black Monarch • 4 months agoteebling
4 months ago