Setting up a web server for testing in Mac OSX 10.4 "Tiger"

MAMPSetting up your own web server on Mac to test various open source CMS is a doodle, thanks to MAMP.

MAMP provides you with:

  • Apache 2
  • PHP 4 / 5
  • mySQL 5
  • eAccelerator
  • phpmyadmin

That is all you really need as a testing ground for web developement.

All you need to do is download MAMP (current version is 1.7.1). Once downloaded to your desktop, unpack and drag the icon to your applications folder and run it from your applications folder.

A control panel should appear that looks like this:

and then a webpage will popup in your default browser (screenshot below):

Now you can start to test your sites. Your web root folder is /Apllications/MAMP/htdocs

This is the folder where MAMP will be looking for any of your sites. This can be changed in your MAMP control panel by clicking on 'Preferences' though i would just leave as it. The thing you want to change in the 'preferences is the 'Ports' settings, click on 'Set to default Apache and MySQL ports so it should fill in as:

Apache Port: 80
MySQL Post: 3306

To save you all the hassle having to browse to your htdocs all the time, create an alias link to the folder. Do this by going to /Applications/MAMP/ find the folder /htdocs and right click on it then select 'Make Alias'. This should create a linked folder, drag this to your desktop.

If you need to make some changes to php.ini or the httpd.conf file you'll find them in Applications/MAMP/config folder.

MAMP allows you to switch between PHP 4 or 5, you find these settings in your preferences in the MAMP control panel. I would try and run PHP 5 at all times since PHP 4 support will be dropped by end of next month.

Each site you create should be placed in a folder in the web root. To access your sites use: http:localhost/{folder of site}/

By default, your mysql password is

user: root
password: root

If you are only using it on your Mac without public access then this is fine. But if you decide to open it up for public access then i highly recommend you change the mySQL password.

To do this, open up a terminal and enter:

/Applications/MAMP/Library/bin/mysqladmin -u root -p password < NEWPASSWORD >

Instead of < NEWPASSWORD > use the new password you want.

Once the password has changed, remember to also set the new password for phpmyadmin. To change this, navigate to

/Applications/MAMP/bin/phpMyAdmin-X.X.X/config.inc.php

and open up the file config.inc.php with a text editor of your choice. Find the line:
$cfg['Servers'][$i]['password']      = 'root';

and change 'root' to your new password.

That is all, let the fun begin...

Trackback URL for this post:

http://duvien.com/trackback/40

Setting up a web server for testing in Mac OSX 10....

Bookmarked your post over at Blog Bookmarker.com!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Installing MAMP

Thanks for the post. I am having a little difficult however. When Installed it, it told me that I should use the Pro version and that I should log out and log back in using my administrator account which I did. I plugged in the port settings that you suggested.

I have placed a folder with my site in it into the Users/myUserName/Sites Folder.
That folder contains a file called index.php and a file called style.css.
When I double click on the file called index.php I get an error stating:

Yet, when I try to open files from within Safari the index.php is grayed out as an available option. Any suggestions?

By default the web server

By default the web server serves it's files from folder:

/Applications/MAMP/htdocs

The path can be changed if you want if you go to MAMP control panel preferences --> Apache. You see a document root path, change this to the directory where you want the web server to serve the files from (like Users/myUserName/Sites).

You don't need the the Pro version though it does come with additional features, like setting up SSL.

You can't open .php file like that because these are server-side files which means they are only ran by the web server. Only client-side files like HTML can be executed in the browser by dragging to the browser or clicking on the file.

i cant change password

Vigor13:~ macpro$ /Applications/MAMP/Library/bin/mysqladmin -u root -p password 12345
Enter password:
/Applications/MAMP/Library/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/Applications/MAMP/tmp/mysql/mysql.sock' exists!
Vigor13:~ macpro$

Missing one step in changing passwords on MAMP

in /Applications/MAMP/bin/mamp/index.php

you need to change this line of code

$link = @mysql_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', 'root');

to this

$link = @mysql_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', 'NEWPASSWORD');

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Mollom CAPTCHA (play audio CAPTCHA)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.