![]() ![]() Thus, we can run a PHP file on Mac using the MAMP. The port 8000 is the default port, and it can be set from the MAMP application. ![]() The index.php file will run on the browser. We can specify the port number of our server from the MAMP application in the Preference option.įor example, after opening the MAMP application, click on the Start Servers option. It is used to run a local server on Mac, and it uses an Apache webserver. MAMP stands for Macintosh, Apache, MySQL, and PHP. We can use the MAMP local server environment to run PHP files on Mac. ![]() Thus, we can run a PHP file starting the Apache server on Mac. The command will display various server information like active status, memory, task, CPU, etc. We can check the status of the Apache server using the command apachectl status. We can stop the web server using the apachectl stop command. The PHP file should be in the root directory to run. Then, typing the URL where our PHP file is index.html will run the PHP file. We can use the command sudo apachectl start in the terminal to start the webserver. We can start the Apache service to create a local server and run our PHP file. PHP comes with a built-in Apache Web Server in Mac. Use the Built-In Apache Web Server to Run PHP on Mac Output: PHP 7.4.11 Development Server () started We can refer to the IP address 127.0.0.1 as localhost. The number 8000 after the IP address in the port used by the IP. It is used for testing purposes in a local machine. We do not need a physical connection to a network. The address 127.0.0.1 is a loop-back address. Go to a web browser and type the address 127.0.0.1:8000/index.php. Write the command PHP -S with the option 127.0.0.1:8000 and press enter. Suppose we have a directory project where our PHP file index.php is located.įirstly, open the terminal and go to the project directory using the cd command. Then, we can specify our PHP file in the URL to run the PHP file. Zip folder and the extracted folder Open the Local Disk and open the extracted PHP folder. Its important to save the file to your local drive. The command PHP -S builds a local server in PHP. When the download is complete, go to your computers downloads folder and look for a PHP zip file. The web server is capable of running only a single-threaded process. It is intended for testing purposes, and it is recommended that it should not be used in public networks. PHP also overs a built-in web server for application development. The server-side languages need these kinds of servers to run the script. There are different web servers like Apache HTTP Server, NGINX, Oracle HTTP Server, Lighttpd, Node.js Server, etc. In this tutorial, we will introduce methods to run PHP on Mac.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |