Centos7上搭建属于自己的Wordpress博客

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平台

  1. 配置Vmware网络
  1. 配置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 
  1. 使用远程连接工具连接服务器
    打开HyperTerminal一文件一新建连接一连接类型一SSH
  1. 安装常用工具
[root@localhost ~]# yum install -y vim net-tools wget   
  1. 安装apache(Httpd)
[root@localhost ~]# yum install -y httpd
  1. 安装mariadb-server
[root@localhost ~]# yum install -y mariadb-server
  1. 安装php php-mysql
[root@localhost ~]# yum install -y php php-mysql
  1. 新建php测试页
[root@localhost ~]# echo '<?php phpinfo(); ?>' >  /var/www/html/index.php
  1. 开启httpd服务
[root@localhost ~]# systemctl start httpd                                                                 
[root@localhost ~]# netstat -anput | grep 80                                                              
tcp6       0      0 :::80                   :::*                    LISTEN      16863/httpd 
  1. 关闭防火墙
[root@localhost ~]# systemctl stop firewalld 
  1. 访问主页
  1. 打切换到网站根目录,下载wordpress
[root@localhost ~]# cd /var/www/html/                                                                     
[root@localhost html]# wget https://cn.wordpress.org/wordpress-5.0.2-zh_CN.tar.gz   
  1. 解压缩wordpress安装包,修改目录权限
[root@localhost html]# tar -xf wordpress-5.0.2-zh_CN.tar.gz 
[root@localhost html]# chmod 777 -R wordpress
  1. 开启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!
  1. 登录数据库,创建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
  1. 安装wordpress
  1. 配置wordpress连接数据库

17.wordpress解压目录下创建wp-config.php文件

[root@localhost html]# cd wordpress 
[root@localhost wordpress]# vim wp-config.php
  1. 填写管理员后台登录信息
  1. 登录后台

20.编辑发布网站( 内容转载自「ONE · 一个」)

21.访问网站

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容