PDA

View Full Version : MAMP, MySQL, Netbeans help- "safari cannot connect to localhost"




Justkeepmoving
Jan 31, 2012, 10:28 AM
Hi all,

Very new to using MAMP and not too hot with running diagnostics or using terminal (though i know some basics).

My problem is i think in setting up MAMP, MySQL workbench and Netbeans to work together... the actual issue is when i click on 'run project' in Netbeans, it opens safari and says that it can't connect to localhost:8888. i am trying to run an .html page.

I ran 'sudo apachectl -t' through terminal as mentioned in another forum and it said 'syntax ok'. Not sure how relevant this is.

Using Mac OS X 10.6.8. I had some issues setting up a new server instance in MySQL workbench- I'm still not sure that my settings are right though the paths check out:

path URL/admin tool: /Applications/MySQLWorkbench.app
Path to start command: /Applications/MAMP/bin/startMysql.sh
Path to stop command: /Applications/MAMP/bin/stopMysql.sh

Oh, also thought it was weird that my basic MySQL server properties (netbeans>services>databases>properties) defines the port i'm using as 3306. Though my MAMP port as defined on the starter page that opens in my browser on opening MAMP is 8889. And Safari is telling me it cant connect to localhost:8888. Why are all these different and should they be the same? The new server instance that i created in MySQL workbench was created on 3306.

Well, thats all the info i can think to provide. Any advice appreciated or links to a good MAMP configuration tutorial perhaps (I have been following a WAMP config tutorial, but it is different. Some of the paths and file names are different to mine and even some of the steps are different. Can't find anything online that explains what i need to know)

Thank you, really appreciate any responses to be able to finally preview my site!

P.S. My apologies- this is a repost from the 'macbook pro' thread as i started the thread in the wrong place first time around, and couldn't simply move it.



4np
Feb 8, 2012, 04:16 AM
Hi,

It is not really clear what your are trying to do, but as you are using MAMP I assume you are trying to program PHP in Netbeans, to run on MAMP's Apache Web server?

PHP does not need to be compiled, as it is executed (interpreted) on page request. So you do not need to 'run' a project as it is being interpreted whenever a page is being requested.

So you just need to code in Netbeans (or any other IDE or text editor), and just browse to localhost (I set my Apache port back to 80).

Note that MAMP indeed uses it's own ports, not to conflict with any other possible running instances. Also, privileged ports (below 1024) require root access, so setting Apache to port 80 would require you to enter your administrator password when you try to run MAMP. Note that you can easily change the ports configured in MAMP by just running the bundled MAMP application...

Also note that MAMP is only able to run one site, and MAMP Pro (which you have to buy) is able to run more. However, it is extremely easy to allow multiple sites (virtual hosts (http://httpd.apache.org/docs/2.0/vhosts/examples.html)) by just editing the httpd.conf. I always develop in ~/Workspace and I have created a folder ~/Workspace/apache to hold my apache virtual host configuration files. Defining host names in /etc/hosts and creating their respective virtual host configurations allows for running multiple virtual hosts from within MAMP:


ME@mbp ~ $ tail -n 1 /Applications/MAMP/conf/apache/httpd.conf
Include /Users/ME/Workspace/apache/*.conf
ME@mbp ~ $


And an example virtual host file:


ME@mbp ~ $ cat ~/Workspace/apache/blog.conf
<VirtualHost *:80>
ServerAdmin me@mydomain.com
ServerName blog
ServerAlias dev.blog.domain.com

DocumentRoot /Users/ME/Workspace/php/blog/htdocs/

ErrorLog /Users/ME/Workspace/php/blog/logs/domain.com_blog-error_log
CustomLog /Users/ME/Workspace/php/blog/logs/domain.com_blog-access_log combined

<Directory /Users/ME/Workspace/php/blog/htdocs/>
AllowOverride FileInfo Indexes
</Directory>
</VirtualHost>

ME@mbp ~ $


and a hosts entry:


ME@mbp ~ $ cat /etc/hosts

...

127.0.0.1 blog dev.blog.domain.com

...

ME@mbp ~ $


When you now run MAMP you can just browse to http://blog/ and see the blog (a wordpress installation).

This allows me to update MAMP whenever I want, and I just have to append that one line to MAMP's httpd.conf to have my setup working again...

Good luck...