Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:Stooryduster/Very Easy Setting up of Local Server on Mac.

This article is a ROUGH DRAFT. The author is still working on this document, so please do not edit this without the author's permission. The content within this article may not yet be verified or valid. This information is subject to change.

Very Easy Setting up of Local Server on Mac.

You will be able to set up a local server on your own Macintosh, with minimal technical knowledge and no need to type code. You can then install WordPress on your own Mac which means no need for FTP or an internet connection or worrying about issues with another's server, hackers or anyone stumbling upon work in progress. Much more relaxing. You can use your local server to have an exact copy (mirror) of your public WordPress site.

You Need Two Things:

1. A Mac with OSX.
2. Mamp – downloadable from http://mamp.info

That is all.

Short version:

Three Steps.

One: Download the Mamp File, open it and drag the Mamp Folder into your Applications Folder. It needs to be there.

Two: Double click on the Mamp application. Congratulations your web server should be running. The info for entering into wp-config.php will be open in the web page welcome to Mamp that will open in your default browser. You can also access phpMyAdmin through this welcome page which will let you edit your database. Type a name for your database and and click create.

Three: Drop the WordPress Folder into your web root folder (usually in Username>Sites), follow the WordPress installation instructions to edit the wp-config.php file and off you go. You can find or set where the web root folder is by looking under 'Apache' in the preferences options for the Mamp application.


Power users can pay and use Mamp pro which gives you many extra options.

Finding your Local Address.

Your local address (it is usually http://localhost) you can check by looking in the Mamp web welcome pages that opened when you installed Mamp. Select 'phpMyAdmin' web page then click on 'Show MySQL system variables' and then scroll down to 'hostname' on the left and read off the address on the right 'example.local'. You will have to prefix this of course with http:// when you enter it in your browser. 'http://example.local/wordpress/wp-admin/install.php'

Good luck.

Longer Version

Download.

Download and expand the Mamp file. It is a .dmg file (disc image). Double click on the downloaded Mamp dmg file and it will mount the disc on your computer.

Install.

The process of double clicking on Mamp should – after you click to agree to the license – open a nicely designed window with a two sentence set of instructions to the left - in six languages.

Install window for Mamp.


The instructions are: drag the Mamp Folder into your Applications Folder. It needs to be in your Applications Folder it will not work elsewhere.

Activate Server, PHP and MySQL.

Double click on the Mamp application located in your Application Folder. It should start up and then activate Apache, PHP and install and activate MySQL light. Your server is up and running.

On the Mac under 'System Preferences' (found in the doc or in the applications folder) make sure that under the 'Sharing' in the 'Internet & Network' section that 'Web sharing' and 'Internet Sharing' are turned off (no ticks in the boxes) in case there is any conflict with Mamp. If you have not touched them they are off anyway – they are off by default. (Enabling Web sharing starts up Apache but not PHP or MySQL).

Mac Internet Preferences.


Information for wp-config.php.

Once Mamp is launched a welcome to Mamp web page should open displaying the information you need for your scripts and WordPress. Which would be: your Host, Port, User name and Password. These are needed for your WordPress wp-config.php file.

Mamp welcome page.


The welcome to Mamp web page also give you access to a php info page, phpMyAdmin page, SQLiteManager page and a FAQ page. You shouldn't need to touch any of these controls unless you know what you are doing, are following instructions, or are setting out to learn.

(Wherever there is any risk anyone but you can access your computer (always) then you should change password and user names from the default into something else. Make passwords at least 8 characters long with some numbers in it and no words that can be found in any dictionary in the world. Then change it again every so often).

Creating the Database.

In the 'welcome to Mamp' web page go to 'phpMyAdmin' and you will see a create a new database option. Enter your choice of name for the database and click the Create button. You're done. Your new database should appear in the drop down menu in the left panel. You will need your database name for installing WordPress.

PhpMyAdmin Page.


Finding Your Local Address.

Your local address is the http address for your local web site. You will find information on this if you enter 'local host' in the search panel in 'Mac Help'.You can also find your local address in the Mamp phpMyAdmin local web page by clicking on 'Show MySQL system variables' link.

PhpMyAdmin Page.


And then scrolling down in the 'MySQL system variables' to 'hostname' on the left and then reading off your address on the right - in this case: 'example.local'.

Hostname Location


You will have to prefix this of course with http:// when you enter it in your browser.

Mamp Help Files.

If anything does fail then look in the help files and FAQ and ask on the Mamp forums which are well supported. There is a link at http://mamp.info. Mamp's worked every time for me so far so no experience of fixing it if there is a hiccup. Sorry.

Stopping and Starting the Server.

A Mamp control panel should also be open where you can 'Stop Servers', 'Open the start page', change 'Preferences' or 'Quit' the application.

Mamp Control Panel.


Under 'Preferences' you have 'Start/Stop', 'Ports', 'PHP' and 'Apache'. All the defaults should be fine apart perhaps from in 'Apache' in 'Document Root' where you set your web root folder.

Mamp Preferences.


Under 'Apache' you can change the Document Root – where your web site and all its files are going to be. It's not good practice to save documents and files into your Applications Folder which is the default under Mamp. You should set the Document Root to a folder somewhere in your Documents Folder - or your Sites Folder.

I had one hiccup. My browser wouldn't recognize both html and php files. I changed ports from the 'Mamp ports' to the 'default Apache and MySQL ports' under Mamp 'preferences' and it all seems to be fine. You will have to enter your Mac admin password when you start or stop the server with this setting. You don't have to with the 'Mamp port' settings.

A simple test to see if you can get your site to work is to create a plain text only file - not a Word or word processor file - name it index.php and put it in your root folder.

Type or copy into the index.php this simple code: <html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <title>PHP Test</title> </head> <body> <?php echo'<p>Hello World</p>'; ?></body></html>.

The doctype is important on the web but it would work well enough for our test without it.

If all is OK you will see "hello world" in the browser when you point it at your site on your local server running on your own Mac at 'http://whateveritis.local' – please don't put in the ' quotation marks.

Go and follow the WordPress installation instructions. You will be asked to configure the wp-config-sample.php with your database details. Then transfer your WordPress folder to your web hosting server. However (because it's all going to work on your local Mac) you can instead drag and drop your WordPress folder into your local web root folder. Then open and type your local address into your browser http://whateveritis.local/wordpress/wp-admin/install.php and follow the WordPress instructions that appear. Good luck.