/ ghost

wordpress

how-to-install-wordpress-on-centos-7

wordpress 对系统的要求:

  • 内存至少要 512MB 才能跑得起来。

docker 运行

# wordpress
docker pull wordpress

# mysql
docker pull mysql

# 启动 mysql
docker run --name mysql_wordpress -e MYSQL_ROOT_PASSWORD=wordpress  -d  mysql

# 对应mysql,启动wordpress
docker run --name docker_wordpress --link mysql_wordpress:mysql -p 8080:80 -d wordpress

Then, access it via http://localhost:8080 or http://host-ip:8080 in a browser.

REST api

wordpress 从 4.4 开始支持 REST api,以 wordpress 4.9 为例,可通过浏览器直接访问 REST API 的其中一种URL:https://www.example.com/wp-json/wp/v2/posts?per_page=5&page=1

需要注意的是,只有在将 permalinks(固定链接) 由 plain(朴素) 改为其它形式,REST API 才能正常生效,否则会报 404。

wp-cli

wp core download --locale=zh_CN

wp core version

创建数据库:

mysqladmin -u root -p 

create db_wordpress

grant all privileges on db_wordpress.* to 'admin'@'localhost' identified by 'GcPpQJe0FDai9Dlhtu69KoOP54RAVkfdadfN9H5a21fpKU=';

db_wordpress 这个数据库的管理员用户名是 admin,密码是GcPpQJe0LE9h2Dlhtu69KoOP54RAVz1pN9H5a21fpKU=

wp core config --dbname=db_wordpress--dbuser=admin --dbpass=GcPpQJe0FDai9Dlhtu69KoOP54RAVkfdadfN9H5a21fpKU= --dbhost=localhost --locale=zh_CN

安装

wp core install --url=http://wp.haobing.io --title='WordPress' --admin_user=admin --admin_password=123456 --admin_email=hi@haobing.wang

nginx:

server {
  listen        80;
  server_name   wp.haobing.io;
  root          /vagrant/wordpress/public;
  index         index.php index.html index.htm;

  location / {
     try_files $uri $uri/ /index.php?$query_string;
  }

  location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include fastcgi_params;  
  }
}