# Another MySQL / PHP setup question?



## wicky (Mar 23, 2005)

I downloaded and installed this (an all in one installer for Apache2, MySQL 4.1.8, PHP 5.0.3) ....

http://www.versiontracker.com/dyn/moreinfo/macosx/24368

I think it's all working, but I'm unsure how to test it? Any answers most appreciated!

The installation has created the folder "/Library/WebServer/Documents", which I assume is the actual web server? Inside of the Documents folder I have created a project folder called "MG_site", for the site that I am going to build.

It probably sounds a bit retarded to those of you in the know, but I am unsure about a couple of things.......

1. When I enter a path that refers to the site folder I have been using "http://localhost:80/Library/WebServer/Documents/MG_site". Is this correct, because it doesn't seem to work? If it isn't correct, what should the path be?

2. Am I missing a vital step? Do I have to do anyting else (in terminal, etc) to make php aware of the project folder "MG_site". I have read many articles that refer to the file "httpd.conf", but I can't find this file anywhere on my system.

Apologies if this is all a bit obvious, or repeated elsewhere.

Many thanks


----------



## davidbrit2 (Mar 23, 2005)

The directory /Library/WebServer/Documents is what's known as the "document root". This means that if you open a web browser with just the URL "http://localhost/" it will start digging from that directory. In other words, you'd want to open "http://localhost/MG_site/".

And you should be able to find httpd.conf inside the directory /etc/httpd/ if everything is installed as expected.

If you want to do a quick test of the PHP installation, make a little .php file with these contents somewhere in your web server directory:


```
<?php
print phpinfo();
?>
```

Then just try to request it with your web browser. Crossing your fingers doesn't hurt, either.


----------



## wicky (Mar 24, 2005)

OK, I'm able to access myPhpAdmin and both PHP and MySQL seem to be functional.

Do I have to do anything else to let php know about "MG_site"? Is this the "virtual directory/alias", because that's the bit that doesn't appear to be working?


----------



## davidbrit2 (Mar 24, 2005)

Hmm, you shouldn't have to as long as MG_site is inside /Library/WebServer/Documents. What happens exactly when you try to access it from "http://localhost/MG_site"?


----------



## wicky (Mar 25, 2005)

I'm getting an Apache 2.0.52 PHP/5.0.3 "requested URL not found" at localhost port 80 message.

I have set the root password for MySQL and now I am getting an error when trying to login into myPhpAdmin too, instead of getting a login screen....
ERROR: #1045 - Access denied for user 'root'@'localhost' (using password: NO) 

I am a bit confused =(


----------



## wicky (Mar 25, 2005)

after restarting MySQL I am not getting a different error in myPhpAdmin....
ERROR: #2002 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


----------



## wicky (Mar 25, 2005)

NOT should have been NOW:

After restarting MySQL I am now getting a different error in myPhpAdmin....
ERROR: #2002 - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


----------



## crash (Mar 25, 2005)

since it's local, you may need the trailing slash on the URL.


----------



## Vger (Mar 28, 2005)

Stupid me - didn't know that my new MacMini came with Apache pre-installed.  So I installed the new XAMPP for Mac OSX all-in-one package.  It worked out for the best in the end though, as it has a lot more features pre-installed.  The one thing that is really slowing me down is that every file and folder (transferred lots of websites from my PC) is set to Read Only.  Does anyone know of a way to change the permissions en-bloc?  Thanks - Vger


----------



## davidbrit2 (Mar 28, 2005)

Vger said:
			
		

> Does anyone know of a way to change the permissions en-bloc?  Thanks - Vger



Yup, that's nice and easy.

chmod -R u+w _directoryname_

That'll dig down into the specified directory, giving the owner write permission for everything inside (and the directory itself).


----------



## Vger (Mar 29, 2005)

Thank you David!  Will I have to navigate to the folder to do that, or can I just use that command from anywhere in the Terminal?  And can I apply that to the whole of htdocs by chmoding the htdocs folder?

Vger


----------



## davidbrit2 (Mar 29, 2005)

If you're specifying the COMPLETE path to the directory you want to "fix", it shouldn't matter where you do it.

And there's one other thing I thought of. If you need to change the actual owner of the directory, use chown in much the same fashion.

chown -R _newowner_ _directoryname_


----------



## Vger (Mar 29, 2005)

Great David - thanks very much.  I'm used to using Putty for SSH so although the Mac is new to me working from a terminal window isn't - luckily!

Vger


----------



## wicky (Mar 31, 2005)

OK, I'm still a bit confused....

It appears that PHP isn't being processed by my web server (I've been using GoLive's dynamic bindings purely to test that PHP & MySQL are working, and it's returning an error which states that "your web server is not currently processing PHP").

After I installed PHP, I was able to access phpMyAdmin via <http://localhost/phpmyadmin/index.php>, although since assigning a root MySQL password this now seems to be broken. I get an error #1045 - Access denied for user 'root'@'localhost' (using password: NO), but no obvious "enter password" dialogue area?!

I have edited the httpd.conf file to set up an alias directory, restarted the apache server and MySQL, all of which seemed to work ok. If I access <http://localhost/> I get a PHP version 5.0.3 configuration page... which I assume means that PHP is installed? Do I have to reconfigure anything to make PHP work?

Thanks


----------



## Vger (Mar 31, 2005)

I can't comment on Go Live, but I have Taco HTML installed and that is supposed to have a Live Preview function, which does not work even though the server runs correctly.

I do not know which server and setup you are trying to get running.  In my ignorance (not knowing that Apache came pre-installed on the MacMini) I installed XAMPP for Mac, and apart from the fact that it has to be booted from the terminal window (doesn't boot by default) it all works perfectly.  XAMPP is a complete all-in-one package and the easiest to install.  The XAMPP for Mac OSX is a Beta version but I have had no problems with it at all.  You can find it here http://www.apachefriends.org/en

Vger


----------



## wicky (Mar 31, 2005)

GoLive is not a factor really, I'm just using it for testing the setup because I know it works, and I know how to use it. It's a good test and helps me to eliminate "unknown issues" from the equation. I know from previous experience that if Apache, PHP and MySQL are set up correctly, then the dynamic bindings will connect, and if they're not it won't. 

The server, set up and versions are detailed on the first entry of this thread. I am also using an all in one installation that adds a pref pane to the system perferences panel. It all seems to make sense................. apart from not processing PHP, of course.


----------



## davidbrit2 (Mar 31, 2005)

wicky said:
			
		

> After I installed PHP, I was able to access phpMyAdmin via <http://localhost/phpmyadmin/index.php>, although since assigning a root MySQL password this now seems to be broken. I get an error #1045 - Access denied for user 'root'@'localhost' (using password: NO), but no obvious "enter password" dialogue area?!



Ah, that's an easy fix. By default,  phpMyAdmin is set up to login using a username and password in the configuration file (god knows why). First, find config.inc.php within the main phpMyAdmin directory, then edit it with your text editor of choice. Look for the line that sets "$cfg['Servers'][$i]['auth_type']", and have it set the value to 'cookie' instead.


```
$cfg['Servers'][$i]['auth_type'] = 'cookie';
```

I _think_ that's all you'll have to do there.


----------



## wicky (Mar 31, 2005)

Ok, that seemed to work... at least a little bit. I no longer have the error that I had before, but have a different on instead. Error: The configuration file now needs a secret passphrase (blowfish_secret).

I have already set a MySQl password, is this not the same thing?


----------



## davidbrit2 (Mar 31, 2005)

Gah, okay, there's one more thing you have to set in config.inc.php. There should be a line that sets "$cfg['blowfish_secret']". Make sure it's not commented out, and set it to any old string value that you want to use as an encryption key. For example:


```
$cfg['blowfish_secret'] = 'secret1335897';
```


----------

