LoginSignup
0
0

More than 1 year has passed since last update.

Ubuntu 20.04 安装 wordpress

Last updated at Posted at 2022-01-16

查看系统版本

lsb_release -a

Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:    20.04
Codename:   focal

下载并解压

查看 https://wordpress.org/download/releases/

wget https://wordpress.org/wordpress-5.8.3.zip # 下载源码
sudo apt install unzip # 安装 unzip
unzip wordpress-5.8.3.zip # 解压

PHP

sudo apt install -y php php-fpm php-mysql
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

php -v
# => PHP 7.4.3 (cli) (built: Nov 25 2021 23:16:22) ( NTS )

MariaDB 数据库

sudo apt install -y mariadb-server mariadb-client

mysql -V
# => mysql  Ver 15.1 Distrib 10.3.32-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
sudo mysql -u root -p # 登陆
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

GRANT ALL ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY 'wordpress';

FLUSH PRIVILEGES;

sudo lsof -Pn -iTCP:3306 访问端口

sudo apt install mycli 也可以安装 mycli,访问 mysql 数据库

Nginx

sudo apt install -y nginx

nginx -v
# => nginx version: nginx/1.18.0 (Ubuntu)

Nginx 配置文件

# /etc/nginx/sites-enabled

server {
  listen 80;
  server_name abc.com;
  root <wordpress目录>;
  index index.php index.html index.htm index.nginx-debian.html;

  location / {
    try_files $uri $uri/ =404;
  }

  location ~ \.php$ {
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }
}

修改 php 配置文件

cp wp-config-sample.php wp-config.php

define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wordpress' );
define( 'DB_PASSWORD', 'wordpress' );
define( 'DB_HOST', 'localhost' );

sudo chown -R www-data:www-data wordpress


参考:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0