准备 LAMP 环境

安装wordpress

1
2
wget https://cn.wordpress.org/latest-zh_CN.zip
unzip latest-zh_CN.zip

安装Mysql

1
2
3
sudo apt install mysql-server -y
sudo systemctl start mysql
sudo systemctl enable mysql

修改密码权限

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cat /etc/mysql/debian.cnf
[client]
host = localhost
user = debian-sys-maint
password = ROmgNW5hP8tsSwrB
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = ROmgNW5hP8tsSwrB
socket = /var/run/mysqld/mysqld.sock

# 修改密码
mysql -udebian-sys-maint -p

use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxx';

# 为wordpress创建数据库
use mysql;
select user,host from user;
CREATE DATABASE wordpress;
CREATE USER wordpressuser;
SET PASSWORD FOR wordpressuser=PASSWORD("password123");
ALTER USER 'wordpressuser'@'%' IDENTIFIED WITH mysql_native_password BY '136140@Techliu';

grant all on wordpress.* to 'wordpressuser'@'%';

# 生效
FLUSH PRIVILEGES;
exit;

安装apache2

1
2
3
sudo apt install apache2
sudo systemctl status apache2
sudo ufw allow 'Apache Full'

安装php

1
2
3
4
5
6
7
8
9
10
11
sudo apt-get install php -y
sudo apt install libapache2-mod-php -y
sudo apt install php-mysql -y
sudo apt install php-curl -y
sudo apt install php-gd -y
sudo apt install php-xml -y
sudo apt install php-mbstring -y
sudo apt install php-xmlrpc -y
sudo apt install php-zip -y
sudo apt install php-soap -y
sudo apt install php-intl -y

配置wordpress

1
2
3
4
5
6
7
8
9
10
sudo mkdir /var/www/html
sudo mv wordpress/* /var/www/html/
sudo chmod -R 777 /var/www/html/

sudo mysql_secure_installation
sudo apt-get install phpmyadmin -y

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
sudo service mysql restart
sudo systemctl restart apache2.service

解决安装插件需要FTP问题

1
2
3
4
5
6
7
8
9
sudo vim /var/www/html/wp-config.php
# 添加以下内容

define("FS_METHOD", "direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);

# 修改权限
sudo chmod 777 -R /var/www/html/wp-content/