If you are trying to install Apache in Mac OS use the below step by step tutorial.

Step 1:

Install Apache with the help of homebrew. If it is not installed in your system. You can install it from here.

Step 2:

After installing homebrew, Run the below command to install apache.

brew install httpd

Step 3:

After completing the installation process, configure httpd service to be auto-started on system boot.

sudo brew services start httpd

Step 4:

By default, Apache will run on 8080 port. you can open below link in the browser and if you see the message β€œIt Works!” it means you have successfully installed the apache in your system.

http://localhost:8080

If you want to change the listen port of Apache, change the value of listen port from 8080 to 80 in the /usr/local/etc/httpd/httpd.conf

Find the line with
Listen 8080

and change it to
Listen 80

Step 5:

Commonly used command to manage apache server

sudo apachectl stop
sudo apachectl start
sudo apachectl -k restart

Let us know by comments if you face any trouble in the above steps.

Happy Coding!!