28

Frontend Local Development Setup?

5 years ago from , Freelance Frontend Developer

Hey DN, Im currently trying to tighten up my local development setup.. Currently I'm using MAMP with my projects inside my Sites folder on OSX.

My folder structure is like so: ~ Sites ~ ~ Project-Name ~ ~ ~ Design ( All project PSD's, Sketch files & other assets ) ~ ~ ~ Web ( All project web directories )

Then to view the a site when MAMP is running, i visit http://localhost:8888/project-name/web Im currently looking at moving from MAMP to either MAMP Pro, Vagrant or AMPPS.

Just wondering how other people have their local dev environments setup and if anyone has any suggestions on how i can improve mine?

Any help is appreciated.

36 comments

  • Jonathan SuhJonathan Suh, almost 5 years ago (edited almost 5 years ago )

    Although Mac has Apache, MySQL, and PHP baked in, I've decided to reinstall and manage them with Homebrew (makes it less of a pain when upgrading).

    All of my projects live in separate folders in ~/Work/.

    I create a separate virtual host file for every new site. My virtual host files live in /etc/apache2/sites-enabled/ (They're symlinks from /etc/apache2/sites-available/, which is configured to work this way in httpd.conf)

    I give each site a unique local servername (following the convention new-website.local, that way I can have a neat URL for every site (http://new-website.local), absolute paths work nicely, not worry about turning sites on/off, etc.

    Once you get into a project folder, I use Grunt and Bower to handle my package management and automation. Here's a view of my typical, barebone project structure.

    project-folder ├─ _orig (random source files) ├─ assets │ ├─css │ ├─images │ ├─js │ └─sass ├─ bower_components ├─ node_modules ├─ bower.json ├─ Gruntfile.js ├─ package.json └─ index.html

    I have a pretty elaborate Sass structure, too. If you're interested in it, here's a screenshot of the structure from a previous project http://cl.ly/XNLx/how-i-organize-my-sass.png. I also open-sourced my personal site on Github https://github.com/jonsuh/jonsuh.com, which should give you a good idea of how I structure my projects.

    12 points
    • Daniel GoldenDaniel Golden, almost 5 years ago (edited almost 5 years ago )

      Do you use screen.scss as your base sass file that is included on every page and then just create a stylesheet for any page specific styles?

      Edit: That is what I gather from your sass screenshot. Is my assumption accurate?

      0 points
      • Jonathan SuhJonathan Suh, almost 5 years ago (edited almost 5 years ago )

        Correct.

        I try to spend a lot of time glancing at a site's designs and breaking out reusable elements as modules. Usually page-specific Sass files have modifying classes for existing modules, unless that page has unique elements specific to that page and that page only.

        1 point
    • Hamish TaplinHamish Taplin, almost 5 years ago

      Do you have any problems using .local for the tld? OS X has always been slow for me doing that, see this article: http://www.justincarmony.com/blog/2011/07/27/mac-os-x-lion-etc-hosts-bugs-and-dns-resolution/

      I stopped using .local and use .dev instead.

      1 point
      • Jonathan SuhJonathan Suh, almost 5 years ago (edited almost 5 years ago )

        As of a matter of fact, I used to. I forget where I read it, but here's how my /etc/hosts file looks like for every site entry:

        0.0.0.0 jonsuh.local ::1 jonsuh.local fe80::1%lo0 jonsuh.local

        Since then, I haven't had any issues with .local being slow.

        And this is what the top of my hosts file looks like:

        127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost

        I personally avoid using .dev anymore on my local machine since many times I have 4 environments (local, development, staging, and production) and development means it's on a server set up closer to production, but still a playground where I push my local changes and break stuff.

        0 points
  • Dominik SchmidtDominik Schmidt, almost 5 years ago (edited almost 5 years ago )

    Be sure to check out my blog post about this. Otherwise just read further.

    I am using Yeoman for my front-end setups. When starting a project with a new technology I am trying to get a generator together or find on of the exisiting one's.

    After finding the right generator and generating the project (mostly coming with grunt or gulp as task runner) I am serving it through grunt serve, grunt or anything like that (see the generator's documentation).

    When this is done, I am almost finished with the setup of my new project. Grunt/Gulp starts the web server I am working on and everything works right out of the box (minification, concatening, etc.).

    Advantages of the use of grunt against use of MAMP: - No need to go into a deep link like /project-name/html or something - Tasks automatically done with build Task - Optimization of images and loading time of your page

    The only disadvantage is, that MAMP is offering PHP from the beginning. Didn't worked with Yeoman and PHP.

    That's how I normally do front-end development.

    Not a fan of CLI-tools? Try CodeKit or Anvil or another alternative

    5 points
  • Varun VachharVarun Vachhar, almost 5 years ago (edited almost 5 years ago )

    I use Gulp for everything. And have a couple of standard tasks that:

    • Start a node server using gulp-connect
    • Sets up live re-load
    • Watches and auto compiles SASS

    Project structure changes a bit depending on whether it's a mobile app or desktop, but generally:

    Project-Folder ├---- bower-components ├---- node-modules ├---- scss ├---- css ├---- img ├---- app (app stuff, js and partial html files, go here) ├---- bower.json ├---- package.json ├---- gulpfile.js └── index.html

    Seriously could not recommend Gulp enough. It's just so much easier to use and understand that Grunt.

    4 points
    • Hamish TaplinHamish Taplin, almost 5 years ago

      Have been meaning to move to Gulp for a while but I have tons of Grunt tasks that I rely on and am concerned there won't be a Gulp equivalent, have you found this to be the case at all?

      0 points
      • Varun VachharVarun Vachhar, almost 5 years ago

        Not at all. The Gulp community just exploded and all the Grunt plugins I ever user have Gulp equivalents now.

        Gulp adopts a different philosophy. No temp files, etc. Data is just piped from one task to another until you want to save it to disk. Makes life so, much easier.

        0 points
  • Daniel GoldenDaniel Golden, almost 5 years ago

    Anyone using Hammer or Anvil for managing local websites?

    3 points
    • Chris ColemanChris Coleman, almost 5 years ago

      I used to use them extensively, but they turned out to be not so good for collaborative work.

      2 points
    • Andrew ZimmermanAndrew Zimmerman, almost 5 years ago

      I've tried this combo and it works fine for my minimal projects. This is at home where I can control my environment. I think I need to move into package management and versioning tools to take my frontend dev skills to contemporary standards.

      At work, we don't use any preprocessing, version control, or even have a dedicated dev environment. It's me, notepad, a renegade web server in the design department, and a lot ctrl+c, ctrl+v, ctrl+r.

      0 points
  • Felix FeierabendFelix Feierabend, almost 5 years ago (edited almost 5 years ago )

    »The Perfect Web Development Environment for Your New Mac« by Chris Mallinson helped me alot.

    Sublime Text, iTerm 2, Codekit and GitX as the tools is what i settled on.

    if you're into Wordpress checkout A WordPress & Git Workflow by Marc Jenkins

    and finally if you're using git for your projects (you should) and do freelance work, clockout by Dan Hassin checks your git commits and gives you an nice timesheet plus customizable estimations

    2 points
  • David DarnesDavid Darnes, almost 5 years ago (edited almost 5 years ago )

    Each time I want run a site locally I just use:

    php -S localhost:8000

    after I cd into the root of the site I'm working on. I just used this tutorial to setup php and mysql on my local machine http://www.createdbypete.com/articles/php-54-development-on-os-x-with-mysql-and-laravel-4/ Just miss out the laravel part.

    2 points
  • Jordan KoscheiJordan Koschei, almost 5 years ago

    I made the switch recently from MAMP to Vagrant and I haven't looked back.

    Vagrant is a little tricky to get set up, but the advantages are enormous. I love being able to partition things – if one Vagrant box breaks, it doesn't affect anything else. You can have completely independent instances of MySQL running for each project. Best of all, I love being able to go to "mysite.dev" or any other arbitrary address rather than localhost:8888. It just feels cleaner.

    2 points
  • James Van Dyke, almost 5 years ago

    We use a custom gruntfile to serve our content, because we have a thick client. Our API runs in a separate process, started manually.

    I've used MAMP before and wasn't too happy. I prefered to have more control and run closer to production by using a custom provisioned VM with Vagrant.

    If you're looking to try something new, I would suggest using a Docker-based solution like Fig or even simpler, Bowery.

    1 point
  • George GritsoukGeorge Gritsouk, almost 5 years ago

    If you're working with static sites, I recommend Anvil which gives you nice clean URLs for local development and for other devices on the same network.

    1 point
  • Alaik FAlaik F, almost 5 years ago

    My daily development tool is AMPPS + Sublime Text + CloudKit + Tower. For the local development setup I created two ssl enabled virtual hosts with AMPPS : https://projects.dev and https://playground.dev

    I deploy all of my projects in a subfolder under projects.dev and using playground.dev for testing, debugging and playground purpose.

    AMPPS allow me to deploy and update cms such as wordpress, joomla etc in one click. It also able to deploy frameworks such as YII, laravel, symphony etc easily in one click too.

    0 points
  • Jack CallisterJack Callister, almost 5 years ago

    MAMP is overkill (assuming you are only doing front end).

    Simply fire up a python server (in terminal) in your project directory -

    python -m SimpleHTTPServer

    That's it.

    You don't need MAMP since you're only using the Apache part of the stack. Use a python server instead. There's less configuration (none) it ALWAYS works and is simple to understand.

    I've got a React boilerplate that has an example of how to do this.

    0 points
  • Tyler Fowler, almost 5 years ago (edited almost 5 years ago )

    Personally, I like to use a combination of CodeKit and Grunt (CodeKit for simple stuff, Grunt for doing pretty much anything it can't do, still waiting on the ability to run bash commands on CodeKit reload). For source control, a combination of SourceTree and the command line, and for a text editor I use the always wonderful Atom (heavily customized).

    As for project structure, I like to keep it as structured as possible:

    ~ {project-name} ~~ app ~~~ css ~~~ img ~~~ js ~~~ templates ~~~ index.html ~ bower_components ~ node_modules ~ sketch ~ src ~~ coffee (* or whatever languages are being used *) ~~ scss (* or whatever css superset is being used *) ~~ templates (* raw -- uncompiled *) ~ gruntfile.js ~ package.json ~ readme.md ~ server.js
    0 points
  • Amazing RandoAmazing Rando, 5 years ago (edited 5 years ago )

    I have my Mac setup to dynamically create virtual hosts using dnsmasq. You can see how to set it up here.

    Folder structure/URL:

    ~ www ~~ ar (ar.dev) ~~~ project 1 (project1.ar.dev) ~~ wr (wr.dev) ~~~ project2 (project2.wr.dev) ~~~ project3 (project3.wr.dev)

    (Wish that I had time to post a more substantive reply to the original poster's question.)

    0 points
  • Chris ColemanChris Coleman, almost 5 years ago

    MAMP and MAMP Pro are so unnecessary these days. The tools to do this stuff yourself are out there and they're not hard to use.

    Here's a very good guide to setting up a local PHP environment: http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/#disqus_thread

    For virtual hosts, just use virtualhost.sh.

    My directory structure is very similar to yours. I also keep a www directory in my ~/Sites, and symlink the various domains to there.

    All that said, I'm considering going the Vagrant route at some point in the future. It's mainly a matter of finding the time to get over the learning curve.

    0 points
  • Kenan Bendz, almost 5 years ago

    I'm at a agency with a lot of developers and frontenders, I can only talk from my experience, and what i observed through my colleagues.

    I wouldn't advise ever using MAMP. It can cause much more headaches and customization can be a real pain. Vagrant is fine - but it's incredibly resource hungry. Most of the people who used Vagrant at our company have removed it again.

    I'd suggest

    • apache2
    • mysql
    • php
    • dnsmasq

    Documentation on how to set it up, if you'r on a mac. article 1article 2

    0 points
  • Jesse DobbelaereJesse Dobbelaere, 5 years ago (edited 5 years ago )

    Some people here seem to use a zero-config development setup and I recommend it too. I just use MAMP or Vagrant, and have a folder structure like this:

    • Sites --- company ------ project-name

    I use DNSMasq for local resolving. If I want to start a new project, I just create new folder(s) and create some html or php files. I just have to browse to http://project-name.company.dev and everything works. No hassle with adding virtualhosts etc. DNSMasq will catch domains ending on *.dev (or configure it for .local) and resolve it to the local machine to your MAMP server. In the apache config I made a virtualhost config that uses the domain name to find the company and projectfolder.

    Read more about it here and here. I use DNSMasq instead of Pow though

    0 points
  • Thibault MaekelberghThibault Maekelbergh, almost 5 years ago

    I'm using my own boilerplate for frontend work. It includes Gulp and Compass for quicker coding.

    For backend I use this boilerplate from a classmate which is largely based on the one I threw together but has a PHP backend.

    Also using MAMP and not sure if Vagrant is the correct fit for me, think it would be overkill.

    0 points
  • Matthew R. MillerMatthew R. Miller, almost 5 years ago

    I just use Cactus, as it's more than plenty for my needs.

    0 points
  • Russell Heimlich, almost 5 years ago

    I love AMPPS. It's cross-platform and just like MAMP Pro but free. I do a lot of WordPress work and they have one click installs that sets up the database, downloads and configures the latest version of WordPress etc. etc. I would at least give it a whirl before considering MAMP Pro.

    0 points
  • Andrew HarrisonAndrew Harrison, almost 5 years ago (edited almost 5 years ago )

    We used to run our stuff using the built in OS X Apache or MAMP, but have recently moved everything over to Vagrant, which is much much better.

    My structure is essentially:

    • Project Assets (PSDs etc.): ~/Documents/[project name]
    • Website Code: ~/Sites/[project-name]/

    Each site folder is its own Git repository (previously remotes were on Github but we've moved to BitBucket).

    My VMs including one Vagrant box (soon to be two) live in ~/VMs/. I use Vagrant Manager to Up/Halt/SSH into it.

    My entire ~/Sites/ folder is a synced folder to the Vagrant box's /var/www/ folder.

    So, to set up a new site:

    1. Create a new repository (or pick an existing one) and clone it into a new folder in ~/Sites
    2. Launch the Vagrant box and SSH into it
    3. Run the vhost script (our own variation of this one): sudo vhost -d /var/www/[project-name] -s [project-name].dev
    4. On my Mac, edit the Hosts file to point the new domain to the Vagrant box (I use Gas Mask for this, it's great): 192.168.33.10 [project-name].dev

    Then I can open http://[project-name].dev in my browser and see the site! I also have a generic host set up pointed at /var/www/ which allows me to visit http://vagrantbox.dev/[project-name]/ without having to set up the virtual host in the box itself.

    Moving over to Vagrant was all a bit confusing at first but now that we're set up (and now that the set up is so easy) everything hums along nicely and it's nicer than the alternatives.

    Edit: Formatting.

    0 points
  • Roland LössleinRoland Lösslein, almost 5 years ago

    I was used to work with MacOS' native server environment. But updating to another major version of MacOS was always a pain in the ass since you had to setup the server again from scratch and install MySQL again.

    Today I'm using Vagrant and I love it. It is a bit of a learning curve to setup Vagrant properly, but once this is done it is easy as using MAMP oder the native server environment. The most tricky part is setting up the configuration in order to get a fully working server. I've prepared a proper Vagrant box for frontend developers and I'd like to share it with you. You'll find a fully documented repostiory over at github. https://github.com/weaintplastic/Vagrant-LAMP

    I'm happy to help if you need some instructions or if you have any questions.

    0 points
  • Karl SanderKarl Sander, almost 5 years ago

    I use the OS X server tool instead of MAMP or other server setups, mostly because i like pain.

    0 points
  • Carlos MañasCarlos Mañas, almost 5 years ago (edited almost 5 years ago )

    I am using MAMP + gulp and my setup looks like this: - projects -- client --- project-name ---- _www ----- _dev ------ js ------- plugins ------ scss ----- css ------ layout ------ img ------ incl ------ js ------ vendor ---- assets ---- design ---- resources

    0 points
  • Akram El YoubiAkram El Youbi, almost 5 years ago

    Apparently I'm the only one here who likes using WebStorm \o/

    0 points
  • Chris Winch, almost 5 years ago

    I'm just getting round to reading all these, thanks for all your reply's! Definitely got me thinking :)

    0 points