当前位置: 首页 > 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.lryc.cn/news/624696.html

相关文章:

  • linux中的hostpath卷、nfs卷以及静态持久卷的区别
  • python+flask后端开发~项目实战 | 博客问答项目--数据库信息的基本配置与UserModel的创建,映射,关联
  • 【MySQL】超详细入门学习
  • Linux 系统(如 Ubuntu / CentOS)阿里云虚拟机(ECS)上部署 Bitnami LAMP
  • 【Python】Python Socket 网络编程详解:从基础到实践​
  • 云原生俱乐部-mysql知识点归纳(1)
  • 【前端面试题】JavaScript 核心知识点解析(第十四题解析到第二十二题)
  • 【牛客刷题】正六边形阴影面积计算
  • FastRTSP介绍
  • 微电网管控系统中python多线程缓存与SQLite多数据库文件连接池实践总结(含源码)
  • 多台服务器批量发布arcgisserver服务并缓存切片
  • Java 大视界 -- Java 大数据在智能安防视频监控系统中的视频内容理解与智能预警升级(401)
  • Python入门Day18:模块与包(module package)
  • Spring Boot + Spring Kafka 集成
  • SMTPman,smtp ssl助力安全高效邮件传输!
  • Java 中表示数据集的常用集合类
  • 低端设备加载webp ANR
  • 安全存储之 SAES+HUK 使用技巧和常见问题 LAT1543
  • Rust 教程之简介000
  • CSS:水平垂直居中
  • 【银河麒麟桌面系统】配置匿名文件夹与用户认证共享服务
  • 2025年秋招Java后端面试场景题+八股文题目
  • AI 推荐系统云端部署实战:基于亚马逊云科技免费资源的工程实现
  • 从财务整合到患者管理:德国医疗集团 Asklepios完成 SAP S/4HANA 全链条升级路径
  • CAN总线的安全性
  • Linux小白加油站,第三周周考
  • 世界模型之自动驾驶
  • 想找出版社出书?这样选就对了!
  • 《P1195 口袋的天空》
  • OVS:ovn是如何支持组播的?