LAMP博客平台Wordpress实战

项目实战:LAMP-博客平台-Wordpress

WordPress是一款个人博客系统,并逐步演化成一款内容管理系统软件,使用PHP语言和MySQL数据库开发,用户可以在支持 PHP 和 MySQL 数据库的服务器上使用自己的博客。

前提条件

用 centos7 模板克隆一台 server

节点规划

节点名称 节点IP 节点功能
wordpress 10.1.8.10/24 LAMP

基础配置

bash 复制代码
[root@localhost ~]# hostnamectl set-hostname wordpress
[root@localhost ~]# nmcli connection modify ens33 ipv4.method manual \
ipv4.addresses 10.1.8.10/24 ipv4.gateway 10.1.8.2 ipv4.dns 10.1.8.2 autoconnect \
yes
[root@localhost ~]# nmcli connection up ens33

准备好 LAMP 环境

bash 复制代码
[root@wordpress ~]# wget -O /etc/yum.repos.d/epel.repo \
http://mirrors.aliyun.com/repo/epel-7.repo

[root@wordpress ~]# yum install -y mariadb-server mariadb php php-fpm php-mysqlnd \
php-gd php-mbstring php-xml httpd

[root@wordpress ~]# systemctl enable mariadb --now
[root@wordpress ~]# systemctl enable php-fpm --now
[root@wordpress ~]# systemctl enable httpd --now

准备数据库

初始化

bash 复制代码
[root@wordpress ~]# 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             # 输入 y → 设置 root 密码
New password:                          #你要设置的密码,如huawei
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] n   # 禁止远程登录root? (项目常用选 n; 安全服务器选 y)
 ... skipping.

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   # 删除 test 测试库
- 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!
[root@wordpress ~]#

创建 WordPress 数据库与用户

bash 复制代码
[root@wordpress ~]# mysql -u root -phuawei
sql 复制代码
MariaDB [(none)]> CREATE DATABASE wordpress;
MariaDB [(none)]> CREATE USER wordpress@localhost IDENTIFIED BY 'huawei';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@localhost;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

准备 WordPress

这里使用 wordpress-4.9.4 版本,该版本部署起来简单。

bash 复制代码
# 上传到root用户家目录
[root@wordpress ~]# unzip wordpress-4.9.4-zh_CN.zip
[root@wordpress ~]# cp -aR wordpress /var/www/html/
[root@wordpress ~]# chown -R apache:apache /var/www/html/wordpress/
[root@wordpress ~]# systemctl restart httpd

配置过程

客户端登录 http://www.laogao.cloud/wordpress/

配置数据库

也可以使用以下方式配置后端数据库:

bash 复制代码
# 设置WordPress后端数据库
[root@wordpress ~]# cd /var/www/html/wordpress/
[root@server wordpress]# cp wp-config-sample.php wp-config.php
[root@server wordpress]# vim wp-config.php
php 复制代码
# 更改如下四个参数:

/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');

/** MySQL数据库用户名 */
define('DB_USER', 'wordpress');

/** MySQL数据库密码 */
define('DB_PASSWORD', 'huawei');

/** MySQL主机 */
define('DB_HOST', 'localhost');

/** WordPress数据表前缀 */
$table_prefix  = 'wp_';

如果出现下图信息:

设置目录权限,确保 apache 用户可以创建文件:

bash 复制代码
[root@wordpress ~]# chown -R 755 /var/www/html/wordpress/

配置网站

管理网站

相关推荐
有个傻瓜3 小时前
手机号明明查不到,注册却提示“已存在“:MyBatis-Plus 逻辑删除与唯一索引冲突排错复盘与五种方案实测
mysql·mybatis-plus·故障排查·唯一索引·逻辑删除
FungLeo4 小时前
FengCMS · PHP+MySQL 升级实录 · 留言模块的六项问题:未审核进公开列表、旧回复覆盖、批量删除恢复
android·mysql·php·工程实践·fengcms
stormsha4 小时前
中文路径让 MySQL 起不来:Failed to find valid data directory 与 Illegal byte sequence
运维·数据库·mysql
洞见前行4 小时前
Android 架构演进全解:从 MVC、MVP、MVVM 到 MVI 的原理、代码实战与得失权衡
android·架构·kotlin
stormsha4 小时前
MySQL 报 `data directory has files in it`:初始化失败一次,之后就永久起不来
运维·数据库·mysql
FungLeo6 小时前
FengCMS · PHP+MySQL 升级实录·安全的网页安装器:一次性密钥、HTTPS+CSRF、安装锁、不删表
mysql·安全·php·安装部署·fengcms
专注Android黑科技6 小时前
Android 玩机黑科技:刀盾「系统冰点还原」与「保环境双清(恢复出厂不掉ROOT)」全图解教程
android·技术分享
真上帝的左手8 小时前
4. 关系型数据库-MySQL-原生集成 AI能力
数据库·人工智能·mysql·ai
StarsGreen8 小时前
Android meminfo 服务详细介绍
android
三少爷的鞋9 小时前
Main-safe、非阻塞与结构化并发,才是协程架构的核心
android