How to install web server in MAC

 

In MAC OS, Apache and php already pre install we need to just activate it
Terminal: sudo apachectl start to activate apache
Open browser and type localhost it will display "It Works".
Now go to computer->osx->Library->WebServer->Documents then find all the sites that hosted by server

For activate PHP

Terminal: sudo nano /etc/apache2/httpd.conf

search the file that followed by php7 and then delete the  infornt of the line and sove the file by control+o then press enter then exit by control+x.

 

Now restart webserver with command
sudo apachectl restart

for make sure that ebserver always use php file first for that:-
terminal: sudo nano /etc/apache2/httpd.conf
than in directory index serction starting with IfModule change 

DirectoryIndex index.html ---> DirectoryIndex index.php index.html
 

This will make sure if you open the localhost your website will first serch for the index.php and then index.html file
Now save by control+O and hit enter then to exit press control+X.
then
Terminal: sudo apachectl restart
 


Answer