WHCSRL 技术网

2021-10-18

WordPress 应用系统

使 用 提 供 的 软 件 包 和 vmware 提 供 的 centos7.2 操 作 系 统 , 完 成 LNMP+WordPress
部署。部署完成后,进行登录,最后提交 WordPress 首页和后 台管理界面。(设置 WordPress
名称为自己的姓名+BLOG,例如张三,则 WordPress 首页显示张三 BLOG,答案的截图需体现这点) 配置YUM源

修改主机名

[root@localhost ~]# hostnamectl set-hostname server1

关闭防火墙

[root@server1 ~]# setenforce 0
[root@server1 ~]# systemctl stop firewalld

配置yum源

[root@server1 ~]# mkdir /opt/centos
[root@server1 ~]# moun /root/CentOS-7-x86_64-DVD-1511.iso /opt/centos/
[root@server1 ~]# mv lnmp/ /opt/
[root@server1 ~]# mount -a

mount: /dev/loop0 is write-protected, mounting read-only 
  • 1

[root@server1 ~]# rm -rf /etc/yum.repos.d/*

编写local.repo

[root@server1 ~]# cat /etc/yum.repos.d/local.repo

[centos]
name=centos
enabled=1
gpgcheck=0
baseurl=file:///opt/centos

[lnmp]
name=lnmp
enabled=1
gpgcheck=0
baseurl=file:///opt/lnmp
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

[root@server1 ~]# yum clean all && yum makecache

Loaded plugins: fastestmirror
Cleaning repos: centos lnmp
Cleaning up everything
Loaded plugins: fastestmirror
centos                                                                                                | 3.6 kB  00:00:00     
lnmp                                                                                                  | 2.9 kB  00:00:00     
(1/7): centos/group_gz                                                                                | 155 kB  00:00:00     
(2/7): centos/primary_db                                                                              | 2.8 MB  00:00:00     
(3/7): centos/other_db                                                                                | 1.2 MB  00:00:00     
(4/7): centos/filelists_db                                                                            | 2.9 MB  00:00:00     
(5/7): lnmp/primary_db                                                                                | 153 kB  00:00:00     
(6/7): lnmp/other_db                                                                                  |  70 kB  00:00:00     
(7/7): lnmp/filelists_db                                                                              | 189 kB  00:00:00     
Determining fastest mirrors
Metadata Cache Created
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
安装服务

[root@server1 ~]# yum -y install mariadb mariadb-server php-fpm php-mysql nginx

配置mariadb数据库

[root@server1 html]# systemctl start mariadb
[root@server1 html]# mysql_secure_installation
y 密码 确认密码 y n y y

登录mysql

[root@server1 html]# mysql -uroot -p123456
MariaDB [(none)]> grant all privileges on *.* to 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on *.* to 'root'@'%%%%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

退出mysql

MariaDB [(none)]> exit

配置nginx

nginx配置文件只需添加或修标黄内容即可, 有注释的去掉注释

[root@server1 ~]# vi /etc/nginx/conf.d/default.conf
      8     location / {
      9         root   /usr/share/nginx/html;
     10         index  index.php index.html index.htm;
     11     }
     30     location ~ .php$ {
     31         root           /usr/share/nginx/html;
     32         fastcgi_pass   127.0.0.1:9000;
     33         fastcgi_index  index.php;
     34         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     35         include        fastcgi_params;
     36     }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

配置php

这里修改第39、41行的用户和组为nginx

[root@server1 ~]# vi /etc/php-fpm.d/www.conf

 39 user = nginx
 41 group = nginx
  • 1
  • 2

[root@server1 ~]# yum -y install unzip
[root@server1 ~]# unzip wordpress-4.7.3-zh_CN.zip
[root@server1 ~]# rm -rf /usr/share/nginx/html/*

配置wordpress

[root@server1 ~]# cp -rf wordpress/* /usr/share/nginx/html/
[root@server1 ~]# cd /usr/share/nginx/html/
[root@server1 html]# cp wp-config-sample.php wp-config.php
[root@server1 html]# vi wp-config.php
/** 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’, ‘’);
[root@server1 html]# chmod -R 777 ./

[root@server1 html]# systemctl start nginx php-fpm

[root@server1 html]# curl -L http://192.168.200.20

推荐阅读