配置服务器环境搭建WordPress博客

Debain 11.1

Php 7.4.25

apt-get install php7.4

apt-get install php7.4-fpm php7.4-cgi php7.4-curl php7.4-gd php7.4-xml php7.4-xmlrpc php7.4-mysql php7.4-bz2 php7.4-bcmath php7.4-gmp php7.4-mbstring php7.4-readline php7.4-zip

APT会默认安装低版本Nginx

Nginx 1.18.0

apt-get install nginx

systemctl start nginx

Nginx

添加nginx官方源

vim /etc/apt/sources.list
deb http://nginx.org/packages/mainline/ubuntu/ focal nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ focal nginx

导入nginx公钥

wget http://nginx.org/keys/nginx_signing.key

apt-key add nginx_signing.key

查看可安装版本

apt-cache madison nginx

apt-get install nginx

systemctl start nginx

MariaDB 10.5.12

apt-get install mariadb-server

MariaDB

安全配置

mysql_secure_installation

创建数据库

登录
mysql -u root -p
创建用户
create user 'user_wordpress'@'localhost' identified by 'yourpassword';
创建WordPress数据库
create database db_wordpress default charset utf8 collate utf8_general_ci;
为新用户赋权
grant all privileges on db_wordpress.* to 'user_wordpress'@'localhost' identified by 'yourpassword';

flush privileges;
退出
exit;

简单测试

nginx与php环境

创建根目录并修改用户与用户组

cd  /var/www/html/
mkdir wordpress
chown -R www-data.www-data wordpress/

创建phpinfo文件访问测试

<?php phpinfo(); ?>

安装配置WordPress

下载并解压至wordpress文件夹

输入域名或IP地址,完成配置