LNMP环境下部署wordpress

1.安装Mariadb

# 更改主机名
[root@localhost ~]# hostnamectl set-hostname wordpress
[root@localhost ~]# bash
# 关闭防火墙以及selinux
[root@wordpress ~]# systemctl stop firewalld
[root@wordpress ~]# systemctl disable firewalld --now
[root@wordpress ~]# sed -i "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
[root@wordpress ~]# setenforce 0
# 备份旧的yum源
[root@wordpress ~]# mv /etc/yum.repos.d/* /media/
# 配置阿里源
[root@wordpress ~]#  curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 配置 Mariadb源
[root@wordpress ~]# vi /etc/yum.repos.d/mariadb.repo
# MariaDB 11.2 CentOS repository list - created 2023-12-08 03:01 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/11.2/centos/$releasever/$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/11.2/centos/$releasever/$basearch
module_hotfixes = 1
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
# 生成yum 源缓存
[root@wordpress ~]# yum makecache
# 清理缓存与验证
[root@wordpress ~]# yum clean all  && yum repolist
# 下载相关依赖包
[root@wordpress ~]# yum install -y epel-release
# 下载 MariaDB-server MariaDB-client 服务
[root@wordpress ~]# yum install -y  MariaDB-server MariaDB-client
# 启动服务
[root@wordpress ~]# systemctl start mariadb
# 开机自启
[root@wordpress ~]# systemctl enable mariadb 

# 进入mariadb
mariadb -uroot -p
# 创建 wordpress 数据库
create database wordpress;
# 查看相关的库信息
show databases;
# 创建 wordpress 用户
grant all on wordpress.* to 'wordpress'@'localhost' identified by '000000';	
# 刷新权限
flush privileges;				
Ctrl+C 	# 退出Mariadb
# 重启mariadb服务
[root@wordpress ~]# systemctl restart mariadb

2.安装Nginx

# 配置 nginx 源
[root@wordpress ~]#  vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

# 下载nginx服务
[root@wordpress ~]# yum install -y nginx
# 查看nginx服务
[root@wordpress ~]# systemctl status nginx
# 启动服务
[root@wordpress ~]# systemctl start nginx
# 开机自启
[root@wordpress ~]# systemctl enable nginx --now
`在浏览器地址栏输入Linux服务器的IP地址,看到 Welcome to ningx! 说明Nginx安装成功`

在这里插入图片描述

3.安装Php

# 安装 epel 依赖包
[root@wordpress ~]# yum install -y epel-release
# 安装 REMI 软件仓库
[root@wordpress ~]# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# 安装 PHP 及相关扩展模块
[root@wordpress ~]# yum -y install php74-php php74-php-common php74-php-fpm php74-php-mysqlnd php74-php-pdo php74-php-cli php74-php-json php74-php-mbstring php74-php-sodium php74-php-pecl-imagick php74-php-xml php74-php-gd php74-php-pecl-mcrypt php74-php-pecl-zip
# 查看PHP版本信息
[root@wordpress ~]# php74 -v
PHP 7.4.33 (cli) (built: Aug  1 2023 08:30:09) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
# 启动 php 服务
[root@wordpress ~]# systemctl start php74-php-fpm.service
# 开机自启
[root@wordpress ~]# systemctl enable php74-php-fpm.service
# 测试
[root@wordpress ~]# echo "<?php phpinfo(); ?>" > /var/www/html/info.php
# 重启服务
[root@wordpress ~]# systemctl restart httpd
`在浏览器中输入该机的IP/info.php查看是否能出现php的相关信息`
# 报错
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.

1.查看服务状态
systemctl status httpd
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address...0.0:80
`可以发现80端口被占用`
netstat -ntpl | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2632/nginx: master
# 杀死进程
kill QUIT 2632
# 重启服务
systemctl restart httpd

在这里插入图片描述

4.配置wordpress

# 下载wordpress-6.4.2-zh_CN.tar包
# 解压
[root@wordpress ~]# cd /var/www/html
[root@wordpress ~]# tar -zxvf wordpress-6.4.2-zh_CN.tar
[root@wordpress ~]# cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
# 赋予权限
[root@wordpress ~]# chown -R nginx:nginx /usr/data/wordpress
# 编辑wordpress配置文件
[root@wordpress ~]# vim /var/www/html/wordpress/wp-config.php
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** Database username */
define( 'DB_USER', 'wordpress' );

/** Database password */
define( 'DB_PASSWORD', '000000' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
# 安装WordPress
在浏览器中输入该机的IP/wordpress 进入安装界面

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值