mac wordpress php7,Mac 下基于 wordpress 搭建个人博客系统
一、前言
這里說(shuō)的是自己從 wordpress 源碼開(kāi)始搭建一個(gè)個(gè)人博客系統(tǒng)。當(dāng)然,很多云端已經(jīng)直接提供了在線安裝的方式,這個(gè)就不在本文的討論范圍之內(nèi)了。
二、關(guān)于 wordpress
wordpress是一款個(gè)人博客系統(tǒng),并逐步演化成一款內(nèi)容管理系統(tǒng)軟件,它是使用PHP語(yǔ)言和MySQL數(shù)據(jù)庫(kù)開(kāi)發(fā)的,用戶可以在支持 PHP 和 MySQL數(shù)據(jù)庫(kù)的服務(wù)器上使用自己的博客。
總之是為眾多的開(kāi)源博客系統(tǒng)之一,也絕對(duì)是一部良心之作。在這里向作者以及貢獻(xiàn)者致敬。本文主要講述的是從 wordpress 源碼進(jìn)行安裝,當(dāng)然是要從 wordpress 官網(wǎng)這里去將其下載下來(lái)的。下載下來(lái)的是一個(gè)壓約縮包,需要我們自己將其解壓出來(lái)。
三、安裝 wordpress
1.確認(rèn)基礎(chǔ)設(shè)施
wordpress 雖然只是一個(gè)個(gè)人博客系統(tǒng),但其也是一個(gè)服務(wù)端系統(tǒng)。要安裝 wordpress 就需要先安裝相應(yīng)的基礎(chǔ)設(shè)施,php,mysql 以及 apache。不過(guò)這些在 Mac 上已經(jīng)安裝好了。我們要做的是執(zhí)行相應(yīng)的命令行查看一下版本是否符合。
查看Apache版本
$ apachectl -version
Server version: Apache/2.4.34 (Unix)
Server built: Feb 22 2019 19:30:04
相看php版本
$ php -v
PHP 7.1.23 (cli) (built: Feb 22 2019 22:08:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
2.配置并啟動(dòng)相應(yīng)服務(wù)
2.1 開(kāi)啟 Apache 服務(wù)
啟動(dòng) Apache
$ sudo apachectl start
關(guān)閉 Apache
$ sudo apachectl stop
重啟 Apache
$ sudo apachectl restart
2.2 起用 php
起用 php
開(kāi)啟PHP,需要修改Apache配置文件,終端下(當(dāng)然,你也可以直接在 Finder 中找到路徑并用文本編輯器進(jìn)行):
sudo vim /etc/apache2/httpd.conf
去掉如下配置的注釋即為起動(dòng) php。
LoadModule php7_module libexec/apache2/libphp7.so
結(jié)果如下圖
2.3 修改 Apache 的目錄
默認(rèn)情況下 Apache 的目錄為 /Library/WebServer/Documents,我們當(dāng)然希望 wordpress 應(yīng)該工作在自己的獨(dú)立目錄下。假設(shè)我們已經(jīng)把面下載并解壓好的 wordpress 目錄拷貝到 /Library/WebServer/Documents。那我們只要在 /etc/apache2/httpd.conf 再修改 DocumentRoot 的配置。
DocumentRoot "/Library/WebServer/Documents/wordpress"
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options FollowSymLinks Multiviews
MultiviewsMatch Any
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Require all granted
如上,我們?cè)?/Library/WebServer/Documents 后面添加自己的目錄 wordpress。然后再重啟一下 Apache 服務(wù)。
apachectl restart
重啟服務(wù)后,在瀏覽器的地址欄輸入:
localhost
即可出現(xiàn)如下頁(yè)面,就代表已經(jīng)配置成功了。
注意,此響應(yīng)的其實(shí)是
http://localhost/index.php
并且它會(huì)自動(dòng)跳轉(zhuǎn)到/wp-admin/setup-config.php。
http://localhost/wp-admin/setup-config.php
2.4 開(kāi)啟 Mysql
上面圖中,告訴了我們要安裝 wordpress ,所需要的 Mysql 服務(wù)及相關(guān)的配置
Database name
Database username
Database password
Database host
Table prefix (if you want to run more than one WordPress in a single database)
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
查看一下Mysql
$ mysql --version
mysql Ver 14.14 Distrib 5.7.20, for osx10.13 (x86_64) using EditLine wrapper
但這個(gè)并不是 Mysql 的服務(wù)端,這是客戶端。我們應(yīng)該這樣來(lái)看是否已經(jīng)安裝了服務(wù)端。
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.27 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
如果你不能進(jìn)入到 Mysql 的控制臺(tái),說(shuō)明你還沒(méi)有安裝好Mysql,那如果沒(méi)有安裝好的話就請(qǐng)去Mysql的官網(wǎng)下載吧。下載免費(fèi)的社區(qū)版即可滿足需求。如果已經(jīng)安裝就通過(guò)“系統(tǒng)偏好設(shè)置”來(lái)啟動(dòng)Mysql服務(wù)。當(dāng)然要啟動(dòng)了該服務(wù),才能進(jìn)入到上面所說(shuō)的Mysql控制臺(tái)。
新建并配置數(shù)據(jù)庫(kù)
新建數(shù)據(jù)庫(kù)這個(gè)就不在這里講述了,假設(shè)我們創(chuàng)建了一個(gè)數(shù)據(jù)庫(kù)為 wordpress,空的就行。然后用 subline 等純文本編輯工具打開(kāi)之前存放在/Library/WebServer/Documents下面的 wordpress/wp-config-sample.php。并修改如下內(nèi)容。
Database name
Database username
Database password
Database host
樣例如下:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'wordpress' );
/** MySQL database password */
define( 'DB_PASSWORD', 'wordpress123456' );
/** MySQL hostname */
define( 'DB_HOST', '127.0.0.1:/var/run/mysqld/mysqld.sock' );
注意上面的 DB_HOST 最好和作者改成一樣的,不要直接用 localhost ,不然可能會(huì)連接不上。
然后將修改后的文件另存為 wp-config.php。這就完成了數(shù)據(jù)庫(kù)的配置。
2.5 安裝WordPress
前面啰嗦了一大堆,終于把要準(zhǔn)備的環(huán)境準(zhǔn)備好了,接下就在瀏覽器的地址欄輸入http://localhost/wp-admin/install.php ,然后按照向?qū)瓿砂惭b即可大功告成了。
四、總結(jié)
WordPress 是一款非常優(yōu)秀的個(gè)人博客系統(tǒng),并且還是開(kāi)源的,可謂是非常良心了。而其實(shí)其安裝也是非常簡(jiǎn)單的,總結(jié)下來(lái)就是:
1.安裝好 php。
2.安裝好 Mysql,當(dāng)然,主要是指服務(wù)端。建立一個(gè)空的數(shù)據(jù)庫(kù),如 wordpress。
3.安裝一個(gè) HTTP 服務(wù)器,如 Apache。
文章非常簡(jiǎn)單,希望能給有需要的同學(xué)一些幫助,謝謝。
總結(jié)
以上是生活随笔為你收集整理的mac wordpress php7,Mac 下基于 wordpress 搭建个人博客系统的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
 
                            
                        - 上一篇: linkerd mysql_Linker
- 下一篇: java创建线程哪种方法最好_Java创
