Grow your CSS skills. Land your dream job.

#87: Moving Up with MAMP

Working locally with MAMP is awesome, but what about when you need to take that site live? Last time we got a version of WordPress installed locally, now we'll take that local version and move it to a real live site. This entails moving files as well as moving the database, and changing a couple of values in that database.

Links from Video:

Regarding the user setting in MAMP, Luke writes in:

If you're connected to the internet, and someone is able to find your External IP address, suffixed with :8888, they will be able to access your local web server (may or may not be desirable). However If they decide to do some unethical stuff (e.g. exploit your site) they can do some pretty nasty stuff.

If you don't change your user in the MAMP dialog to www/MYSQL then they could potentially access your data outside of the local web dev section, delete your data, etc. Basically they will have the same permissions as the user that's running the MAMP server. So if you're running it as root, or your local user, they can potentially delete your data, view your data, edit your data, etc. However the www/MYSQL user by default only has access to read (no write) the data within your local web dev area and nowhere else.

To get around permission errors, on a Mac, you would just have to change the permissions. Go to the file/folder you're trying to access, right click and View Info. at the bottom there is a box for permissions, and just change for the user _www (add it if it's not in the list, it might be www) and give it read and write permissions for whatever it needs.

Comments

  1. A few things I didn’t discuss in the video:

    Make sure new “live” web server has the same technologies available as you do locally. WordPress runs on even PHP4 and simply needs MySQL. But if you were creating a Rails site, it’s likely more setup would need to be done.

    When working locally, at least on a Mac, files that begin with a period are hidden. Like the ever-important .htaccess file. Make sure that gets moved properly when going live.

    If you were moving from a live site on one domain to a live site on another domain, there may be more work to do: redirecting the old site, moving DNS (or A & MX records), and potentially closing down the old host after a certain amount of time. This might be a whole tutorial in itself…

    • Gringer
      Permalink to comment#

      Around 01:22 I see a curser blinking at the end of the article paragraph.

      Is this a glitch or some nice plugin you didn’t tell us about yet ? (in-page editing of articles ?)


      Gringer

    • Gringer
      Permalink to comment#

      Oh, and I hate that I now have to re-buffer to where I was :-P

      *hint*Ajax submitting*cough*

  2. Kevin Burton
    Permalink to comment#

    Just a note: you can have as many websites locally if you know how to adjust apache server and /etc/hosts file.

    MAMP PRO is only an interface to do these for you.

    Cheers.

  3. Thanks for the update Chris. Just a quick suggestion.

    If you are moving WordPress after setting up the site in full locally you will have many records in your database with the old domain in it. I would export the old database and open it in a text editor and use the find and replace functionality to replace all references to the old domain and replace then with the new domain.

    Second little suggestion you only need the wp-content folder for each specific site that you are uploading so I would suggest connecting with ssh and using wget to get the latest version of WordPress from their servers and then uploading the wp-content directory via FTP – will save you that 10 minutes it took to upload the whole thing :)

    wget http://wordpress.org/latest.tar.gz
    tar xzf latest.tar.gz

    Cheers,

    @Prydie

    • To add a little caveat to my first suggestion. If you have a large db (and I mean very large) opening the file in a text editor depending on the editor and the amount of free RAM you have can be a little dicey. So use the sed command in bash to replace the old hostname (i.e. localhost) with your domain name :)

      sed -i.bak 's/localhost/www.pryde-design,co.uk/g' db.sql

      @Prydie

    • Thanks for sharing, this saved me so much time.

    • No problem. I have written these and a few more tips up on my blog if you want to check it out :)

      http://www.pryde-design.co.uk/2010/06/moving-wordpress-localhost-to-live/

    • rick gregory
      Permalink to comment#

      ANother way to do this is to use phpmyadmin to open the database on the new, live server and edit the relevant fields in, usually, wp-options. Home and siteurl are the two basic ones, but the larger issue are uploads and any embedded paths done by plugins. Those are better to do in a text editor.

  4. A great step by step guide for anyone that’s never done this before.

    One problem I’ve run into in the past when porting a clients exciting site over to work press, is to make sure you have access to modify the .htaccess file.

    I’ve ran into this problem once before when moving a local site to a live server. After double checking everything, and thinking it some sort of weird caching problem, only to fine that the sites permalink settings were unable to write to .htaccess

  5. Jim
    Permalink to comment#

    My go-to resource for migrating WP from local to remote host. Includes the very helpful step of replacing local URLs with domain specific URLs.

    http://www.webdesignerwall.com/tutorials/exporting-and-importing-wordpress/

  6. Michael
    Permalink to comment#

    Chris,

    Excellent screencast. I like the casual approach as it’s like how I approach a new app also.

    I’m just getting going with MAMP Pro and was wondering if I can set up multiple sites locally, but with one being WordPress, Joomla and Drupal?

    Should I just set up multiple folders for each projects and do a fresh install of each CMS in each location? For example, I have 2 drupal sites, so make two folders and install drupal in each to keep them separate?

    Thanks,
    Michael

    • Yes, if you just set up different folders within the ‘htdocs’ folder for the different CMS’s, and create seperate databases within phpMyAdmin. I’m a Drupal Developer, and have several different versions of Drupal running in MAMP, as well as bespoke PHP projects.

  7. Matt
    Permalink to comment#

    I’ve ran WordPress on Nginx, Lighttpd, and IIS 7, so yes, it can run on other web servers besides Apache. The general rule is that if it can use PHP, it can run WordPress.

  8. Ray Tiley
    Permalink to comment#

    Hey Chris,

    Have you ever looked into something like capistrano for deployment? http://www.capify.org

    It works really well for Rails, but I’ve also started using it for my PHP projects as well.

    -ray

  9. Thanks for the mention Chris! Slightly offtopic question: who did the awesome intro for that screencast that you use? Where can I hire him / her? :)

  10. Bert de Vries
    Permalink to comment#

    My procedure looks like this:
    1. Zip the PHP files
    2. Upload the zip file
    3. Unzip the lot
    4. Create database and user
    5. Export the database to SQL file on desktop
    6. Do a scan and replace with notepad
    7. Edit user and database info in SQL file
    6. Import the SQL file and run.
    7. Do a test.
    Thats it. Shouldn’t take more than 5 minutes.
    Greetings from Holland.
    Oh, Chris Congrats….

  11. hey. i love your tutorial chris.
    but i must say i like u better when i see you righting code :) anyway. another great tutorial delivered.

  12. brandon
    Permalink to comment#

    I noticed in the screencast that transmit’s awesome new feature – being able to browse your server as if a normal osx window – seemed to hang up. was the server MT? just wondering… since that transmit feature works fine for me on all hosts except for my clients (and myself) who use MT. The behavior I encountered was similar. I asked mediatemple but they didn’t seem to know. Does that feature work with MT for others?

    • brandon
      Permalink to comment#

      medita temple issue i just resolved… if you connect sftp there isn’t a problem with slowness of the disk feature

  13. Haven’t looked the full screencast yet but one thing I hear you talk about Chris is something I would love to have a plugin for WP. A Plugin that is able to get changes from a local install (as long as you have an internet connection) and apply them to the live site (or the other way around so you always work with the up to date data locally).

    It’s not that the process of exporting and importing the database and copying mostly Theme or/and Plugin files is really hard … it’s just a pain. Something like a “mirror” Plugin would be cool for this.

    • Natalie
      Permalink to comment#

      I keep toying with this plugin (Backup Buddy) http://pluginbuddy.com/purchase/backupbuddy/ for just that very reason.
      Haven’t used it yet, but have an opportunity to shortly. The migration alone would be worth it, but added in backup capability makes it really something I think. Wonder if anyone else has had experience using it?

    • Thanks for the mention of the Plugin Natalie. I heard about it but didn’t know it makes migration that easy as they advertise on the their site. Will have to check out the videos some time soon. I don’t mind paying for a Plugin and 45$ for a single license seems pretty reasonable.

    • Mark
      Permalink to comment#

      Hi Natalie, I’ve bought & used Backup Buddy & been very pleased with the ease of use & the results.
      Full site or DB backup creation is fast & the resulting file can be sent via FTP, email or now uploaded to Amazon S3.
      For migration, backup the site to be moved, upload that zipped file to the destination along with the Importbuddy php file. Run the 5 step php file adding the new DB settings in the appropriate place & login.
      Currently, changes to Username & Password have to be made from with the WP dashboard.

  14. Copying any more than a couple dozen files via FTP is painfully slow. It’s a heck of a lot faster to zip the entire tree, copy the zip, then unzip on the server.

  15. You can use Sequel Pro to import and export the databases without having to log onto different local and live servers and use phpMyAdmin.

    If you open the local database in Sequel Pro and select File > Export > MySQL dump, you’ll export your database as a .sql file – the same as if you did it through phpMyAdmin.

    Then, switch to your live database and select File > Import, and select your .sql file. Done!

  16. I may convert from FileZilla to Transmit – mounting remote directories and drives is extremely useful!

  17. Up to now I “only” used the free version of MAMP because I didn’t really think I would need the paid version. But after the full screencast I might think about it again. After all, it’s not an expensive app at all for what you get.

  18. I dont watc video !

  19. just for the PC users the version is WAMP (Windows, Apache, mySql, Php)

    go to: http://www.wampserver.com/
    you must shut iis server in some windows os

    Linux users version: LAMP (Linux, Apache, mySql, Php)

    go to: http://www.sph.umich.edu/csg/abecasis/lamp/download/

  20. Hi Chris
    Thanks for the screencast.
    I use Mamp pro for a while and after seing your add one personnal domain localy, I try by myself on 80 port.
    Since this time, I can’t connect to this site on line with the same computer I have used for this experiment. It’s weard! If I use an other computer, even on the same wireless network, the connexion to this just work fine.
    I try to restore factory setting on Mamp and delet all caches and cookies but nothing works.
    Anybody has these experience? Have you some tricks? Thanks!

  21. Johnny
    Permalink to comment#

    Hey Chris,

    Did you ever hear what the security concern might be when you “run Apache/MySQL server” as name/name, versus www/mysql in MAMP Pro?

    Anyway I just thought I’d share some observations/problems I had yesterday while trying to get MAMP Pro and virtual servers running on my machine.

    First, I don’t handle discrepancies well, meaning when two of the same thing are different, it baffles me. But the “official MAMP Pro landing page,” telling you your virtual server is running, and the vague “It Works” page, essentially — as far as I can tell — mean the same thing, it’s running. Go figure.

    I’m new to this whole port thing, but had issues using port 80 in my particular configuration. Apache wouldn’t run. But when I left the port blank — I can’t recreate the issue this morning, for some reason — it ran fine. But the local domain I was using had :8888 on the end of it. Short story is if you turn off web sharing (System Preferences>Sharing) Apache runs with the port set as 80, and the :8888 in the address goes away.

    Point is, I’m happy.

    Hope this helps,

    Johnny

    • Permalink to comment#

      Johnny,

      Thanks for mentioning this, I had the same issues.

      With no port set, my local domains resolved at Mac OS X Web Sharing instead of the disk location I set in MAMP. When I tried to set the port to 80, Apache would not start.

      To get my custom local hosts to work in MAMP Pro I had to turn off my Mac’s Web Sharing in the System Prefs and remake the local host with port setting of 80.

  22. Some themes require cache folder to be CHMOD 777 to enable auto thumbnail generation,

    how to enable CHMOD 777 on local host (with MAMP or WAMP) ?

    • stars
      Permalink to comment#

      Yes, Me2

      I want to CHMOD faster then trough the info tab on mac.

      Thnx

  23. Thanks for the rundown Chris. I’ve been using MAMP for a while now, and was wondering whether or not MAMP PRO was worth the upgrade. In addition, I recently ran into a situation where I needed to move from a localhost to live and found this quite helpful.

  24. Well that really helped me a lot with my work. Thanks a million!

  25. Permalink to comment#

    Hey Chris, You really are a life saver spent ages working local host getting all the pages ready. Then had a heart sinking moment thinking I have to do it all again live :( Great vid 10/10 dude!

  26. Thanks for the awesome post, Chris. A real life-saver. Love the easy-going, fun style. Keep up the good work.

  27. Charlie Magee
    Permalink to comment#

    For some reason I can’t use a short name in my browser, like you did with testtesttest. If I try that with my hosts I get permission errors and changing permissions doesn’t help. But if I put in the myfolder:8888/whatever.php, then I can see the pages. What’s the trick?

  28. Durand
    Permalink to comment#

    Chris,
    I’ve used your podcasts before and gotten a lot out of them. I want to say this in the friendliest sort of way… you really need to organize what you’re doing before you start the screen cast. You’re half-way presenting a dozen things at a time while you’re trying to explain whatever the main thing is. Think about creating an outline for yourself. Most of us need a step-by-step using the simplest process and the most basic tools. If you want to demo new features for MAMP Pro or talk about the latest new software you’re using, that might be better as a separate podcast. I have at this point given up using this podcast to help me do basic wordpress migration from localhost to live hosted. I’m sure the explanation was in there somewhere, but you lost me. Sorry.

    • I totally accept and appreciate the criticism.

      I also gotta say they aren’t going to ever be any different. I like to just wing it and make mistakes and just publish it. And enough people have told me they like it that I’m going to keep it that way. I make zero money off these things, and the the only way I can keep doing them is if I can just do it the way I want and that is easiest for me. It’s probably chicken/egg. If I did them really polished up, maybe I’d get more sponsors or whatever and make money on them, but I’m not interested in that.

    • Shawn McCarthy
      Permalink to comment#

      Amen, Chris! I follow all your stuff via RSS, iTunes and Apple TV because you, unapologetically, don’t know what’s going on half the time. And thats who most people prefer to learn from, someone that’s learning alongside them. Keep doing things the way you are!

  29. Dave Allen
    Permalink to comment#

    Chris,

    Just had the same issues uploading via Transmit. But then also with Coda! I noticed Transmit wasn’t able to see my Applications folder. So I moved htdocs to Sites and set the Document Root to there in MAMP preferences. Now works. Odd.

  30. predde
    Permalink to comment#

    Hi Chris,

    First off, thanks for all the work you put into these screencasts, and CSS-Tricks in general. This site is a tremendous resource.

    This is obviously a pretty late comment, but I wonder if you or anyone else out there might care to elaborate a bit on Luke’s initial comment regarding the whole www/mysql thing. When developing WordPress and Drupal sites on MAMP, I run into some permissions problems when I run Apache/MySQL server as user www/mysql (not an uncommon problem, I guess). But when I go to correct the permissions on the folders/files that need it—per Luke’s suggestion—I don’t see any existing “www” or “_www” user. If I try and add a user, I’m given the option of creating a “New Person” with a unique username and password (running Mac OS 10.6.8). Do I really want to create a “www” user, give it a unique password, and then give that user read/write permission? Is there maybe some command line I need to run?

    Apologies to anyone and everyone for what is probably a stupid question with a pretty basic answer… And thanks again.

    • predde

      So, just in case anyone else ever runs into this issue, I ended up solving it with the help of BatChmod, which is a pretty awesome little program that lets you change and assign permissions in OSX. Seems especially helpful in Snow Leopard, which doesn’t list the _www and _mysql users when you use the “Get Info” command on a file or folder. I just used BatChmod to give the webserver read/write on all the files and folders that needed it. I know all this can be done via command line as well, but BatChmod seemed just that much easier.

    • Permalink to comment#

      tried using batchmod and changed user and group to www and allowed read and write. Still the folders are not accessible to me. Should I just go back to user/user? that’s a security problem right? Is that ok if I’m not using web sharing in my sharing preferences?

    • Christiaan
      Permalink to comment#

      I was struggling with this issue too, until tonight. I found out that if you option-click on the “+” in the bottom of the info-window (CMD+i) for an upload directory for example, you can see the full list of users. Then scroll down to the “World Wide Web Server” user (one person icon, not the group with two person icon) and add this user (_www) to the list and select the proper read/write permissions. You should have proper read/write permissions now, assuming you’re running MAMP as www/mysql.

  31. David
    Permalink to comment#

    Thank you, Chris. Really helped!

  32. Wonderful tutorial. I look forward to checking out your other videos.
    Also, thanks to everyone who made suggestions, between the different links that was posted and suggestions and your video, I managed to migrate my site successfully with only a few bumps along the way.

  33. Niek
    Permalink to comment#

    So, if i can create any domain locally, why wouldn’t i just do the following: let’s assume i’m working on this site: niek.com, i develop it locally with mamp (pro only i suppose), calling it just that: niek.com, and then i upload it to the live version of niek.com. Surely this way the database has all the correct paths to images etc, and there’s no need for any search and replace…?

  34. Just installed mamp and ran into several problems, some discussed here.
    1. Could not view site: Change apache port to default: 80.
    2. No php errors display when you have an error; just blank screen. Open up /Applications/MAMP/bin/php/{your PHP version}/conf/php.ini.
    Find display_errors = Off. Change it to display_errors = On.
    Restart MAMP . Why this is off by default makes no sense to me.
    3. Run Apache/mysql as user: web/myslq. This caused site to break because web does not have permission to that folder. If you don’t want to go through the permissions dance (could be dangerous on unix), put your website folders in /applications/mamp/htdocs or /users/your-user-folder/sites. User www has permission to both of those folders.

    • Update on permissions: If you use web/myslq users, you won’t be able to install WordPress plugin from WordPress admin. You’ll have to download the plugin and install it from the zip file.

  35. Emmi
    Permalink to comment#

    Chris:
    I love your video cast. I’ve watched several and they are all helpful and fun. I am new to all of this and I feel like I get to hang out with the big boys.

    I saw someone suggesting that you dont wing it. It was actually really helpful for me to see you go around to try and solve problems. I would not change a thing.

    Thanks for your time and efforts.

  36. Hey Chris,

    Very useful to this total newbie, but I have to correct some of your grammar in the final minute or so of the video:

    “Would’ve come across,” not “Would’ve came across.”
    “Came” is the past tense.
    “Come” is the past participle.
    Since “Would’ve come” (contracted form of “Would have come”) includes the perfect tense form “have come,” you need to use the past participle (“come”) not the past tense (“came”).

    I know that’s not totally clear. Just had to put it out there as your resident grammar Nazi.

    MHB

  37. pablo
    Permalink to comment#

    I found some more better then Sequel Pro tool – Valentina Studio, it works as with mySQL. http://www.valentina-db.com/en/valentina-studio-overview

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like ```this```. You don't need to escape code in backticks, Markdown does that for you.

Sadly, it's kind of broken. WordPress only accepts a subset of HTML in comments, which makes sense, because certainly some HTML can't be allowed, like <script> tags. But this stripping happens before the comment is processed by Markdown (via Jetpack). It seems to me that would be reversed, because after Markdown processes code in backticks, it's escaped, thus safe. If you think you can fix this issue, get in touch!

If you need to make sure the code (typically HTML) you post absolutely posts correctly, escape it and put it within <pre><code> tags.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".