WordPress安装笔记

新建用户

新用户加入sudo组

软件源改为清华源

sudo apt update

sudo apt upgrade

sudo reboot

 

sudo apt install apache2

sudo apt install mysql-server

#检查MySQL运行状态,显示active (running)即为成功
service mysql status

#修改密码
安装完成后,root用户默认是没有密码的。

#进入MySQL命令行
sudo mysql -uroot

use mysql;

#查看MySQL用户列表
select user,host,authentication_string from user;

#修改root密码为123456
alter user 'root'@'localhost' identified with mysql_native_password by '123456';

#刷新权限
flush privileges;

#退出MySQL命令行并重新进入,测试root密码。
quit

安全设置(可选)
修改密码完成后已经可以正常使用,在MySQL官方文档中还提供了一个设置工具,可以进行密码安全级别调整、匿名用户移除、禁止远程登录等操作,如果有需要可以进行设置。使用以下命令(在Linux命令环境下执行),输入密码后继续:

mysql_secure_installation

#要设置密码安全组件吗? 输入Y回车
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

#设置密码的安全级别,这里我选择最低,输入0回车
通过输入数字设置密码安全级别,0为最低,1为中等,2为最高。
There are three levels of password validation policy:

LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0

 

#你的root密码强度25,是否要修改?这里我不修改,输入N回车
Estimated strength of the password: 25
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

#是否删除匿名用户?这里我选择删除,输入Y回车
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

#是否禁止root用户远程登录?这里我选择禁止,输入Y回车(这里建议禁止,如果需要远程登录,可以添加新的连接规则,不要直接使用root用户。)
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

#是否删除测试数据库?这里我选择删除,输入Y回车
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

#是否重新加载权限表?这里我选择是,输入Y回车(不小心按错了也可以重启一下MySQL服务)
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

#全部完成!
All done!

#创建WordPress数据库和用户
MySQL –uroot –p
输入MySQL的root密码

CREATE DATABASE 【新数据库名称】;

CREATE USER '【新用户名称】'@'localhost' IDENTIFIED BY '【新用户密码】';

GRANT ALL PRIVILEGES ON 【新数据库名称】.* TO '【新用户名】'@'localhost';

FLUSH PRIVILEGES;

#退出mysql数据库终端
quit;

#安装PHP以及相关组件
sudo apt install php libapache2-mod-php php-mysql php-gd php-curl php-dom php-imagick php-mbstring php-zip php-intl

#下载WordPress安装包
浏览器访问https://wordpress.org/download/releases/选择最新版本的tar.gz点击下载

把官网下载的wordpress-x.x.tar.gz压缩包上传到服务器“你的用户名”根目录

#把上传到服务器的WordPress安装包解压到当前文件夹
sudo tar -zxvf wordpress-6.4.tar.gz

#删除此目录下的所有文件
sudo rm -rf /var/www/html/*

#把解压后的安装文件移动到指定目录
sudo mv wordpress/* /var/www/html/

#给/var/www/html/目录设置权限
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

现在可以访问你的服务器ip,开始安装并设置你的WordPress