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

Centos7安装部署wordpress个人博客保姆级教程

目录

  • 关闭防火墙
  • 修改yum镜像源
  • 安装 php
  • 安装mysql
  • 安装nginx
  • 关闭SELinux
  • 配置nginx转发php文件到fpm服务
  • 下载wordpress与配置

centos: 7

php:8.1.29

wordpress:6.8.1

nginx:1.26.1

mysql:5.6.51


关闭防火墙

# 停止防火墙
systemctl stop firewalld
# 禁止开启启动
systemctl disable firewalld

修改yum镜像源

centos默认yum镜像源已无法使用,当使用yum install 会报错:

在这里插入图片描述

# 1.备份原镜像源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 2.下载阿里镜像源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 3.刷新缓存
yum clean all
yum makecache

安装 php

  • 将 yum 源更换为 aliyun 的 remi:

    yum -y install https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm
    yum -y install yum-utils
    
  • 为 PHP8.1 启用流模块:

    yum-config-manager --enable remi-php81
    
  • 安装 PHP8.1 及扩展:

    yum install -y php
    sudo yum install -y php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis php-common php-opcache php-memcached --skip-broken
    
  • 运行下面的命令,查看已安装的 PHP 版本,只要能显示版本,就证明 PHP 已经安装成功!

    php -v
    

    在这里插入图片描述

  • 启动php服务

    systemctl start php-fpm
    systemctl enable php-fpm
    
    # 配置文件地址
    /etc/php-fpm.d# 日志
    tail -f /var/log/php-fpm/error.log
    

安装mysql

  • 在线安装mysql的repo源

    # 1.下载mysql的repo源
    wget http://repo.mysql.com/mysql-community-release-el7-7.noarch.rpm
    # 注:如果没有wget下载命令就执行 yum install wget 进行安装# 2.安装mysql的repo源
    rpm -ivh mysql-community-release-el7-7.noarch.rpm# 3.安装完成后 /etc/yum.repos.d/ 下会有多两个文件:mysql-community.repo , mysql-community-source.repo
    

    在这里插入图片描述

  • 安装mysql

    yum install -y mysql-server
    
  • 重置mysql密码

    # 启动mysql服务
    systemctl start mysql
    # 运行以下脚本
    mysql_secure_installation
    # 提示输入root密码,初始为null,回车就可以设置root密码了,其他选项回车即可
    
  • 登录mysql

    mysql -u root -p 
    # 输入刚刚设置的密码即可进入
    
  • 允许远程登录

    # 授权
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码';
    # 刷新权限
    FLUSH PRIVILEGES;
    # 退出
    exit
    
  • 开机启动mysql

    systemctl enable mysqld
    

安装nginx

  • 在线安装nginx的repo源

    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    
  • 安装nginx

    yum install -y nginx
    
  • 启动Nginx

    systemctl start nginx
    
  • 访问80端口:

在这里插入图片描述

  • 设置开启启动

    systemctl enable nginx
    
    # Nginx全局配置
    cat /etc/nginx/nginx.conf
    # 网站默认站点配置
    cat /etc/nginx/conf.d/default.conf# 网站文件存放默认目录
    cd /usr/share/nginx/html# 打印nginx错误日志
    tail -f /var/log/nginx/error.log
    # 重载nginx配置
    cd /usr/sbin
    ./nginx -s reload
    

关闭SELinux

  • 查看当前selinux的状态

    /usr/sbin/sestatus
    
  • 关闭selinux

    vi /etc/selinux/config
    #SELINUX=enforcing 修改为 SELINUX=disabled
    
  • 重启

    reboot
    

配置nginx转发php文件到fpm服务

  • 修改nginx配置:

    cd /etc/nginx/conf.d# 修改default.conf文件server {listen       80;server_name  localhost;root   /usr/share/nginx/html;location / {index  index.php index.html index.htm;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}location ~ \.php$ {fastcgi_index index.php;fastcgi_pass 127.0.0.1:9000;include      fastcgi_params;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}
    }
    
  • 重载nginx配置

    cd /usr/sbin
    ./nginx -s reload
    
  • 创建php测试页面

    echo "<?php phpinfo(); ?>" > /usr/share/nginx/html/info.php
    
  • 访问http://ip/info.php,显示如下页面则表示nginx成功转发php文件到php-fpm服务

在这里插入图片描述

下载wordpress与配置

  • 官网下载wordpress压缩包

    # 我们统一放在/home/project下
    cd /home
    mkdir project
    cd /project
    wget --no-check-certificate https://cn.wordpress.org/wordpress-6.8.1-zh_CN.tar.gz
    tar -zxvf wordpress-6.8.1-zh_CN.tar.gz
    
  • 修改nginx根目录路径到/home/project/wordpress

    cd /etc/nginx/conf.d# 修改default.conf文件
    
    server {listen       80;server_name  localhost;root   /home/project/wordpress;#access_log  /var/log/nginx/host.access.log  main;location / {index  index.php index.html index.htm;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {fastcgi_index index.php;fastcgi_pass 127.0.0.1:9000;include      fastcgi_params;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}
    }
    
  • 重载nginx配置

    cd /usr/sbin
    ./nginx -s reload
    
  • 浏览器访问http://{ip}

  • 出现这个页面就表示部署成功了

在这里插入图片描述

注意填写的数据库名需要提前在mysql中创建好对应的database

在这里插入图片描述

剩下的就根据wordpress的提示一步步配置即可完成部署

http://www.xdnf.cn/news/5969.html

相关文章:

  • iVX 研发基座:大型系统开发的协作与安全架构实践
  • 基于MATLAB的生物量数据拟合模型研究
  • 云蝠智能大模型呼叫优势:技术驱动全链路升级,重塑智能交互服务新体验
  • 前端性能优化3:深入分析 Web Worker 和 Service Worker
  • 【源码+文档+调试讲解】驾校报名小程序2
  • python打卡day24
  • ppy/osu构建
  • window 显示驱动开发-创建分配时指定段
  • 块设备代码分析
  • 测试集群的功能-执行wordcount程序
  • uniapp|实现获取手机摄像头权限,调用相机拍照实现人脸识别相似度对比,拍照保存至相册,多端兼容(APP/微信小程序)
  • 什么情况会导致JVM退出?
  • 【机器学习赋能的智能光子学器件系统研究与应用】
  • 界面组件DevExpress WPF中文教程:Grid - 如何自定义Band Header外观?
  • 《内网渗透测试:绕过最新防火墙策略》
  • ZYNQ实战:可编程差分晶振Si570的配置与应用指南
  • 人工智能基础知识笔记九:模型评估的指标
  • OpenAI官方指南,详细解释了何时使用哪种AI模型
  • amd架构主机构建arm架构kkfileview
  • vue3学习——侦听器
  • 从零开始掌握FreeRTOS——目录
  • Java后端快速生成验证码
  • Python查询ES错误ApiError(406, ‘Content-Type ...is not supported
  • vr视频制作攻略(VR视频制作基础知识)
  • 漏桶算法的实际应用案例:数据库批量写入流量控制
  • 基于智能家居项目 解析DHT11温湿度传感器
  • hadoop中创建MySQL新数据库数据表
  • 数据库数据清洗、预处理与质量监控、 数据质量的核心概念
  • 《Effective Python》第1章 Pythonic 思维总结——编写优雅、高效的 Python 代码
  • 分布式任务调度XXL-Job