I was playing around that quiet long time, because I didn't want to post the question right away I encounter on some difficulties. But here I go.

The goal

is to have separate craft installs for each subdomain.

The problem

When I hit enter to start installation, I get this The requested URL /admin was not found on this server. Have tried with *index.php?p=admin *, but with no effect.

  1. I've set up virtual host subdomain.craft.dev
  2. Checked, if the host loads anything. It does.
  3. Uploaded public files to subdomain.craft.dev and edited

    // Path to your craft/ folder $craftPath = '../subdomain.craft/craft';

    P.S Could I simply use $craftPath = '../subdomain.craft';? I've tried it at first without positive results.

  4. Created folder subdomain.craft above the webroot. In it, uploaded craft folder and set the permission for required directories recursively.

  5. Edited db.php to the needs of Craft's installation.

  6. Run the install by visiting the host address subdomain.craft.dev:8888/admin

  • To me it sounds like either your hosts settings are off –_subdomain.craft.dev_ should have /path/to/your/root/subdomain.craft/public/ as its document root – or your Craft path is off (should be ../craft for the above). What does the host "load" under 2)? – Mats Mikkel Rummelhoff Apr 26 '15 at 13:41
  • I've loaded some image. Well, I run it on MAMP, and if you're OS X user, the 'public' files are located at /Applications/MAMP/subdomain.craft.dev/. The craft folder is described in point 4. – Dominik Krulak Apr 26 '15 at 14:01

I also use MAMP. Here's my general process (I've used generic names in this example; but feel free to rename folders, hosts, as needed):

  1. create the folders for your two sites:

    /Applications/MAMP/htdocs/domain.craft.dev /Applications/MAMP/htdocs/subdomain.domain.craft.dev

  2. Download craft, unzip and copy the public and craft folders to your new folders:

    /Applications/MAMP/htdocs/domain.craft.dev/craft /Applications/MAMP/htdocs/domain.craft.dev/public /Applications/MAMP/htdocs/subdomain.domain.craft.dev/craft /Applications/MAMP/htdocs/subdomain.domain.craft.dev/public

  3. Create two new hosts in MAMP, 'domain.craft.dev' and 'subdomain.domain.craft.dev'; set the 'document root' to the respective '/public' folders; start server. (I also have the server set to serve on port 80 instead of the default 8080; which avoids problems with your craft configuration).

  4. Using Sequel Pro (phpMyAdmin), create two new databases. 'craft_domain' and 'craft_domain_subdomain'.

  5. In each of the sites.

    • Rename 'public/htaccess' to 'public/.htaccess'
    • Set permissions on the following folders and all contents to 777 (for now; will want this more restrictive on public servers)
      • craft/app
      • craft/storage
      • craft/config (technically only need it on the license.key file)
    • (optional) delete 'web.config' from 'public' and 'craft' folders (assuming you don't need them)
  6. Open 'craft/config/db.php' and set the database connection details (server, port, user, password, database).

  7. Open 'craft/config/general.php' and set your config settings, if any.

  8. Open 'public/index.php' and confirm that $craftPath = '../craft'

  9. Navigate to your site in the browser (domain.craft.dev) and (subdomain.domain.craft.dev) and follow on screen instructions to continue install.

  10. Have a beer and celebrate. (maybe 2... one for each site?)

(Did I miss anything?)

Advanced. For steps 6, 7 and 8 above, I actually use a slightly different setup. Instead I use this multi-environment configuration method from the craft cookbook site which allows you to define your environments from within your 'index.php' file; combined with Ben Parizek's technique as described in this answer for automatically configuring 'siteUrl' and 'basePath' environment variables. Note: doesn't work well if MAMP is set to serve on port 8080.

  • :) Thanks. What I've noticed in step 7.? Maybe you know, but If you custom set cpTrigger, than you won't be able to run install from domain.com/admin, but from domain.com/customCPtrigger. I didn't carry on installation, I rather commented in the settings in general.php. But great tutorial @Douglas McDonald – Dominik Krulak Apr 26 '15 at 17:52

Get a copy of MAMP Pro and save yourself the hassle of creating virtual hosts, hacking /etc/hosts, etc.

I do 90% of what Douglas does but with some slight modifications, mostly to simplify permissions.

Serve out of your own Sites folder:

Set up a new site in ~/Sites. Then when you're creating a new subdomain, just point MAMP to the public folder inside of that subdomain. So inside ~/Sites it'll look like:

New Site (whatever.craft.dev) - craft - public <-- point MAMP to this folder.

Another new site (another.craft.dev) - craft - public

Run Apache/nginx as the current user:

That way you don't have to wrestle with permissions since Apache (or nginx) will run as the account that you're logged into.

As an aside:

Mac OS X used to ship with a copy of BIND so you could do wildcard DNS. That would allow you to setup one virtual host block and use Apache to do something like:

<Virtualhost *:80> VirtualDocumentRoot /Users/yourusername/Sites/%0/public/ </VirtualHost>

... basically mapping the hostname to the folder, so all you have to do when making a new dev site is to create a new dev folder (like mynewsite.craft.dev). Some more reading on that.

  • +1 for going MAMP Pro. The license is cheap and its a lot more flexible than the free version. – Mats Mikkel Rummelhoff Apr 27 '15 at 17:32
  • Exactly, creating virtual hosts is main reason, why I've chosen MAMP server. And thanks for the tutorial @RitterKnight. – Dominik Krulak Apr 28 '15 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.