WordPress是使用PHP语言开发的博客平台,依赖LAMP(linux+apache+mariadb+php)或LNMP(linux+nginx+mariadb+php)环境。
一.部署的方案
1.Windows
Phpstudy集成环境、宝塔面板、本地LNMP分别安装
2.Linux
Phpstudy集成环境、LNMP自动脚本、宝塔面板、Docker容器、本地LNMP软件自动或编译安装
这次演示是用Red Hat的社区企业版Centos,在本地Vmware虚拟机上使用本地包管理工具yum安装LNMP。
二.准备
- 实验前准备:在Vm虚拟机上已经最小化安装好Centos7.6.1810
- 环境:
系统:Win7 64位
虚拟机:VMware® Workstation 14 Pro
系统:CentOS-7-x86_64-Minimal-1810
三.Centos7搭建Wordpress平台
- 配置Vmware网络
- 配置Centos主机IP
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static #设置为静态IP
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=29d45897-bbea-47e9-8f8e-c2e1c9ed58cc
DEVICE=ens33
ONBOOT=yes #设置为开机启动
IPADDR=192.168.1.140 #主机IP
NETMASK=255.255.255.0 #子网掩码
GATEWAY=192.168.1.1 #网关
DNS1=8.8.8.8 #DNS
[root@localhost ~]# systemctl restart network
- 使用远程连接工具连接服务器
打开HyperTerminal一文件一新建连接一连接类型一SSH
- 安装常用工具
[root@localhost ~]# yum install -y vim net-tools wget
- 安装apache(Httpd)
[root@localhost ~]# yum install -y httpd
- 安装mariadb-server
[root@localhost ~]# yum install -y mariadb-server
- 安装php php-mysql
[root@localhost ~]# yum install -y php php-mysql
- 新建php测试页
[root@localhost ~]# echo '<?php phpinfo(); ?>' > /var/www/html/index.php
- 开启httpd服务
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# netstat -anput | grep 80
tcp6 0 0 :::80 :::* LISTEN 16863/httpd
- 关闭防火墙
[root@localhost ~]# systemctl stop firewalld
- 访问主页
- 打切换到网站根目录,下载wordpress
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# wget https://cn.wordpress.org/wordpress-5.0.2-zh_CN.tar.gz
- 解压缩wordpress安装包,修改目录权限
[root@localhost html]# tar -xf wordpress-5.0.2-zh_CN.tar.gz
[root@localhost html]# chmod 777 -R wordpress
- 开启mariadb服务并创建root用户登录密码
[root@localhost html]#systemctl start mariadb
[root@localhost html]# mysql_secure_installation
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):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
- 登录数据库,创建wordpress数据库,并授权给wordadmin
[root@localhost html]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.60-MariaDB MariaDB Server
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 wordpress charset utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on wordpress.* to wordadmin@'localhost' identified by '123456';
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
- 配置wordpress连接数据库
17.wordpress解压目录下创建wp-config.php文件
[root@localhost html]# cd wordpress
[root@localhost wordpress]# vim wp-config.php
- 填写管理员后台登录信息
- 登录后台
20.编辑发布网站( 内容转载自「ONE · 一个」)
21.访问网站
- 至此wordpress博客平台搭建基本完成,wordpress有自带的主题可供选择、可以设置页面样式并且提供了丰富的插件及工具,也可以在wordpress大学及其他开源网站上下载更酷炫的主题来打造属于自己的网站。
- 正式的部署建议使用云主机,云平台自带完善的监控管理工具,外分配的公网IP绑定好域名后就可以在其他地方访问了。
VMware+秘钥下载链接:https://pan.baidu.com/s/1iLsji5Mh5vqe6XUkX7q-_w
提取码:f56w
Centos7下载链接:http://mirrors.ustc.edu.cn/centos/7.6.1810/isos/x86_64/
HyperTerminal下载链接:https://www.hilgraeve.com/hyperterminal/
LNMP一键安装包链接:https://lnmp.org/
PhpStudy:https://www.xp.cn/