在 RHEL7 安裝 WordPress

 

WordPress 是目前相當多人使用的 blog

https://w3techs.com/technologies/overview/content_management/all

image

先從 RPM 套件安裝開始

 

[root@server28 ~]# yum install httpd php mariadb-server php-gd php-mysql
Loaded plugins: langpacks
…【略】
Resolving Dependencies

啟動 mariadb 服務

[root@server28 ~]# systemctl start mariadb
[root@server28 ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
[root@server28 ~]# systemctl status mariadb
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled)
   Active: active (running) since Wed 2018-08-01 11:19:44 CST; 9s ago
 Main PID: 9881 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─ 9881 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─10039 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/...

Aug 01 11:19:42 server28.example.com mariadb-prepare-db-dir[9802]: The latest information abo...
Aug 01 11:19:42 server28.example.com mariadb-prepare-db-dir[9802]: You can find additional in...
Aug 01 11:19:42 server28.example.com mariadb-prepare-db-dir[9802]: http://dev.mysql.com
Aug 01 11:19:42 server28.example.com mariadb-prepare-db-dir[9802]: Support MariaDB developmen...
Aug 01 11:19:42 server28.example.com mariadb-prepare-db-dir[9802]: SkySQL Ab. You can contact...
Aug 01 11:19:42 server28.example.com mariadb-prepare-db-dir[9802]: Alternatively consider joi...
Aug 01 11:19:42 server28.example.com mariadb-prepare-db-dir[9802]: http://mariadb.com/kb/en/c...
Aug 01 11:19:42 server28.example.com mysqld_safe[9881]: 180801 11:19:42 mysqld_safe Logging ....
Aug 01 11:19:42 server28.example.com mysqld_safe[9881]: 180801 11:19:42 mysqld_safe Starting...l
Aug 01 11:19:44 server28.example.com systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.

 

如果在意安全問題,應該要執行 mysql_secure_installation 初始化 root 密碼…等

[root@server28 ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):

建立 WordPress 使用的 database

[root@server28 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.35-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> CREATE DATABASE wordpressdb;
Query OK, 1 row affected (0.01 sec)

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

MariaDB [(none)]>

建立連線專用的帳號跟密碼【都是單引號,不然會出現語法錯誤的訊息】

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpressdb.* TO ‘wpuser’@’localhost’ IDENTIFIED BY ‘wppasswd’;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '‘wppasswd’' at line 1
MariaDB [(none)]>
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'wppasswd';
Query OK, 0 rows affected (0.00 sec)

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

MariaDB [(none)]> exit
Bye


 

下載 wordpress

[root@server28 ~]# cd /tmp
[root@server28 /tmp]#
[root@server28 /tmp]# wget http://wordpress.org/latest.tar.gz
--2018-08-01 11:25:39--  http://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://wordpress.org/latest.tar.gz [following]
--2018-08-01 11:25:39--  https://wordpress.org/latest.tar.gz
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8742203 (8.3M) [application/octet-stream]
Saving to: ‘latest.tar.gz’

100%[======================================================>] 8,742,203   3.19MB/s   in 2.6s

2018-08-01 11:25:42 (3.19 MB/s) - ‘latest.tar.gz’ saved [8742203/8742203]

 

解開 tar ball file 到 DocumentRoot

[root@server28 /tmp]# ls -l /tmp/latest.tar.gz
-rw-r--r--. 1 root root 8742203 Jul  6 00:08 /tmp/latest.tar.gz
[root@server28 /tmp]# tar zxvf /tmp/latest.tar.gz -C /var/www/html
wordpress/
wordpress/xmlrpc.php
wordpress/wp-blog-header.php
wordpress/readme.html
wordpress/wp-signup.php
wordpress/index.php
...【以下省略】

啟動 Apache Web Server

[root@server28 ~]# systemctl start httpd
[root@server28 ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[root@server28 ~]# systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since Wed 2018-08-01 11:29:20 CST; 8s ago
 Main PID: 10292 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─10292 /usr/sbin/httpd -DFOREGROUND
           ├─10294 /usr/sbin/httpd -DFOREGROUND
           ├─10298 /usr/sbin/httpd -DFOREGROUND
           ├─10299 /usr/sbin/httpd -DFOREGROUND
           ├─10300 /usr/sbin/httpd -DFOREGROUND
           └─10301 /usr/sbin/httpd -DFOREGROUND

Aug 01 11:29:19 server28.example.com systemd[1]: Starting The Apache HTTP Server...
Aug 01 11:29:20 server28.example.com systemd[1]: Started The Apache HTTP Server.

開放 Firewall

[root@server28 ~]# firewall-cmd --permanent --add-service=http
success
[root@server28 ~]# firewall-cmd --reload
success
[root@server28 ~]# firewall-cmd --list-all
public (default, active)
  interfaces: eth0
  sources:
  services: dhcpv6-client http ssh
  ports:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

變更擁有者及隸屬群組

[root@server28 /var/www/html]# ls -l
total 4
drwxr-xr-x. 5 nobody nfsnobody 4096 Aug  1 11:32 wordpress
[root@server28 /var/www/html]# chown -R apache.apache wordpress
[root@server28 /var/www/html]#
[root@server28 /var/www/html]# ls -l
total 4
drwxr-xr-x. 5 apache apache 4096 Aug  1 11:32 wordpress

準備要編輯設定檔

[root@server28 ~]# cd /var/www/html/wordpress/
[root@server28 /var/www/html/wordpress]#
[root@server28 /var/www/html/wordpress]# ls -l wp-config-sample.php
-rw-r--r--. 1 nobody nfsnobody 2853 Dec 16  2015 wp-config-sample.php
[root@server28 /var/www/html/wordpress]# mv wp-config-sample.php wp-config.php
[root@server28 /var/www/html/wordpress]#
[root@server28 /var/www/html/wordpress]# ls -l wp-config.php
-rw-r--r--. 1 nobody nfsnobody 2853 Dec 16  2015 wp-config.php

編輯設定檔

[root@server28 /var/www/html/wordpress]# vi wp-config.php

主要是指定 database 名稱,以及連線登入到 mariadb 的 ID/password,大約在 23-29 行之間

  23 define('DB_NAME', 'wordpressdb');
     24
     25 /** MySQL database username */
     26 define('DB_USER', 'wpuser');
     27
     28 /** MySQL database password */
     29 define('DB_PASSWORD', 'wppasswd');

接下來就要用 Browser 設定了

image

image

image

安裝完成

image

image

參考網址:

WordPress installation on Centos/RHEL 7

How to Install WordPress Using Apache on CentOS/RHEL 7/6/5

How To Install WordPress on CentOS 7

WordPress教學:32個課程(安裝+主題外掛+購物車)

 

How To Install WordPress on CentOS 7

本篇發表於 Uncategorized。將永久鏈結加入書籤。

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com 標誌

您的留言將使用 WordPress.com 帳號。 登出 /  變更 )

Google photo

您的留言將使用 Google 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 /  變更 )

連結到 %s