Ubuntu安装wordpress

搭建wordpress

一、检查服务器配置

  1. mysql 3306 端口开放(一般在云服务器厂商处设置)

二、安装mysql

https://blog.csdn.net/wm609972715/article/details/83759266

开放root的远程登陆
mysql -u root -p 

use mysql;

update user set host='%' where user='root';

flush privileges;
创建wordpress数据库与相应用户
mysql -u root -p 

create database wordpressdb;

create user 'wordpress'@'localhost' identified by '自定义密码';

grant all on wordpressdb.* to 'wordpress'@'localhost';

flush privileges;

三、安装nginx

sudo apt update

apt install nginx

nginx -v

四、安装PHP

sudo apt install -y php php-fpm php-mysql

php -v
# PHP 7.2.19-0ubuntu0.18.04.1 (cli)

五、下载安装wordpress

wget https://wordpress.org/latest.tar.gz
tar xf latest.tar.gz
cp wordpress/* 你自己设定的路径,例nginx:/var/www/wordpress/html/

注:

如果出现mysql数据库无法连接,

  1. 检查host是否为127.0.0.1:3306

  2. 检查验证方式是否正确

    存为test.php文件

    #!/usr/bin/php
    <?php
    $link = mysqli_connect('localhost', 'wordpress', 'password');
    if (!$link) {
    die('Could not connect: ' . mysqli_error());
    }
    echo 'Connected successfully';
    mysqli_close($link);
    ?>
    
    
    chmod -x test.php
    ./test.php
    

    检查是否能正常连接,若出现验证方式错误,则更改数据库账户验证方式

    mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in /usr/local/program/testMysql.php on line 3
    PHP Warning:  mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in /usr/local/program/testMysql.php on line 3
    PHP Warning:  mysqli_error() expects exactly 1 parameter, 0 given in /usr/local/program/testMysql.php on line 
    

    更改方式

    ALTER USER 'wordpress'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码'
    
posted @ 2021-07-23 15:11  辞树  阅读(334)  评论(0)    收藏  举报