PHP 5.2.4或更新版本php
MySQL 5.0或更新版本html
WebServer(能夠選擇Apache、nginx等支持PHP的,這裏我選擇Apache)mysql
Mac OSX 自帶PHP,無需安裝。 nginx
不建議經過brew、源碼安裝等方式升級PHP7。若須要可在虛擬機中測試。web
訪問MySQL的官網 http://www.mysql.com/downloads/ 在頁面中會看到「MySQL Community Server」下方有一個「download」按鈕,點擊該按鈕。 sql
進入MySQL的下載界面 http://www.mysql.com/downloads/mysql/,下面羅列的都是在Mac OS上能用的MySQL的版本,選擇須要的版本點擊下載。 數據庫
而後會跳轉到另一個界面,這個界面是提示你需不須要註冊的,直接選擇最下面的「No thanks,just take me to downloads!」,而後這才真正跳轉到了下載的界面,這個界面列了不少的供下載的服務器,選擇一個服務器進行下載就OK了。apache
雙擊下載下來的文件,通常裏面會有幾個文件,5.6以上的包裏面沒有MySQL.prefPane文件,可是會默認安裝;5.6如下則須要本身手動安裝。
安裝完成後,會在系統的(偏好設置)裏面出現MySQL的管理按鈕,經過這個按鈕能夠啓動和中止MySQL。 api
⚠️注意:MySQL安裝完成時,會以彈窗的形式顯示初始密碼,請保存好該密碼!!!瀏覽器
打開命令行
編輯.bash_profile,並添加以下內容
vi .bash_profile tcsh下添加以下內容: alias mysql /usr/local/mysql/bin/mysql alias mysqladmin /usr/local/mysql/bin/mysqladmin bash下添加以下內容: alias mysql=/usr/local/mysql/bin/mysql alias mysqladmin=/usr/local/mysql/bin/mysqladmin
保存並退出,並啓用配置
source .bash_profile
初次使用MySQL時須要修改密碼,表現爲如下錯誤
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
具體能夠參照官網的例子解決
http://dev.mysql.com/doc/refman/5.7/en/alter-user.html
http://dev.mysql.com/doc/refman/5.6/en/alter-user.html
如下爲個人解決方案
mysql> SELECT 1; ERROR 1820 (HY000): You must SET PASSWORD before executing this statement mysql> SET PASSWORD = PASSWORD('new_password'); Query OK, 0 rows affected (0.01 sec) mysql> quit;
如今就可使用新密碼從新登陸數據庫
mysql>create database database-name;
Mac OSX 自帶Apache,無需安裝。
根目錄配置文件爲/etc/apache2/httpd.conf
sudo vi /etc/apache2/httpd.conf 搜索DocumentRoot(操做按ESC + shift + :+ /DocumentRoot) 修改成以下內容便可 # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. DocumentRoot "/usr/local/www/" <Directory "/usr/local/www/"> 爲何把Apache的網站根目錄放在/usr/local/www/這裏? 答:不須要修改權限,不須要折騰。 把這行的註釋去掉 #LoadModule php5_module libexec/apache2/libphp5.so
多站點配置文件爲/etc/apache2/extra/httpd-vhosts.conf
#<VirtualHost *:80> # ServerAdmin webmaster@dummy-host2.example.com # DocumentRoot "/usr/docs/dummy-host2.example.com" # ServerName dummy-host2.example.com # ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" # CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common #</VirtualHost> 裏面有2個例子,複製一個修改以下 <VirtualHost *:80> DocumentRoot "/usr/local/www/WordPress/WordPress01" ServerName WordPress01 ErrorLog "/private/var/log/apache2/WordPress01-error_log" CustomLog "/private/var/log/apache2/WordPress01-access_log" common </VirtualHost> <VirtualHost *:80> DocumentRoot "/usr/local/www/WordPress/WordPress02" ServerName WordPress02 ErrorLog "/private/var/log/apache2/WordPress02-error_log" CustomLog "/private/var/log/apache2/WordPress02-access_log" common </VirtualHost> 如今apache多站點配置好了。
修改/etc/hosts文件
sudo vi /etc/hosts 修改以下內容, ## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost 127.0.0.1 WordPress01 127.0.0.1 WordPress02 127.0.0.1 phpMyAdmin ::1 localhost 啓動Apache: sudo apachectl start 如今能夠經過在瀏覽器中輸入:localhost/WordPress01 訪問 WordPress01 的內容了 重啓Apache: sudo apachectl restart 中止Apache: sudo apachectl stop
到WordPress的官網
https://cn.wordpress.org/
上下載安裝包,解壓並重命名爲WordPress01,放到/usr/local/www/WordPress目錄下面。
修改WordPress01裏面的wp-config-example.conf的內容以下並重命名爲wp-config.conf
<?php /** * WordPress基礎配置文件。 * * 這個文件被安裝程序用於自動生成wp-config.php配置文件, * 您能夠不使用網站,您須要手動複製這個文件, * 並重命名爲「wp-config.php」,而後填入相關信息。 * * 本文件包含如下配置選項: * * * MySQL設置 * * 密鑰 * * 數據庫表名前綴 * * ABSPATH * * @link https://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php * * @package WordPress */ // ** MySQL 設置 - 具體信息來自您正在使用的主機 ** // /** WordPress數據庫的名稱 */ define('DB_NAME', 'WordPress'); /** MySQL數據庫用戶名 */ define('DB_USER', 'root'); /** MySQL數據庫密碼 */ define('DB_PASSWORD', '123456'); /** MySQL主機 */ define('DB_HOST', 'localhost'); /** 建立數據表時默認的文字編碼 */ define('DB_CHARSET', 'utf8'); /** 數據庫整理類型。如不肯定請勿更改 */ define('DB_COLLATE', ''); /**#@+ * 身份認證密鑰與鹽。 * * 修改成任意獨一無二的字串! * 或者直接訪問{@link https://api.wordpress.org/secret-key/1.1/salt/ * WordPress.org密鑰生成服務} * 任何修改都會致使全部cookies失效,全部用戶將必須從新登陸。 * * @since 2.6.0 */ define('AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', 'put your unique phrase here'); define('NONCE_KEY', 'put your unique phrase here'); define('AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', 'put your unique phrase here'); define('NONCE_SALT', 'put your unique phrase here'); /**#@-*/ /** * WordPress數據表前綴。 * * 若是您有在同一數據庫內安裝多個WordPress的需求,請爲每一個WordPress設置 * 不一樣的數據表前綴。前綴名只能爲數字、字母加下劃線。 */ $table_prefix = 'wp_'; /** * 開發者專用:WordPress調試模式。 * * 將這個值改成true,WordPress將顯示全部用於開發的提示。 * 強烈建議插件開發者在開發環境中啓用WP_DEBUG。 * * 要獲取其餘能用於調試的信息,請訪問Codex。 * * @link https://codex.wordpress.org/Debugging_in_WordPress */ define('WP_DEBUG', true); /** * zh_CN本地化設置:啓用ICP備案號顯示 * * 可在設置→常規中修改。 * 如需禁用,請移除或註釋掉本行。 */ define('WP_ZH_CN_ICP_NUM', true); /* 好了!請不要再繼續編輯。請保存本文件。使用愉快! */ /** WordPress目錄的絕對路徑。 */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); /** 設置WordPress變量和包含文件。 */ require_once(ABSPATH . 'wp-settings.php'); 如今能夠經過在瀏覽器中輸入:localhost/WordPress01 安裝WordPress了。 ⚠️注意:這裏頗有可能會在瀏覽器中看到「連接數據庫發生錯誤」,須要確認如下內容: * 數據庫用戶名和密碼正確。 * 數據庫已經啓動並能訪問。 若是以上無誤,請修改wp-config.conf文件中的 /** MySQL主機 */ define('DB_HOST', 'localhost'); 改成: /** MySQL主機 */ define('DB_HOST', '127.0.0.1'); 或者是 MySQL主機的IP 接下來正常安裝便可。