在Centos7上搭建Wordpress博客平台

2018-12-22  本文已影响27人  shuhanghang

Wordpress博客与论坛、电影点播平台一样都依赖LAMP(linux+apache+mariadb+php)或LNMP(linux+nginx+mariadb+php)环境。
本次使用Red Hat的社区企业版Centos,在本地Vmware虚拟机上使用系统自带的自动安装工具搭建环境。
也可以在云平台上搭建,快速的创建系统实例,而且云平自带有监控、防火墙等实用的管理工具,主要还可以分配公网IP,再绑定上域名跑起来那叫一个舒服!

一.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.访问网站

上一篇 下一篇

猜你喜欢

热点阅读