![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_00.jpg)
但若只需要PHP環境時,在macOS就已內建了Apache與PHP,因此完全不用再安裝第三方的套件,就可直接將MAC內建的Apache與PHP給開啟,同時一樣的地方就在於,當要使用時,再將Apaache開啟就可以,至於要怎麼開啟MAC內建的Apache與PHP環境,現在就一塊來看看囉!
重點提示
sudo apachectl start
sudo apachectl restart
sudo apachectl stop
網站根目錄:/Library/WebServer/Documents
sudo apachectl restart
sudo apachectl stop
網站根目錄:/Library/WebServer/Documents
Step1
首先,開啟終端機,並輸入sudo apachectl start後,再輸入電腦的管理者密碼。
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_01.jpg)
Step2
接著開啟瀏覽輸入,http://localhost或http://127.0.0.1,當看到It works!,就表示Apaceh的Web伺服器,已正常運作,但現階段並不支援PHP。
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_02.jpg)
Step3
接著開啟/etc/apache2/httpd.conf檔案。
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_03.jpg)
Step4
接著透過文字編輯器,將httpd.conf檔案開啟。
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_04.jpg)
Step5
接著再透過搜尋,尋找「LoadModule php7_module libexec/apache2/libphp7.so」,將前方的註解拿掉,再把文件儲存起來。
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_05.jpg)
Step6
這時再回到終端機,輸入sudo apachectl restart,重啟Apache。
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_06.jpg)
Step7
接著再前往網站根目錄「 /Library/WebServer/Documents」。
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_07.jpg)
Step8
進入網站根目錄後,再放進phpinfo檔案,來作檢測。
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_08.jpg)
Step9
回到瀏覽器,並輸入http://127.0.0.1/phpinfo.php,就會看到以下的畫面啦!這樣就已將WebServer與PHP的環境都建立完成,是不是超簡單的呀!
![梅問題-[教學] macOSX 開啟內建 Apache 網站伺服器與PHP環境設定](http://photo.minwt.com/img/Content/mac/mac-webserver-apache/mac-include-apache_09.jpg)