wordpress博客服务搭建

实战:部署wordpress

Cloud研习社 Cloud研习社 2022-12-31 10:33 发表于山东
图片图片

教程每周二、四、六更新

图片

 

Cloud研习社
为Linux云计算零基础同学服务,致力于打造一套完整的linux云计算教程。包括新手学习路线、linux、存储、集群架构以及Docker,K8S,DevOps等
179篇原创内容
WordPress是一款能让您建立出色网站、博客或应用程序的使用php开发的开源软件。本节通过部署wordpress网站来体验一下LNMP的魅力。WordPress下载地址:https://cn.wordpress.org/download/#download-install下载以后后拷贝到Linux中:
[root@localhost ~]# mkdir /usr/share/nginx/html/blog
[root@localhost ~]# tar -zxvf wordpress-5.9.3-zh_CN.tar.gz
[root@localhost ~]# cp -r wordpress/* /usr/share/nginx/html/blog
[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
[root@localhost ~]# cat /etc/nginx/conf.d/default.conf | grep -v "^ #"
server {
    listen 80;
    server_name localhost;

    location / {
        root /usr/share/nginx/html/blog; # http的root目录设置为/usr/share/nginx/html/blog
        index index.php index.html index.htm;
    }

    error_page 500 502 503 504  /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
            root /usr/share/nginx/html/blog; # http的root目录设置为/usr/share/nginx/html/blog
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

重启nginx服务:

[root@localhost ~]# systemctl restart nginx

创建一个数据库:

[root@localhost blog]# mysql -uroot -pTsinghua@123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> create database wordpress; # 创建一个数据库
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| wordpress |            # 这个wordpress就是我们创建的数据库
+--------------------+
5 rows in set (0.00 sec)

mysql> quit

下一节我们来验证并配置wordpress!


 

雷哥开通了抖音(云计算雷哥)和微信视频号,求关注!!!和大家一起学习 技术!

图片

推荐阅读

 

《一站式教程之集群架构》:

 

Nginx面试题(总结最全面的面试题!!!)

Nginx 面试题 40 问

初识LNMP

LNMP - FastCGI

部署LNMP(1)

部署LNMP(2)- 配置nginx

部署LNMP(3)- 配置mysql

 

 

 

看完本文有收获?请分享给更多人

推荐关注「Cloud研习社」,带你从零开始掌握云计算技术!

Cloud研习社
为Linux云计算零基础同学服务,致力于打造一套完整的linux云计算教程。包括新手学习路线、linux、存储、集群架构以及Docker,K8S,DevOps等
179篇原创内容

 

收录于合集 #一站式教程
 187
上一篇ngx_http_fastcgi_module详解下一篇验证wordpress
阅读 128
 

验证wordpress

Cloud研习社 Cloud研习社 2023-01-03 07:31 发表于山东
图片图片

教程每周二、四、六更新

图片

使用浏览器访问:http://10.0.0.31/,会弹出如下页面:

图片

接下来看说明就好了。大概意思就是准备好数据库的相关信息以后,系统会用这些信息生成一个wp-config.php文件,以便php程序访问数据库,那么,我们点击左下角“现在就开始!”就可以了:

图片

数据库名就填入我们前面创建的数据库名字wordpress,用户名、密码就是我们使用数据库的密码,这里我们就用root了,在实际工作中可以用别的用户,但是这个用户必须对wordpress数据库有操作权限。

数据库主机这里填入数据库服务器的地址,我们的环境就是本地,所以填写localhost即可。

填写完成后,左下角“提交”就可以了,这时候会展示出生成的配置文件内容,请复制这些内容,然后点击“运行安装程序”。

到/usr/share/nginx/html/blog目录下查看是否已经生成wp-config.php文件,如果没有生成,手动创建一个wp-config.php并把刚才复制的配置文件的内容粘贴进这个文件保存退出即可。

这个时候刷新页面,点击“立即部署”即可:

图片

上面信息(这些信息是网站管理员的信息)填写完成后,点击左下角“安装wordpress”,然后我们看数据库中就有一些表了:

[root@localhost blog]# mysql -uroot -pTsinghua@123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.37 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use wordpress;
Database changed
mysql> show tables; # 点击左下角“安装wordpress”之前,数据库还是空的,没有任何内容
Empty set (0.00 sec)

mysql> show tables;
Empty set (0.00 sec)

mysql> show tables; # 点击左下角“安装wordpress”之后,自动创建了一些表
+-----------------------+
| Tables_in_wordpress |
+-----------------------+
| wp_commentmeta |
| wp_comments |
| wp_links |
| wp_options |
| wp_postmeta |
| wp_posts |
| wp_term_relationships |
| wp_term_taxonomy |
| wp_termmeta |
| wp_terms |
| wp_usermeta |
| wp_users |
+-----------------------+
12 rows in set (0.00 sec)

此时wordpress网站就可以登陆了:

图片

接下来我们修改数据库,这样可以让wordpresss可以上传文件:

# 设置远程访问权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Tsinghua@123';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

然后通过HeidiSQL连接上数据库:

  • 找到wordpress数据库,打开wp_options表

  • 修改表中键名为upload_path的键值,添加” wp-content/uploads”双引号必加!

  • 图片

此时我们就可以正常使用wordpress了。

课后实践:

  1. 自行准备环境,练习搭建LNMP并搭建起自己的wordpress。目标:掌握这个搭建过程已经各组件的配置及作用。


 

雷哥开通了抖音(云计算雷哥)和微信视频号,求关注!!!和大家一起学习 技术!

图片

推荐阅读

 

《一站式教程之集群架构》:

 

LNMP - FastCGI

部署LNMP(1)

部署LNMP(2)- 配置nginx

部署LNMP(3)- 配置mysql

部署LNMP(4)- 配置PHP并验证

ngx_http_fastcgi_module详解

实战:部署wordpress

 

 

 

看完本文有收获?请分享给更多人

推荐关注「Cloud研习社」,带你从零开始掌握云计算技术!

Cloud研习社
为Linux云计算零基础同学服务,致力于打造一套完整的linux云计算教程。包括新手学习路线、linux、存储、集群架构以及Docker,K8S,DevOps等
179篇原创内容

图片

 

收录于合集 #一站式教程
 187
上一篇实战:部署wordpress下一篇nginx负载均衡-概述
阅读 74
 
posted @ 2023-01-17 14:56  往事已成昨天  阅读(71)  评论(0编辑  收藏  举报