How to use mamp for php

I already installed MAMP in my macbook pro. I want to run a php. what can i do?

asked Feb 17, 2010 at 18:44

How to use mamp for php

2

If you have done everything right, open your browser and type this:

http://localhost

to see if it opens successfully and then you can open your sites.

Also check out the mamp's documentation on how to configure it and run php scripts.

answered Feb 17, 2010 at 18:47

How to use mamp for php

SarfrazSarfraz

371k74 gold badges529 silver badges574 bronze badges

Drop the PHP file into the HTDOCs folder in MAMP, for example let's call it hello_world.php and now you can run it by going to:

http://localhost/hello_world.php

answered Feb 17, 2010 at 19:33

How to use mamp for php

TravisOTravisO

9,2804 gold badges34 silver badges44 bronze badges

Depending on the port settings of MAMP (Preferences -> Ports) you have to call http://localhost:8888/filename.php (MAMP ports) or http://localhost/filename.php (default ports). The file "filename.php" have to be located in this folder: /Applications/MAMP/htdocs/

answered May 19, 2010 at 14:07

How to use mamp for php

Dirk EineckeDirk Einecke

2,3451 gold badge15 silver badges10 bronze badges

In MacOSX there is a default Apache + PHP server, but if you develop using MAMP, you need to use MAMP version’s of php instead the OSX one.
Here 3 steps for let’s say to terminal the existence of the MAMP’s PHP binaries and use them instead of the ones shipped with MacOSX.

1° step : Verify which PHP is used by your Terminal
Open terminal and add:

$ which php
/usr/bin/php

With this commands you verify which PHP is your Terminal using.
As you can see ( if you are use default Mac OSX apache + php server ) you see as terminal response

” /usr/bin/php “

you can see, the MAMP’s folders don’t are showed. We have to add them to $PATH.

2° step : Add MAMP to $PATH variable

Now we have to modify the “$path” variable by modifying the file ” ~/.bash_profile ” located in root user folder.
We’ll made this by using VIM.
Open it in your terminal by typing:

sudo vi ~/.bash_profile

Since you call vi in sudo mode you’ll have to type your system password.
If you cannot edit the file, enter the Edit mode simply typing a.

Now write in the file the new “$path” variable that terminal has to use ( if you don’t know MAMP’s php version , open MAMP navigate to “Preferences -> PHP” and see the selected versions ).

PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php7.1.12/bin:$PATH

Save the file, press “esc” to quit edit mode, then type

:wp

( or press “shift” and letter “z” for two times ).

3° step: Load “.bash_file” and check

It’s tiem to load new “.bash_profile” fiel:
Type:

$ source ~/.bash_profile

and check if all went good by typing one more time

$ which php

This time the response must be : ” /Applications/MAMP/bin/php/php7.1.12/bin/php ”
That’s right, from now terminal use MAMP’s PHP binaries.

First Steps

After successful installation you can start your local servers. Start MAMP and click the “Start” button in the toolbar. If necessary, you will be asked for your administrator password. The button shows the server status by its color:

  • grey = servers are not running
  • green = server running
  • orange = not all servers are running

The web server (Apache or Nginx) starts by default on port 8888, the database server (MySQL) on port 8889. When calling your web page in a web browser, you must enter the web server port at the end of the URL, e.g.: http://localhost:8888

How to use mamp for php

Toolbar

  • Preferences
    Click on this button to display the settings. Details can be found here.

  • Cloud
    Open up the MAMP Cloud Functions. See the Cloud section for more details.

  • WebStart
    Clicking this button opens the WebStart page in your default browser. This button is only active if a web server is running.

  • Start / Stop
    Start or stop the Apache/Nginx and MySQL services of MAMP.

Main area

  • Document root
    This shows the directory where you store your HTML and PHP files, images, and so on. This directory is called the document root. By default, the directory is set to “/Applications/MAMP/htdocs”. You can change the path in the Preferences (Server).

  • Web server
    Determine which web server will be used.

  • PHP version
    Here you can choose between two PHP versions. The available PHP versions depend on the installed version of MAMP.

Can I run PHP in MAMP?

You can easily install the Apache web server (A), MySQL (M) and PHP (P) on your laptop or home PC. The three come bundled together, referred to as either the WAMP, MAMP or LAMP according to whether you are installing them on Windows (W), a Mac (M), or Linux (L).

How do I run a PHP file in Htdoc?

Now, to run a PHP script:.
Go to “C:\xampp\htdocs” and inside it, create a folder. ... .
Inside the demo folder, create a new text file and name it “index. ... .
Now, to see the script output, open the XAMPP control panel and start Apache to host the local webserver, where our script will be running..

Where is PHP in MAMP?

If you're using MAMP Pro then, it easier to find the php. ini file. All you need to do is have MAMP Pro open, then click File > Edit Template > PHP and choose the version of PHP you are running (either php 5.2. 17 or php 5.3.