OS X Yosemite 10.10.1 + Apache + PHP + MariaDB
作業系統:Mac OS X Yosemite 10.10.1
系統已經內建 Apache 和 PHP
Apache
PHP
編輯Apache設定檔
下面是放置網頁的路徑,可以修改至/Users/使用者名稱/網頁資料夾
把#拿掉
產生php設定檔
MariaDB
首先要已經安裝好homebrew
開始安裝與設定
登入MariaDB
查詢版本
離開MariaDB
phpMyAdmin
從網路下載phpMyAdmin後放置在/Users/使用者名稱/網頁資料夾(同上面設定的路徑),並且新增資料夾命名成phpmyadmin
開啟網頁後輸入網址localhost/phpmyadmin/setup
接著按下“建立伺服器”

至認證頁面,設定如下圖,完成後按下“套用”自動跳回上一頁再按下“儲存”
完成後把config資料夾裡的config.ini.php複製到上一層
在config.inc.php裡將底下這行的localhost修改成127.0.0.1
看到其他設定檔中有加入Apache Web Server 的虛擬主機配置功能
這部分我是還沒加入
附上說明連結
Apache - VirtualHost 架設虛擬網站
引用
在 Mac OS X 中啟動 Apache Web Server 與 PHP 環境
Get Apache, MySQL, PHP and phpMyAdmin working on OSX 10.10 Yosemite
Installing MariaDB 10.0.10 on Mac OS X with Homebrew
在 Mac OS X 系统下配置 Apache MySQL PHP phpMyAdmin 环境
系統已經內建 Apache 和 PHP
Apache
$sudo apachectl start
PHP
編輯Apache設定檔
$sudo vim /etc/apache2/httpd.conf
下面是放置網頁的路徑,可以修改至/Users/使用者名稱/網頁資料夾
DocumentRoot "/Library/WebServer/Documents" <Directory "/Library/WebServer/WebSites">
把#拿掉
LoadModule php5_module libexec/apache2/libphp5.so
產生php設定檔
$sudo cp /etc/php.ini.default /etc/php.ini
MariaDB
首先要已經安裝好homebrew
$brew doctor
$brew update
$brew info
mariadb: stable 10.0.15 (bottled)
http://mariadb.org/
Conflicts with: mysql, mysql-cluster, mysql-connector-c, percona-server
Not installed
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/mariadb.rb
==> Dependencies
Build: cmake ✘
Required: openssl ✔
==> Options
--enable-local-infile
Build with local infile loading support
--universal
Build a universal binary
--with-archive-storage-engine
Compile with the ARCHIVE storage engine enabled
--with-bench
Keep benchmark app when installing
--with-blackhole-storage-engine
Compile with the BLACKHOLE storage engine enabled
--with-embedded
Build the embedded server
--with-libedit
Compile with editline wrapper instead of readline
--with-tests
Keep test when installing
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
mysql -uroot
To have launchd start mariadb at login:
ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents
Then to load mariadb now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
開始安裝與設定
$brew install mariadb $unset TMPDIR $cd /usr/local/Cellar/mariadb/10.0.15/ $mysql_install_db $mysql.server start $mysql_secure_installation ... Enter current password for root (enter for none):按下enter ... Set root password? [Y/n]Y New password:輸入密碼 Re-enter new password:再輸入一次密碼 ... Remove anonymous users? [Y/n]Y ... Disallow root login remotely? [Y/n]Y ... Remove test database and access to it? [Y/n]Y ... Reload privilege tables now? [Y/n]Y ...
登入MariaDB
$mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 1663 Server version: 10.0.15-MariaDB Homebrew Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
查詢版本
MariaDB [(none)]>@@version +-----------------+ | @@version | +-----------------+ | 10.0.15-MariaDB | +-----------------+ 1 row in set (0.00 sec)
離開MariaDB
MariaDB [(none)]>\q Bye
phpMyAdmin
從網路下載phpMyAdmin後放置在/Users/使用者名稱/網頁資料夾(同上面設定的路徑),並且新增資料夾命名成phpmyadmin
mkdir ~/網頁資料夾/phpmyadmin/config chmod o+w ~/網頁資料夾/phpmyadmin/config
開啟網頁後輸入網址localhost/phpmyadmin/setup
接著按下“建立伺服器”

至認證頁面,設定如下圖,完成後按下“套用”自動跳回上一頁再按下“儲存”

完成後把config資料夾裡的config.ini.php複製到上一層
cp ~/網頁資料夾/phpmyadmin/config/config.ini.php ~/網頁資料夾/phpmyadmin開啟網頁進入localhost/phpMyAdmin輸入帳密,登入後出現"無法登入 MySQL 伺服器"(英文是"Cannot log in to the MySQL server")
在config.inc.php裡將底下這行的localhost修改成127.0.0.1
$cfg['Servers'][$i]['host'] = '127.0.0.1';
看到其他設定檔中有加入Apache Web Server 的虛擬主機配置功能
這部分我是還沒加入
附上說明連結
Apache - VirtualHost 架設虛擬網站
引用
在 Mac OS X 中啟動 Apache Web Server 與 PHP 環境
Get Apache, MySQL, PHP and phpMyAdmin working on OSX 10.10 Yosemite
Installing MariaDB 10.0.10 on Mac OS X with Homebrew
在 Mac OS X 系统下配置 Apache MySQL PHP phpMyAdmin 环境
留言
張貼留言