Close ad

If you develop PHP applications, you definitely need a test server. If you do not have a server on the website, you have several options on Mac OS to set up a local server. Either you take the internal route, i.e. you use internal Apache and install PHP and MySQL support, or take the path of least resistance and download MAMP.

Mamp is a simple application that allows you to set up a test environment in minutes. You download it <a href="https://cdn.shopify.com/s/files/1/1932/8043/files/200721_ODSTOUPENI_BEZ_UDANI_DUVODU__EN.pdf?v=1595428404" data-gt-href-en="https://en.notsofunnyany.com/">here</a>. You can choose from 2 versions. One is free and also lacks some features of the paid version, but it is enough for normal testing. For example, the number of virtual guests is limited in the free version. It is a fact that it is not quite. I haven't tried it, but I think that the limitation only applies to the graphics tool, which is minimal in the free version, but if you want more virtual guests, it should be possible to get around it via the classic path of configuration files.

Once downloaded, all you have to do is drag and drop the directory into your preferred folder. Either to global Applications or Applications in your home folder. It is also advisable to change the initial password for the MySQL server. Here's how to do it.

Open a terminal. Press CMD+space to bring up SpotLight and type "terminal" without the quotes and once the appropriate application is found, press Enter. In the terminal, type:

/Applications/MAMP/Library/bin/mysqladmin -u root -p password


Where replace with your new password and press Enter. If everything went correctly, you will not get any response, if an error occurred, it will be written. Subsequently, we need to change the password in the configuration files for accessing the database via PHPMySQL Admin. Open the file in your favorite text editor:

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


Where on line 86 we can enter our new password in quotes.

And then the file:

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


In this file, we will overwrite the password on line 5.

Now we can start MAMP itself. And then configure it. Click on “Preferences…”.

On the first tab, you can set things like which page should be launched at startup, whether the server should start when MAMP is started and end when MAMP is closed, etc. For us, the second tab is more interesting.

On it, you can set the ports on which MySQL and Apache should run. I chose 80 and 3306 from the image, i.e. basic ports (just click on "Set default PHP and MySQL ports"). If you do the same, OS X will ask for the administrator password after starting MAMP. It is for one simple reason and that is safety. Mac OS won't let you run, without a password, anything on ports lower than 1024.

On the next tab, select the PHP version.

On the last tab, we choose where our PHP pages will be stored. So for example:

~/Documents/PHP/Pages/


Where will we place our PHP application.

Now just to test if MAMP is running. Both lights are green, so we click on "Open start page” and an information page about the server will open, from which we can access, for example, information about the server, i.e. what is running on it, and especially phpMyAdmin, with which we are able to model databases. The own pages then run on:

http://localhost


I hope you found the tutorial useful and that it introduced you to a simple way to set up a PHP and MySQL test environment on a Mac.

.