当前位置: 首页 > news >正文

CentOS 7 LAMP快速部署WordPress指南

CentOS 7 使用LAMP架构部署WordPress

1. 修改主机名
hostnamectl set-hostname lamp.example.com
bash  # 立即生效
2. 关闭防火墙和SELinux
systemctl stop firewalld
systemctl disable firewalld  # 修正拼写错误(原文档为firewallld)
setenforce 0                 # 临时关闭SELinuxvim /etc/selinux/config
SELINUX=enforcing 改为 SELINUX=disabled  # 永久关闭
3.配置yum仓库
cd /etc/yum.repos.d/
#全部删除
rm -rf *
阿里云CentOS 7镜像复制安装
yum -y install epel-release
4. 时钟同步
yum -y install chrony
systemctl restart chronyd
systemctl enable chronyd
hwclock -w  # 同步硬件时钟

5. 安装Apache与MariaDB
yum -y install httpd mariadb mariadb-server

6. 初始化MariaDB
systemctl start mariadb      # 启动服务(原文档为restart)
systemctl enable mariadb     # 设置开机自启
mysql_secure_installation    # 运行安全配置脚本

配置说明:

  • 设置root密码:redhat(生产环境建议使用强密码)
  • 移除匿名用户:Remove anonymous users?:y
  • 禁止root远程登录:Disallow root login remotely?:n
  • 移除测试数据库:Remove test database and access to it?:y
  • 重载权限表:Reload privilege tables now? :y

7. 安装PHP
# 启用Remi仓库(PHP 7.4,更稳定且兼容WordPress)
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php70	#启用php70# 安装PHP及扩展
yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd

8. 配置PHP时区,将时区改成亚洲/上海
echo "date.timezone = Asia/Shanghai" >> /etc/php.ini  # 追加时区配置
systemctl restart php-fpm
systemctl enable php-fpm

9. 配置Apache默认页
# 设置默认首页为index.php
vim /etc/httpd/conf/httpd.conf
<IfModule dir_module>DirectoryIndex index.html index.php
</IfModule># 创建测试页
echo "<?php phpinfo(); ?>" > /var/www/html/index.php# 启动服务
systemctl restart httpd
systemctl enable httpd

10. 测试LAMP环境

访问 http://服务器IP,确认显示PHP信息页(如下图示)
LAMP基础环境部署成功

在这里插入图片描述


11. 上传WordPress
yum -y install lrzszmkdir -p /opt/software  # 创建软件目录
cd /opt/software
# 使用rz上传或wget下载(示例使用wget)
`将wordpress-6.5.5.tar.gz压缩包拖入进`
wget https://wordpress.org/wordpress-6.5.5.tar.gz

12. 解压并部署WordPress
yum -y install tartar -zxvf wordpress-6.5.5.tar.gz
#ls 查看解压完的包
cp -R wordpress /var/www/html/

13. 设置目录权限
chown -R apache:apache /var/www/html/wordpress  # 属主属组
chmod -R 755 /var/www/html/wordpress            # 建议755(原文档775权限过高)

14. 创建WordPress数据库
mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.5.22-MariaDB MariaDB ServerCopyright (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_db;
Query OK, 1 row affected (0.000 sec)MariaDB [(none)]> create user 'wordpress_user'@'localhost' identified by 'redhat';
Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> grant all on wordpress_db.* to 'wordpress_user'@'localhost';
Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

15. 配置Apache虚拟主机
cp -p /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/  # 备份原配置vim /etc/httpd/conf.d/httpd-vhosts.conf  # 新建虚拟主机配置

添加以下内容:

<VirtualHost 192.168.100.10:80>DocumentRoot "/var/www/html/wordpress"<Directory "/var/www/html/wordpress">Options Indexes FollowSymLinksAllowOverride All      # 允许.htaccess覆盖配置Require all granted</Directory>
</VirtualHost>

16. 重启Apache服务
systemctl restart httpd

17. 完成WordPress安装
  1. 访问 http://服务器IP
  2. 按向导填写信息:
    • 数据库名: wordpress_db
    • 用户名: wordpress_user
    • 密码: redhat
    • 数据库主机: localhost
    • 表前缀: wp_(默认)
  3. 点击提交 → 运行安装 → 设置站点标题/管理员账号

WordPress部署完成!
在这里插入图片描述

http://www.dtcms.com/a/336934.html

相关文章:

  • 云原生Ansible渗透场景(⾃动化的运维⼯具)
  • Ansible企业及实战
  • OVS:除了Geneve和VXLAN,还有哪些虚拟化网络协议?
  • 云计算:企业数字化转型的核心引擎
  • 传统方式部署(RuoYi-Cloud)微服务
  • 一套GoldenGate → Kafka → Flink → MySQL 的端到端增量同步方案
  • 云计算学习100天-第17天
  • Linux学习-(进程间,线程间通信)
  • nuScence数据集
  • 计算机视觉 图像处理 在两张二值图中检测线条交集点的高效方法 适合工程图纸比对、生物神经元网络分析和文档特征提取等场景 ,
  • 20. 云计算-Service MeshServerless
  • 谷粒商城项目-P3简介-分布式基础概念
  • CloudBase AI ToolKit + VSCode Copilot:打造高效智能云端开发新体验
  • 【运维进阶】LNMP + WordPress 自动化部署实验
  • CMakeLists.txt 学习笔记
  • MariaDB/MySQL 客户端工具与服务端配置精要指南
  • C++---有符号和无符号整数的位移操作
  • 云原生俱乐部-mysql知识点归纳(1)
  • 《亚矩阵云手机重构出租接单:KVM 虚拟化与边缘计算驱动的设备替代技术路径》
  • 8.18决策树
  • 性能测试(Jemter)
  • grep命令要点、详解和示例
  • 基于nvm安装管理多个node.js版本切换使用(附上详细安装使用图文教程+nvm命令大全)
  • QT第九讲- 控件委托
  • Git智能合并机制深度解析
  • ChatGPT-5 对教育行业的影响与案例研究
  • Qt笔试题
  • 录像视频删除如何恢复?手机电脑的录像恢复技巧
  • 给linux的root磁盘扩容
  • 手游搬砖对云手机的需求有哪些?