1. 啟動Apache服務器
(1) 勾選互聯(lián)網(wǎng)共享
打開"系統(tǒng)偏好設置"->"共享"党瓮,在"互聯(lián)網(wǎng)共享"那一項前面打√。
(2) 啟動Apache服務器
版本
sudo apachectl -v
啟動終端命令
sudo apachectl start
瀏覽器中http://localhost
Mac上Apache服務器使用的一些終端命令
啟動:sudo apachectl start
停止:sudo apachectl stop
重啟:sudo apachectl restart
測試配置:sudo apachectl configtest
版本信息:sudo apachectl -v
目錄
文件目錄:/Library/WebServer/Documents
服務器配置目錄:/etc/apache2
2. ?PHP運行
(1) 修改配置文件
前往文件夾/etc/apache2
找到httpd.conf文件盐类,文本編輯打開
搜索#LoadModule php5_module libexec/apache2/libphp5.so
將#號去掉保存
如鎖定可右鍵查看簡介解鎖
如無法解鎖寞奸,復制到桌面修改然后替換
Paste_Image.png
(2) 重啟Apache
終端輸入
sudo apachectl restart
php已經(jīng)可以使用。
(3) 測試info.php
終端輸入
sudo cp /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/info.php
前往文件夾/Library/WebServer/Documents/info.php
打開info.php在跳,在It works!后面加上<?php phpinfo(); ?>
重啟Apache服務器sudo apachectl restart
瀏覽器打開
http://localhost/info.php
顯示php信息頁
Paste_Image.png
3. 配置MySql
(1)使用Homebrew安裝MySQL
brew install mysql
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebr
(2)啟動MySQL
mysql.server start
mysql -uroot即可連接到MySQL數(shù)據(jù)庫枪萄。