I've recently purchased an Apple iMac. Unfortunately, enabling Apache and PHP has thrown up some problems. I enabled Mac's built-in Web Sharing through System Preferences, at which point I got an output and could add HTML files to my user directory. However, PHP files were being displayed rather than interpreted. Installing Apache and PHP on macOS Catalina 10.15. (Spotlight Search) and bring up the terminal. Start as root sudo su - 1) The Apache HTTP Server As Apache 2.4 comes pre-packaged in macOS Catalina 10.15, check the version to verify httpd -v. You can place this newly created Sites directory in the Favorites section of your Mac's Finder.
Introduction
Apache HTTP server is an open source cross platform web server which was released under the license of Apache 2.0. It is developed and maintained by an open community of developers under apache software foundation.
In this tutorial, we will learn the steps involved in the installation process of Apache on MacOS.
Prerequisites
- MacOS
- Login as an administrator on terminal.
- Homebrew must be installed on the system.
Installation
Installation of Apache web server on MacOS includes following steps.
1) Update the repository index of homebrew
To install Apache on our MacOS, we first need to update the index of homebrew package installer. This can be done as follows:
2) Install apache 2.0
![Php Php](/uploads/1/1/8/6/118681083/649689608.jpg)
The homebrew package installer can be used to install Apache 2.0 on MacOS. The installer installs the Apache HTTP server on the location /usr/local/Cellar/httpd .
3) Start apache
Apache provides a service named as apachectl which needs to be started in order to start Apache. The command needs super user privileges to be executed hence we have to use sudo to get the command executed.
This will start Apache HTTP server which can be tested by visiting localhost on the browser. The localhost gives the response as shown below:
4) Stop Apache
To stop Apache, we need to stop apachectl service with super user privileges as shown below.
Mac Httpd
When you stop Apache, the localhost will stop listening on port 8080 and it doesn't give any response.
Well we have successfully installed and test apache which is working fine on our MacOS.
May 4, 2013 11:51 PM
Great guide, thanks John.
Just a note, in case anyone has the same issue. At first I couldn't get this to work. I tried logging out and back in (still no joy), then restarting the mac (still no joy).
Try doing both of those first. However, if, like me, you still can't get the local host site to load, try the following: You should find a file at /Library/WebServer/Documents/index.html.en . This contains the text 'It works!' referred to in the post. What I did was duplicate that file in the same folder and changed the duplicate's name to 'index.html', leaving the original in situ.
Both local and user sites then loaded. After which, I was able to delete the duplicated file and everything now works without issue. Just to be clear, leave the original file index.html.en where it is, untouched and unharmed throughout this step.
Apache Php Server For Mac Shortcut
Apache Php Server For Mac Windows 7
Not sure why I had to take this mysterious detour - probably something local to my machine, but if you're having trouble after following the guide above, see if it helps.
Php Web Server Mac
May 4, 2013 11:51 PM