Can't access apache-powered website at localhost
I had errors in my "private/etc/apache2/httpd.conf " file. To fix that I replaced the old file with a new file. To check if you have errors in httpd.conf file, write the following commands in terminal:

sudo apachectl start  


to start apache server

sudo apachectl configtest


to run test if the file's syntax is alright. If get a return command saying syntax OK. Then file httpd.conf file is alright.

In my case sudo apachectl configtest output: 

Abhimanyus-MacBook-Pro:apache2 abhimanyuaryan$ sudo apachectl configtest
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using Abhimanyus-MacBook-Pro.local. Set the 'ServerName' directive globally to suppress this message
Syntax OK


Otherwise replace the old file with a new file that I provided above. 

sudo mv ~/Downloads/httpd.conf  /private/etc/apache2/httpd.conf


i.e. sudo mv [target] [destination]. You can change the target location of you file. If the new file has not been downloaded to Download folder of Home Directory(~).

Once you are done that now follow the instruction written here by etresoft.

. Thanks.