30-04-2021



How to work with multiple sites on localhost. Want to Start Learning but cant get passed making MAMP Pro and PHP Storm working? August 31, 2014, 1:37am #3. For example, lets say you have two hosts in MAMP Pro, one called test and one called test1. In DynDNS you need to set up two hosts, you can call them whatever you like but lets say you choose test.dyndns.info (the second part can be one of several choices if you have a free account) and test1.dyndns.info.

  1. Map Multiple Sites On One Map
  2. Mamp Multiple Wordpress Sites

So I am working through the 'Buld a simple PHP application' project, and it's great. As I move through it, I would like to create another project that is more relevant to what I want to do. My question is, what is the best way to do this?

It supports multiple websites, so you can set up several concurrent websites and work on multiple projects at once. It can work with independent environments (like PHP5, PHP 7, and MySQL) for each site, thus allowing you to compartmentalize your work without any issues. I have 3 sites on MAMP local server but in 2 of 3, the htaccess doesnt work. I add this code in httpd.conf (MAMP->apache): NameVirtualHost. <VirtualHost.> DocumentRoot "c:/MAMP/h.

Is htdocs the only folder that is recognizable by MAMP? Can I have multiple projects going within the htdocs folder? I would imagine that if I have more than one project in that folder and I run 'localhost' in the browser, MAMP will be confused. Anyone have a good way to do this?

Thanks!

I am currently running 5 different web projects under my htdocs folder.

I have it structured like Spen mentioned. I have subfolders inside my htdocs folder that are named after the project. In my browser I type localhost/project3 for instance to view and working on the third project in there.

The big trick is keeping your links, images, CSS, etc from breaking since that projects root is not the servers root.

To keep that from happening, I used Randy's lesson on setting up a config file for each project, defining the BASE_URL and ROOT_PATH variables to that particular name for that project.

Then I can use keep my links happy and working. Plus if I ever want to change the name of my project, I can in one location and all of my links and includes should still work.

How to do that is in Randy's PHP lessons.

Thanks Kevin, do you know the exact name of the lesson where Randy covers this? Thanks!

It mostly starts in this lesson http://teamtreehouse.com/library/programming/enhancing-a-simple-php-application/cleaning-urls-with-subfolders. But you may need to back up further to understand it. He uses this as a way of having clean urls with multiple subfolders, but essentially that is what you are doing anyway having more than one site in your htdocs.

Hi Chance,

It's as simple as keeping your multiple sites in sub directories within htdocs.

For example :

htdocs/exampleone - would be one site,

htdocs/exampletwo - would be another

htdocs/.... etc.

Multiple

And to access them in your browser, either just go to localhost and choose the site that you want to see, or go to:

localhost/exampleone or localhost/exampletwo

:)

Posting to the forum is only allowed for members with active accounts.
Please sign in or sign up to post.

I'm trying to set up a workflow wherein I can develop multiple web projects on my local machine. My MAMP document root is set to the default, so I'm simply wanting to have directories for each project (e.g. MAMP/htdocs/project-1 or MAMP/htdocs/project-2) that serve as the homepage of each website. So localhost:8888/project-1 is the homepage for Project 1 and so forth.

When I go to localhost:8888/project-1 in the browser, it's just a blank page, but when I go to localhost:8888/project-1/page.php, it shows the page correctly. Is my .htaccess wrong or am I missing some fundamental concept about developing locally?

Any clues at all are most welcome. Thanks, y'all!

When you go to localhost:8888/project-1 it's going to look for a file named index (in the case of php, it would be index.php) in that folder. Do you have an index file there? That's the file almost all servers will look for first.

When you go to localhost:8888/project-1/page.php it would show a file called page.php

Hey Kevin. Thanks for the quick response, man! I do have an index.php file in the directory, and that's what is so confusing. I set the top of my htaccess, which is in the project's directory, to this:

Mamp multiple wordpress sites

I'm still a novice at htaccess, so there could be a clue there.

Curious, have you tried it without your .htaccess file? I'm a novice too with them, but it looks like you're not wanting to require www in the url (which is fine).

I haven't tried that. I hesitate to simply because it's a large php site I'm setting up a local development environment for, and there are dozens of interlinked pages already on the site. I'd like to keep it a fully functioning replica of the site in production if possible.

Mamp

mmm....I tried you .htaccess file on a test site I have, and it didn't cause any unwanted behavior. So it's in production now? And you're duplicating a dev site to work on it?

Yep. I copied the files via ftp of the live site over to my local machine where I am running MAMP.

To test the htaccess file idea, what about just removing it from the directory and putting it somewhere like the desktop, restarting the server, and see if it behaves as you want. If there is no change, just move it back, restart the server and all should be as it was.

I also wonder, depending on the size of this thing, if there isn't some other logic that is playing with routing. When I first read this I assumed this was a brand new site, with two files, index.php and page.php.

Does this site use some sort of framework, MVC logic?

Mamp

Same thing happening. Blank page on what should be the index. It's a custom template our church hired a development company to build for us, now I and a designer develop and manage the site. It is indeed structured with MVC patterns.

Is it an MVC library like Cake, CodeIgnighter, Laravel, Slim....or is it a custom MVC?

Map Multiple Sites On One Map

Fun...lol. A quick test I'd try is set up another simple, empty project with a index.php, and page.php, and see if your localhost does route to index.php by default.

Mamp Multiple Wordpress Sites

Posting to the forum is only allowed for members with active accounts.
Please sign in or sign up to post.