Jump to content

Need help with MAMP


SaranacLake

Recommended Posts

I am trying to set up a new PHP environment on my newer Macintosh, and cannot seem to get my webserver, MAMP, to work properly.

When I run my PHP code, Firefox launches and the URL says: 

http://www.local.acme/index.php

 

I am using NetBeans for my IDE, and in the IDE, I have the "Project URL" defined as:

http://local.acme/

 

I assume there is some problem with how MAMP is set up, but am unsure.  And I tried to copy all of the settings from my old setup on my old Macintosh, but having been away from all of this for about 2 years, I really have no recollection of how I set all of this up.

Am a dead duck until I can get my dev and run enorionments working again.  ?

 

 

Link to comment
Share on other sites

8 hours ago, requinix said:

So change the Project URL in NetBeans...

I have the Project URL set in NetBeans to what I want it to be...

http://local.acme/

Where is the prepended www. coming from when I run my code in NetBeans?

 

All of my settings from my old environment/laptop match what is on my new environment/laptop...

 

I thought it might be an issue with the php.ini file, but after looking at tha file's contents, I don't see anything referring to my "Web Root".

This is driving me mad!!

 

P.S.  How can I get email notofications when people respond to this thread?  (I didn't know you responded last night.)

Link to comment
Share on other sites

7 minutes ago, requinix said:

What if you go to http://local.acme in the browser? Are you being redirected?

It just rewrites to http://www.local.acme

Like I said before, I haven't done any LAMP stuff in over 2 years, so it feels like I am starting from scratch.

However, a light went off in my head, and I think the issue might be related to virtual hosts I set up like 8 years ago on my old Macintosh...

 

7 minutes ago, requinix said:

"Following" option in the top-right of the page.

I have "New notofcation sent when response posted".

I see an email from your response now.  Maybe Iw asn't getting them before because I needed my post to ne Admin approved?

 

Link to comment
Share on other sites

2 minutes ago, SaranacLake said:

However, a light went off in my head, and I think the issue might be related to virtual hosts I set up like 8 years ago on my old Macintosh...

The issue is a redirect somewhere. It could be in the virtualhost configuration. Typically is.

2 minutes ago, SaranacLake said:

Maybe Iw asn't getting them before because I needed my post to ne Admin approved?

Posts aren't moderated - they're immediately public. I believe it won't send an email if it thinks you're still actively browsing...

Link to comment
Share on other sites

@requinix,

I think the problem is I forgot to set up a virtual host called "local.acme"

Found some notes on my old Mac and may be on to something.

As far as posts, I was sure I saw some message saying my post had to be Admin approved - maybe since I am new?  Either way, I seem to be getting emails when you have posted which is good.  (When I made my first post last week I didn't get any emails.)

Thanks

Link to comment
Share on other sites

I found some old notes that tell me t make changes in the hosts and httpd.conf files.

In the past, I had a parent folder called +htdocs with a bunch of subfolders that represented different "projects" (i.e. websites).

Now what I would like to do is have a folder for Company-A, another forlder for Company-B, and so on.  And then nested in each of those parent company folders, have an +htdocs folder for each company.

Is that possible with MAMP and Apache?

 

Link to comment
Share on other sites

2 minutes ago, requinix said:

Sure. Apache doesn't care what directory structure you use. Put your "htdocs" wherever you want.

I am looking at my notes and the httpd.conf file, and am having a hard time figuring out how to change things.

First, to be clear, this is how I had things on my old Mac...

	MyHDD > DEV > +htdocs > Company1
	MyHDD > DEV > +htdocs > Company2
	MyHDD > DEV > +htdocs > Company3
	

 

Now how I want to organize my Macintosh is like this...

	MyHDD > Company1 > +htdocs1
	MyHDD > Company2 > +htdocs2
	MyHDD > Company3 > +htdocs3
	

 

In my httpd.conf file, I had modified the file like this...

	DocumentRoot "/Users/user1/Documents/DEV/+htdocs"
	

 

But with how I want things, I would need 3 DocumentRoots and I don't see how that can work?!  ?

Link to comment
Share on other sites

In my httpd.conf file, there are 3 places where I modified the code in the past...

Section 1:

	DocumentRoot "Users/user1/Documents/DEV/+htdocs"
	

 

Section 2:

	<Directory "/Users/user1/Documents/DEV/+htdocs/">
	  Options All
	  AllowOverride All
	  Order allow,deny
	  Allow from all
	  XSendFilePath "/Applications/MAMP/htdocs"
	</Directory>
	

 

Section 3:

	<VirtualHost #.80>
	  DocumentRoot "Users/user1/Documents/DEV/+htdocs/Company1/public_html"
	  ServerName local.company1
	</VirtualHost>
	<VirtualHost #.80>
	  DocumentRoot "Users/user1/Documents/DEV/+htdocs/Company2/public_html"
	  ServerName local.company2
	</VirtualHost>
	

 

It seems like the VirtualHosts might allow me to have code for a given company in a distinct location on my computer, but in Section 1 above, it seems like everything needs to be located in a "God" WebRoot directory - which is how I used to have things, but NOT how I want things moving forward!!

Link to comment
Share on other sites

4 minutes ago, requinix said:

I'll say it again:

Apache doesn't care what directory structure you use.

I got that, but in my two posts above, it seems like DocumentRoot contradicts having multiple VirtualHosts.

Can you help me understand how I would need to modify my httpd.conf file FROM supporting multiple VirtualHosts ll nested under one parent DocumentRoot TO instead having multiple VirtualHosts which are NOT located under a central DocumentRoot?

Link to comment
Share on other sites

Please stop. 

WAMP and MAMP are limiting and pollute your workstation with server processes.  Furthermore, almost nobody actually serves their sites from Windows or Mac OS.  

Virtualization makes all this unnecessary.  You have a few different tried and true options.

Docker is the latest greatest.  Once installed, you can easily find a multitude of docker-compose files out there that will configure an Apache/PHP/MySQL stack for you.

Vagrant is also still a viable alternative, is somewhat simpler to understand in that you will typically use a box that is running some well known linux in a virthual machine, which has Apache/PHP/MySQL installed for you.

The bonus is you will have a Linux box of your choice to play with running whatever distro you like.  Centos/RHEL is the most often used in hosting environments, but you can just as easily choose Ubuntu, Debian or whatever else you want.

You can also get a simple OS, and go through the process of installing the separate pieces using the Linux package manager if you choose.  With Vagrant it's very easy in most cases to setup a shared drive where you put your code, so you can use your same IDE and tools.  Setting up XDebug is also not very difficult.

The beauty of these solutions is that you can easily start them when you need to and stop them when you don't.  You can have multiple virtual machines running that simulate clusters and the type of sophisticated development environments that you see in the real world, not to mention you can easily have different versions of php or mysql in seperate VM's for testing.  

These days, with the virtualization technology available, I just can't recommend what you are doing to anyone.  

 

Link to comment
Share on other sites

15 minutes ago, gizmola said:

Please stop. 

WAMP and MAMP are limiting and pollute your workstation with server processes.  Furthermore, almost nobody actually serves their sites from Windows or Mac OS.  

Virtualization makes all this unnecessary.  You have a few different tried and true options.

I am just running a local dev environment, so why get into virtualization?

I was able to host several websites before locally, but now I want to change how I organize things on my HDD and am hoping that I can tweak my httpd.conf file to get the outcome I want with the least effort.

Not to say your idea doesn't have merits, but that is adding a lot of complexity that is unnecessary now for my needs.

 

Link to comment
Share on other sites

I don't care for personal virtualization either. Not for simple dev work, not when it means I have to dedicate half my computer's resources to having a single instance running, not when I have multiple projects to work on.

2 hours ago, SaranacLake said:

Can you help me understand how I would need to modify my httpd.conf file FROM supporting multiple VirtualHosts ll nested under one parent DocumentRoot TO instead having multiple VirtualHosts which are NOT located under a central DocumentRoot?

1. Move each host's document root to wherever you want.
2. Edit each virtualhost configuration to use the new root.

Link to comment
Share on other sites

2 minutes ago, requinix said:

I don't care for personal virtualization either. Not for simple dev work, not when it means I have to dedicate half my computer's resources to having a single instance running, not when I have multiple projects to work on.

1. Move each host's document root to wherever you want.
2. Edit each virtualhost configuration to use the new root.

 

Okay, but what do I do with these two blocks in the httpd.conf file...

DocumentRoot "Users/user1/Documents/DEV/+htdocs"
	

Can I just comment that out or ignore it since everything will map to my Virtual Hosts?

 

	<Directory "/Users/user1/Documents/DEV/+htdocs/">
	  Options All
	  AllowOverride All
	  Order allow,deny
	  Allow from all
	  XSendFilePath "/Applications/MAMP/htdocs"
	</Directory>
	

And what about this block?  (Looks important to me...)

 

 

 

 

Link to comment
Share on other sites

So let me say, I don't recognize +htdocs are being a syntax for something. It's not dynamic hosting. If it is some feature then I don't know what it is. If it isn't some feature and the directories really care named "+htdocs" then it doesn't matter.

With that out of the way,

It almost seems to me that you aren't actually trying to understand anything here. You have no idea what the configuration is and have been successfully copying and pasting from various internet sources to ultimately achieve what you want.

You can continue that process, if you wish, by searching around until you find the answer you need. Or you can actually learn what all this means. What the DocumentRoot is. What, jeez, I guess, what a file path is? Normally it's obvious but maybe here it isn't...

Even an educated guess would be sufficient here. You can plainly see the file paths. You know where the roots used to be so you should recognize them in the configuration. It shouldn't take a huge leap to figure out you should change those paths.

Link to comment
Share on other sites

4 minutes ago, requinix said:

So let me say, I don't recognize +htdocs are being a syntax for something. It's not dynamic hosting. If it is some feature then I don't know what it is. If it isn't some feature and the directories really care named "+htdocs" then it doesn't matter.

It's what I called the directory.

 

4 minutes ago, requinix said:

With that out of the way,

It almost seems to me that you aren't actually trying to understand anything here. You have no idea what the configuration is and have been successfully copying and pasting from various internet sources to ultimately achieve what you want.

Where do you come up with these things?

I have posted what I used in the past in my httpd.conf file, so yeah, I think I have some clue...

It would help if people would answer the uestions I ask and not go off on tangents about things I haven't asked for help with.

 

4 minutes ago, requinix said:

You can continue that process, if you wish, by searching around until you find the answer you need. Or you can actually learn what all this means. What the DocumentRoot is. What, jeez, I guess, what a file path is? Normally it's obvious but maybe here it isn't...

If someone would answer the questions I asked I might learn something more...

 

4 minutes ago, requinix said:

Even an educated guess would be sufficient here. You can plainly see the file paths. You know where the roots used to be so you should recognize them in the configuration. It shouldn't take a huge leap to figure out you should change those paths.

And I said I get that part, but you seem to not be reading my questions...

 

Link to comment
Share on other sites

19 hours ago, SaranacLake said:

I am just running a local dev environment, so why get into virtualization?

I was able to host several websites before locally, but now I want to change how I organize things on my HDD and am hoping that I can tweak my httpd.conf file to get the outcome I want with the least effort.

Not to say your idea doesn't have merits, but that is adding a lot of complexity that is unnecessary now for my needs.

 

First a quick comment on RFC2606 compliant development domains.  Don't use .acme.  The top level domains supported in the overall DNS system  are .test, .invalid,  or .example

I would be rehashing the reasons I provided as to "why get into virtualization".  Virtualization was built into the chip and motherboard you purchased when you bought your mac.

A vagrant installation involves this:

Pre-requisites:

  • Download and install Virtualbox
  • Download and install Vagrant

At that point you are ready to go.  Lots of LAMP boxes out here like Scotchbox.  They have a bunch of instructional videos if you want hand holding and deep dive, however getting it all up and running is often as easy as (in a terminal window):

git clone https://github.com/scotch-io/scotch-box my-project
cd my-project
vagrant up

I set up a Scotchbox while I wrote you this reply.  If you want to stay with MAMP that is certainly your choice, and I wish you the best with it.   I may have come on strong in an attempt to get your attention, but try and advocate for the things I use myself on a daily basis.  In my experience this approach is simply a better way to do development.

 

Link to comment
Share on other sites

1 hour ago, gizmola said:

First a quick comment on RFC2606 compliant development domains.  Don't use .acme.  The top level domains supported in the overall DNS system  are .test, .invalid,  or .example

You took what I said above too literally...

Replace what I said with

http://local.mytopsecretcompany/

 

 

1 hour ago, gizmola said:

I would be rehashing the reasons I provided as to "why get into virtualization".  Virtualization was built into the chip and motherboard you purchased when you bought your mac.

A vagrant installation involves this:

Pre-requisites:

  • Download and install Virtualbox
  • Download and install Vagrant

If you want to stay with MAMP that is certainly your choice, and I wish you the best with it.   I may have come on strong in an attempt to get your attention, but try and advocate for the things I use myself on a daily basis.  In my experience this approach is simply a better way to do development.

 

I appreciate the advice, and will look into things down the road, but you have to realize I have been away from web development and PHP for over 2 years, and I almost wet myself when I finally got MAMP and NetBeans set up correctly and a "Hello World" page appeared!

My #1 priority is to get my website and business up before there is no longer PHP or the Internet!

Then I can look at getting fancy with Virtualization.  ?

 

Link to comment
Share on other sites

Seems that your mind is made up that virtualization is fancy.  People come here every day and start doing things the old fashioned way.  PHP has evolved, and I try and promote the best practices.  There is nothing more limiting than building upon something old and dated, so I can never in good conscience support that when I know it's a mistake.  

That isn't specific to using tools like Vagrant and Docker, but the reality is that these are the things people use these days.  If you are planning perhaps to to deploy to production using AWS, well that's virtualization.

http://local.mytopsecretcompany/

Point is that should be www.mytopsecretcompany.test

Best of luck with your website  ;)

 

 

Link to comment
Share on other sites

18 hours ago, gizmola said:

Seems that your mind is made up that virtualization is fancy.  People come here every day and start doing things the old fashioned way.  PHP has evolved, and I try and promote the best practices.  There is nothing more limiting than building upon something old and dated, so I can never in good conscience support that when I know it's a mistake.  

 

No, I am trying to lesrn how to ride a bicycle and you are telling me to put that on hold to learn painting.

Let me get my website online first - which has little to do with virtual hosts and even less to do with virtualization - and then I can come back and revisit this topic.

 

18 hours ago, gizmola said:

That isn't specific to using tools like Vagrant and Docker, but the reality is that these are the things people use these days.  If you are planning perhaps to to deploy to production using AWS, well that's virtualization.

One step at a time...

 

18 hours ago, gizmola said:

http://local.mytopsecretcompany/

Point is that should be www.mytopsecretcompany.test

Best of luck with your website  ;)

 

Okay.

 

Link to comment
Share on other sites

30 minutes ago, SaranacLake said:

 

No, I am trying to lesrn how to ride a bicycle and you are telling me to put that on hold to learn painting.

 

That analogy just isn't applicable.  You are setting up your development environment, and struggling with that task.   There are different ways to do that, and I suggested you do that in a particular way.   The choice is yours, and I have no issue with your final decision.

A modern, professional PHP project these days involves:

  • Use of composer with a composer.json
  • Your code in git, with a remote repository you push your committed changes to.
  • Typically, people start with a few component libraries (Symfony project) or use Symfony, Laravel or some other solid framework or CMS, so as to avoid reinvention of the wheel, improve quality etc.
  • High quality projects also write unit tests and may have a Continuous Integration (CI) pipeline in place 

These are all decisions and work that will point you in a particular direction, unless of course you are starting with an old code base.  

I started with suggesting Vagrant because it is incredibly simple, and can and does solve problems of setup and configuration of a development environment for people like you.  It involves installing a few pieces (at the end of the day, likely the same number and relative complexity involved in installing Apache, PHP and MySQL on your MAC).  Your responses continue to reflect FUD when that was not the point.  Using virtualization does not involve a PHD in virtualization.  They are just tools that work in most cases.

You saw the advantage of installing and configuring a Java IDE (Netbeans) which certainly is not a small footprint development platform.   At some point you were sold on using that when there are many simpler alternatives that don't require a Java virtual machine to run.  

Again,  my recommendations came out of a desire to help you out.  Clearly I failed in communicating all the benefits in a way that made a strong enough case, but by the same token, the subject matter of this thread has started to move away from the start, which is not my intention.  Although I didn't manage to convince you, others in the future may see this thread and perhaps I'll have more luck with them.

Now where do you actually stand with your setup?  Is it now working?

 

Link to comment
Share on other sites

 

@gizmola,

You seem to be a drill-sergeant an loving father all in one?!

 

9 minutes ago, gizmola said:

That analogy just isn't applicable.  You are setting up your development environment, and struggling with that task.   There are different ways to do that, and I suggested you do that in a particular way.   The choice is yours, and I have no issue with your final decision.

A modern, professional PHP project these days involves:

  • Use of composer with a composer.json
  • Your code in git, with a remote repository you push your committed changes to.
  • Typically, people start with a few component libraries (Symfony project) or use Symfony, Laravel or some other solid framework or CMS, so as to avoid reinvention of the wheel, improve quality etc.
  • High quality projects also write unit tests and may have a Continuous Integration (CI) pipeline in place 

These are all decisions and work that will point you in a particular direction, unless of course you are starting with an old code base.  

I am very interested in learning how to do all of that, but I also stick to what I said (or implied) above...  That being, I have a very large code-base I as working on a couple of years ago for a couple more years, and when I was 95% done, life happened and my work got tabled.

My goal is to "finish what I started" and get my existing environment, tools, approach and code-base into prod so I can get my website up and try to make some $$$ while I regroup.  (Starting to re-organize a Terabyte of crap on my old Macbook and laying it down in a way that I can actually find things on my new MacBook made total sense.  But getting fancy with anything else is likely an unnecessary distraction...)

 

9 minutes ago, gizmola said:

I started with suggesting Vagrant because it is incredibly simple, and can and does solve problems of setup and configuration of a development environment for people like you.  It involves installing a few pieces (at the end of the day, likely the same number and relative complexity involved in installing Apache, PHP and MySQL on your MAC).  Your responses continue to reflect FUD when that was not the point.  Using virtualization does not involve a PHD in virtualization.  They are just tools that work in most cases.

And I am interested, but it was quicker to change a few lines of code in my httpd.conf file then do what you suggested.  (For v2.0, I will check that and your other advice out.)

 

9 minutes ago, gizmola said:

You saw the advantage of installing and configuring a Java IDE (Netbeans) which certainly is not a small footprint development platform.   At some point you were sold on using that when there are many simpler alternatives that don't require a Java virtual machine to run.  

Again,  my recommendations came out of a desire to help you out.  Clearly I failed in communicating all the benefits in a way that made a strong enough case, but by the same token, the subject matter of this thread has started to move away from the start, which is not my intention.  Although I didn't manage to convince you, others in the future may see this thread and perhaps I'll have more luck with them.

There is nothing more than I want moving forward to learn how to code like a modern professional, and start being EFFICIENT, because that is what sunk me the first go around.  (I have solid code that works, but it takes me 10 times longer to do and maintain things than it should for me to be successful.  And, NO, that has nothing to do with tools, but has a s***load to do with architecture and coding styles!))

 

9 minutes ago, gizmola said:

Now where do you actually stand with your setup?  Is it now working?

 

MAMP des what I need it to do for now.

Took me an evening to research, and a few minutes to type the code to make it adapt to my new filing system.

Now on trying to find all of my old code and notes and get my website working in my new dev environment on my new macBook.

Thanks for the thoughts!

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.