CentOS7環(huán)境搭建WordPress項目(使用XAMPP集成環(huán)境)

wordpress.jpeg

簡介

WordPress是使用PHP語言開發(fā)的博客平臺,用戶可以在支持PHP和MySQL數(shù)據(jù)庫的服務(wù)器上架設(shè)屬于自己的網(wǎng)站。也可以把 WordPress當(dāng)作一個內(nèi)容管理系統(tǒng)(CMS)來使用。

搭建WordPress 要分搭建php apache mysql 環(huán)境、配置數(shù)據(jù)庫、安裝WordPress。

Step1 搭建php apache mysql 環(huán)境

搭建php apache mysql 環(huán)境,分開來搭建這些環(huán)境比較復(fù)雜,網(wǎng)絡(luò)上有現(xiàn)成的工具包類似一鍵安裝就能把環(huán)境搭建好,這個工具就是XAMPP 。這一部分步驟如下:

  1. 下載XAMPP ,下載地址:https://www.apachefriends.org/download.html 有windows、linux、macOS平臺的可以下載。選擇適合自己的系統(tǒng)。我這里下載的是linux版本。

    download-wordpress.png

  2. 執(zhí)行下載文件:xampp-linux-x64-7.2.8-0-installer.run ,把下載文件上傳到centos服務(wù)器/opt目錄下。

  3. 執(zhí)行命令:

./xampp-linux-x64-7.2.8-0-installer.run

  1. 注意:如果安裝文件沒有可執(zhí)行權(quán)限,執(zhí)行命令賦給可執(zhí)行權(quán)限

chmod +x xampp-linux-x64-7.2.8-0-installer.run 。

在執(zhí)行過程中會遇到確認(rèn)提示,選擇y或者n,這里都選擇y。選擇完成后默認(rèn)安裝路徑在:/opt/lampp 目錄下

具體操作如下:

[root@sufeng opt]# pwd
/opt
[root@sufeng opt]# ls
xampp-linux-x64-7.2.8-0-installer.run
[root@sufeng opt]# ./xampp-linux-x64-7.2.8-0-installer.run 
----------------------------------------------------------------------------
Welcome to the XAMPP Setup Wizard.

----------------------------------------------------------------------------
Select the components you want to install; clear the components you do not want 
to install. Click Next when you are ready to continue.

XAMPP Core Files : Y (Cannot be edited)

XAMPP Developer Files [Y/n] :y

Is the selection above correct? [Y/n]: y

----------------------------------------------------------------------------
Installation Directory

XAMPP will be installed to /opt/lampp
Press [Enter] to continue:

----------------------------------------------------------------------------
Setup is now ready to begin installing XAMPP on your computer.

Do you want to continue? [Y/n]: y

----------------------------------------------------------------------------
Please wait while Setup installs XAMPP on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing XAMPP on your computer.
  1. 安裝xampp完成后,可以通過命令來啟動xampp環(huán)境
/opt/lampp/lampp start      //啟動
/opt/lampp/lampp stop     //停止
/opt/lampp/lampp restart  //重啟

啟動后,可以通過ps -aef |grep lampp 來查看lampp環(huán)境是否正常啟動。如下提示中,可以看出Apache 和MySQL都啟動正常

[root@sufeng opt]# /opt/lampp/lampp stop
Stopping XAMPP for Linux 7.2.8-0...
XAMPP: Stopping Apache...ok.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...not running.
[root@sufeng opt]# /opt/lampp/lampp start
Starting XAMPP for Linux 7.2.8-0...
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...fail.
Contents of "/opt/lampp/var/proftpd/start.err":
 proftpd[8021]: warning: unable to determine IP address of 'sufeng'
sufeng proftpd[8021]: error: no valid servers configured
sufeng proftpd[8021]: Fatal: error processing configuration file '/opt/lampp/etc/proftpd.conf'
[root@sufeng opt]# /opt/lampp/lampp restart
Restarting XAMPP for Linux 7.2.8-0...
XAMPP: Stopping Apache...ok.
XAMPP: Stopping MySQL...ok.
XAMPP: Stopping ProFTPD...not running.
XAMPP: Starting Apache...ok.
XAMPP: Starting MySQL...ok.
XAMPP: Starting ProFTPD...fail.
Contents of "/opt/lampp/var/proftpd/start.err":
sufeng proftpd[8289]: warning: unable to determine IP address of 'sufeng'
sufeng proftpd[8289]: error: no valid servers configured
bogon proftpd[8289]: Fatal: error processing configuration file '/opt/lampp/etc/proftpd.conf'
[root@sufeng opt]# ps -aef | grep lampp
root       8272      1  0 06:27 ?        00:00:00 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
daemon     8280   8272  0 06:27 ?        00:00:00 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
daemon     8290   8272  0 06:27 ?        00:00:00 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
daemon     8292   8272  0 06:27 ?        00:00:00 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
daemon     8294   8272  0 06:27 ?        00:00:00 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
daemon     8296   8272  0 06:27 ?        00:00:00 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
daemon     8297   8272  0 06:27 ?        00:00:00 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
root       8299      1  0 06:27 pts/0    00:00:00 /bin/sh /opt/lampp/bin/mysqld_safe --datadir=/opt/lampp/var/mysql --pid-file=/opt/lampp/var/mysql/sufeng.pid
mysql      8448   8299  5 06:27 pts/0    00:00:00 /opt/lampp/sbin/mysqld --basedir=/opt/lampp --datadir=/opt/lampp/var/mysql --plugin-dir=/opt/lampp/lib/mysql/
  1. 關(guān)閉Centos7 防火墻命令:systemctl stop firewalld.service,關(guān)閉防火墻后,可以從外部訪問到這臺服務(wù)器

Step2 配置數(shù)據(jù)庫

配置數(shù)據(jù)庫,數(shù)據(jù)庫服務(wù)在第一部分一鍵安裝好了,還需要配置下訪問權(quán)限

  1. 登錄mysql服務(wù),執(zhí)行命令:/opt/lampp/bin/mysql -uroot

  2. 登錄后執(zhí)行SQL

use mysql;
select t.host from user t where t.user='root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;

具體如下:

[root@sufeng opt]# /opt/lampp/bin/mysql -uroot 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.34-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> select t.host from user t where t.user='root';
+-----------+
| host      |
+-----------+
| 127.0.0.1 |
| ::1       |
| localhost |
+-----------+
3 rows in set (0.00 sec)

MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)

MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> 
  1. 登錄mysql 服務(wù)創(chuàng)建wordpress 數(shù)據(jù)庫,執(zhí)行命令: /opt/lampp/bin/mysql -uroot -p
    彈出輸入password ,輸入123456。
    登入后執(zhí)行SQL:
CREATE DATABASE IF NOT EXISTS wordpress DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

具體操作如下:

[root@sufeng opt]# /opt/lampp/bin/mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.34-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE IF NOT EXISTS wordpress DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| phpmyadmin         |
| test               |
| wordpress          |
+--------------------+
6 rows in set (0.00 sec)

MariaDB [(none)]> 

Step 3 安裝Wordpress

  1. 下載Wordpress:https://wordpress.org/download/ 點擊Download .tar.gz 下載wordpress 壓縮包

  2. 解壓wordepress 到目錄/opt/lampp/htdocs/下:

tar -xzvf wordpress-5.2.1.tar.gz -C /opt/lampp/htdocs/

  1. 瀏覽器中輸入http://192.168.1.108/wordpress/index.php ip 為centos7 的ip,由于是首次打開,自動跳轉(zhuǎn)到安裝頁面http://192.168.1.108/wordpress/wp-admin/setup-config.php

在安裝頁面,可以看出頁面提示的必要數(shù)據(jù)庫信息,這些信息在第二部分已經(jīng)完成了

step1.jpg
  1. 點擊 【Let‘s go’】 進(jìn)入填寫數(shù)據(jù)庫信息頁面,點擊【submit】
step2.jpg
  1. 如果點擊【Submit 】 按鈕后出現(xiàn)如下提示:
    說明在寫wp-config.php 文件的時候沒有權(quán)限,提示中也給了解決方法,就是手動在wordpress 目錄下新建wp-config.php 文件,并且把提示中的代碼復(fù)制保存到wp-config.php 文件中再點擊【run the installation】就能繼續(xù)安裝


    step3.jpg
  2. 輸入站點信息,管理員賬號密碼后 點擊【Install WordPress】


    step4.jpg

    step5.jpg
  3. 安裝完成后,進(jìn)入登錄頁:http://192.168.1.108/wordpress/wp-login.php,并登錄成功,說明安裝成功
    step6.jpg
step7.jpg
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容