搜索
首页后端开发php教程WordPress搭建个人博客

WordPress搭建个人博客

Mar 22, 2018 pm 02:05 PM
wordpress博客搭建

本文主要和大家分享WordPress搭建个人博客,主要以图文和代码的形式和大家分享,希望能帮助到大家。

1 LNMP组合

1.1 验证Nginx到php的连通性

在前几篇博文中所有环境都已经配置好了,下面测试Nginx和php之间的连通

LNMP之Nginx服务搭建及三种类型虚拟主机
LNMP之二进制安装mysql-5.5.54
LNMP之源码编译安装php-5.5.32

# 修改/application/nginx/conf/extra/blog.conf[root@web01 extra]# cat blog.conf
    server {        listen       80;
        server_name  blog.rsq.com;
        location / {
            root   html/blog;            index  index.html index.htm;
        }
        location ~ .*\.(php|php5)?$ {
            root html/blog;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
        }
    }# 重启nginx服务[root@web01 extra]# ../../sbin/nginx -tnginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@web01 extra]# ../../sbin/nginx -s reload# 在/application/nginx/html/blog/目录中写一个phpinfo文件,测试连通性[root@web01 extra]# cd /application/nginx/html/blog/[root@web01 blog]# echo "<?php phpinfo(); ?>" >test_info.php[root@web01 blog]# cat test_info.php<?php phpinfo(); ?>

# windows浏览器中做访问测试,若出现以下页面则测试成功
phpinfo

1.2 验证php到mysql的连通性

# 写一个简单的数据库连接脚本[root@web01 blog]# cat test_mysql.php<?php
    $link_id=mysql_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;oldboy123&#39;) or mysql_error();    if($link_id){        echo "Mysql successful by RSQ !";
    }else{        echo mysql_error();
    }?>

# 浏览器端测试
这里写图片描述

2 LNMP之wordpress个人博客搭建

2.1 创建wordpress数据库

# 先登录mysql,创建WordPress所需要的数据库
[root@web01 ~]# mysql -uroot -poldboy123mysql> show databases;
+--------------------+| Database           |
+--------------------+| information_schema |
| mysql              |
| performance_schema || test               |
+--------------------+4 rows in set (0.01 sec)

mysql> drop database test;          # 删除多余的test数据库
Query OK, 0 rows affected (0.02 sec)mysql> show databases;          #显示数据库
+--------------------+| Database           |
+--------------------+| information_schema |
| mysql              |
| performance_schema |+--------------------+3 rows in set (0.00 sec)

mysql> create database wordpress;           # 创建wordpress用户
Query OK, 1 row affected (0.00 sec)mysql> show databases;
+--------------------+| Database           |
+--------------------+| information_schema |
| mysql              |
| performance_schema || wordpress          |
+--------------------+4 rows in set (0.00 sec)mysql> select user();
+----------------+| user()         |
+----------------+| root@localhost |
+----------------+1 row in set (0.00 sec)mysql> select user,host from mysql.user;        #查看当前数据库用户
+------+-----------+| user | host      |
+------+-----------+| root | 127.0.0.1 |
| root | ::1       |
|      | localhost || root | localhost |
+------+-----------+4 rows in set (0.00 sec)

# 为wordpress数据库创建专门管理的wordpress用户并授予所有权限
mysql> grant all on wordpress.* to wordpress@&#39;localhost&#39; identified by &#39;123456&#39;;        
Query OK, 0 rows affected (0.00 sec)mysql> select user,host from mysql.user;    # 查看wordpress数据库用户是否创建
+-----------+-----------+| user      | host      |
+-----------+-----------+| root      | 127.0.0.1 |
| root      | ::1       |
|           | localhost |
| root      | localhost || wordpress | localhost |
+-----------+-----------+5 rows in set (0.00 sec)
mysql> show grants for wordpress@&#39;localhost&#39;;   # 查看指定用户所具有的权限
mysql> flush privileges;        # 刷新一下,使用户权限生效
Query OK, 0 rows affected (0.00 sec)

2.2 修改blog.conf配置文件

# blog.conf配置文件中index新增index.html[root@web01 extra]# cat blog.conf 
    server {
        listen       80;
        server_name  blog.rsq.com;
        location / {
            root   html/blog;
            index  index.php index.html index.htm;
        }
        location ~ .*\.(php|php5)?$ {
            root html/blog;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
        }
    }
[root@web01 tools]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@web01 tools]# /application/nginx/sbin/nginx -s reload

2.3 下载wordpress软件包

# 先去官网查看所支持插件的版本
这里写图片描述

# 去官网下载最新的wordpress软件包[root@web01 extra]# cd /home/oldboy/tools/[root@web01 tools]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz# 解压缩[root@web01 tools]# tar -xf wordpress-4.9.4-zh_CN.tar.gz# 拷贝wordpress目录下的所有内容到/application/nginx/html/blog/目录下[root@web01 tools]# cp -a wordpress/* /application/nginx/html/blog/[root@web01 tools]# ls /application/nginx/html/blog/index.php        wp-blog-header.php    wp-includes        wp-settings.phplicense.txt      wp-comments-post.php  wp-links-opml.php  wp-signup.phpreadme.html      wp-config-sample.php  wp-load.php        wp-trackback.phpwp-activate.php  wp-content            wp-login.php       xmlrpc.phpwp-admin         wp-cron.php           wp-mail.php# 授予权限,先暂时授予所有文件,以后再调整权限[root@web01 tools]# chown -R www.www /application/nginx/html/blog/

2.4 网页安装wordpress

# 客户端 hosts文件要做解析

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

———————————————END!

目录



  • 1 LNMP组合

    • 1.1 验证Nginx到php的连通性

    • 1.2 验证php到mysql的连通性

  • 2 LNMP之wordpress个人博客搭建

    • 2.1 创建wordpress数据库

    • 2.2 修改blog.conf配置文件

    • 2.3 下载wordpress软件包

    • 2.4 网页安装wordpress

1 LNMP组合

1.1 验证Nginx到php的连通性

在前几篇博文中所有环境都已经配置好了,下面测试Nginx和php之间的连通

LNMP之Nginx服务搭建及三种类型虚拟主机
LNMP之二进制安装mysql-5.5.54
LNMP之源码编译安装php-5.5.32

# 修改/application/nginx/conf/extra/blog.conf[root@web01 extra]# cat blog.conf
    server {        listen       80;
        server_name  blog.rsq.com;
        location / {
            root   html/blog;            index  index.html index.htm;
        }
        location ~ .*\.(php|php5)?$ {
            root html/blog;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
        }
    }# 重启nginx服务[root@web01 extra]# ../../sbin/nginx -tnginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@web01 extra]# ../../sbin/nginx -s reload# 在/application/nginx/html/blog/目录中写一个phpinfo文件,测试连通性[root@web01 extra]# cd /application/nginx/html/blog/[root@web01 blog]# echo "<?php phpinfo(); ?>" >test_info.php[root@web01 blog]# cat test_info.php<?php phpinfo(); ?>

# windows浏览器中做访问测试,若出现以下页面则测试成功
phpinfo

1.2 验证php到mysql的连通性

# 写一个简单的数据库连接脚本[root@web01 blog]# cat test_mysql.php<?php
    $link_id=mysql_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;oldboy123&#39;) or mysql_error();    if($link_id){        echo "Mysql successful by RSQ !";
    }else{        echo mysql_error();
    }?>

# 浏览器端测试
这里写图片描述

2 LNMP之wordpress个人博客搭建

2.1 创建wordpress数据库

# 先登录mysql,创建WordPress所需要的数据库
[root@web01 ~]# mysql -uroot -poldboy123mysql> show databases;
+--------------------+| Database           |
+--------------------+| information_schema |
| mysql              |
| performance_schema || test               |
+--------------------+4 rows in set (0.01 sec)

mysql> drop database test;          # 删除多余的test数据库
Query OK, 0 rows affected (0.02 sec)mysql> show databases;          #显示数据库
+--------------------+| Database           |
+--------------------+| information_schema |
| mysql              |
| performance_schema |+--------------------+3 rows in set (0.00 sec)

mysql> create database wordpress;           # 创建wordpress用户
Query OK, 1 row affected (0.00 sec)mysql> show databases;
+--------------------+| Database           |
+--------------------+| information_schema |
| mysql              |
| performance_schema || wordpress          |
+--------------------+4 rows in set (0.00 sec)mysql> select user();
+----------------+| user()         |
+----------------+| root@localhost |
+----------------+1 row in set (0.00 sec)mysql> select user,host from mysql.user;        #查看当前数据库用户
+------+-----------+| user | host      |
+------+-----------+| root | 127.0.0.1 |
| root | ::1       |
|      | localhost || root | localhost |
+------+-----------+4 rows in set (0.00 sec)

# 为wordpress数据库创建专门管理的wordpress用户并授予所有权限
mysql> grant all on wordpress.* to wordpress@&#39;localhost&#39; identified by &#39;123456&#39;;        
Query OK, 0 rows affected (0.00 sec)mysql> select user,host from mysql.user;    # 查看wordpress数据库用户是否创建
+-----------+-----------+| user      | host      |
+-----------+-----------+| root      | 127.0.0.1 |
| root      | ::1       |
|           | localhost |
| root      | localhost || wordpress | localhost |
+-----------+-----------+5 rows in set (0.00 sec)
mysql> show grants for wordpress@&#39;localhost&#39;;   # 查看指定用户所具有的权限
mysql> flush privileges;        # 刷新一下,使用户权限生效
Query OK, 0 rows affected (0.00 sec)

2.2 修改blog.conf配置文件

# blog.conf配置文件中index新增index.html[root@web01 extra]# cat blog.conf 
    server {
        listen       80;
        server_name  blog.rsq.com;
        location / {
            root   html/blog;
            index  index.php index.html index.htm;
        }
        location ~ .*\.(php|php5)?$ {
            root html/blog;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
        }
    }
[root@web01 tools]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is oknginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@web01 tools]# /application/nginx/sbin/nginx -s reload

2.3 下载wordpress软件包

# 先去官网查看所支持插件的版本
这里写图片描述

# 去官网下载最新的wordpress软件包[root@web01 extra]# cd /home/oldboy/tools/[root@web01 tools]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz# 解压缩[root@web01 tools]# tar -xf wordpress-4.9.4-zh_CN.tar.gz# 拷贝wordpress目录下的所有内容到/application/nginx/html/blog/目录下[root@web01 tools]# cp -a wordpress/* /application/nginx/html/blog/[root@web01 tools]# ls /application/nginx/html/blog/index.php        wp-blog-header.php    wp-includes        wp-settings.phplicense.txt      wp-comments-post.php  wp-links-opml.php  wp-signup.phpreadme.html      wp-config-sample.php  wp-load.php        wp-trackback.phpwp-activate.php  wp-content            wp-login.php       xmlrpc.phpwp-admin         wp-cron.php           wp-mail.php# 授予权限,先暂时授予所有文件,以后再调整权限[root@web01 tools]# chown -R www.www /application/nginx/html/blog/

2.4 网页安装wordpress

# 客户端 hosts文件要做解析

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

相关推荐:

LAMP基于php模块实现个人博客搭建的图文详解

HTTPS的WordPress搭建个人博客步骤

php个人博客 谈谈PHP继承的那些事,我的个人见解

以上是WordPress搭建个人博客的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
PHP和Python:解释了不同的范例PHP和Python:解释了不同的范例Apr 18, 2025 am 12:26 AM

PHP主要是过程式编程,但也支持面向对象编程(OOP);Python支持多种范式,包括OOP、函数式和过程式编程。PHP适合web开发,Python适用于多种应用,如数据分析和机器学习。

PHP和Python:深入了解他们的历史PHP和Python:深入了解他们的历史Apr 18, 2025 am 12:25 AM

PHP起源于1994年,由RasmusLerdorf开发,最初用于跟踪网站访问者,逐渐演变为服务器端脚本语言,广泛应用于网页开发。Python由GuidovanRossum于1980年代末开发,1991年首次发布,强调代码可读性和简洁性,适用于科学计算、数据分析等领域。

在PHP和Python之间进行选择:指南在PHP和Python之间进行选择:指南Apr 18, 2025 am 12:24 AM

PHP适合网页开发和快速原型开发,Python适用于数据科学和机器学习。1.PHP用于动态网页开发,语法简单,适合快速开发。2.Python语法简洁,适用于多领域,库生态系统强大。

PHP和框架:现代化语言PHP和框架:现代化语言Apr 18, 2025 am 12:14 AM

PHP在现代化进程中仍然重要,因为它支持大量网站和应用,并通过框架适应开发需求。1.PHP7提升了性能并引入了新功能。2.现代框架如Laravel、Symfony和CodeIgniter简化开发,提高代码质量。3.性能优化和最佳实践进一步提升应用效率。

PHP的影响:网络开发及以后PHP的影响:网络开发及以后Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP类型提示如何起作用,包括标量类型,返回类型,联合类型和无效类型?PHP类型提示如何起作用,包括标量类型,返回类型,联合类型和无效类型?Apr 17, 2025 am 12:25 AM

PHP类型提示提升代码质量和可读性。1)标量类型提示:自PHP7.0起,允许在函数参数中指定基本数据类型,如int、float等。2)返回类型提示:确保函数返回值类型的一致性。3)联合类型提示:自PHP8.0起,允许在函数参数或返回值中指定多个类型。4)可空类型提示:允许包含null值,处理可能返回空值的函数。

PHP如何处理对象克隆(克隆关键字)和__clone魔法方法?PHP如何处理对象克隆(克隆关键字)和__clone魔法方法?Apr 17, 2025 am 12:24 AM

PHP中使用clone关键字创建对象副本,并通过\_\_clone魔法方法定制克隆行为。1.使用clone关键字进行浅拷贝,克隆对象的属性但不克隆对象属性内的对象。2.通过\_\_clone方法可以深拷贝嵌套对象,避免浅拷贝问题。3.注意避免克隆中的循环引用和性能问题,优化克隆操作以提高效率。

PHP与Python:用例和应用程序PHP与Python:用例和应用程序Apr 17, 2025 am 12:23 AM

PHP适用于Web开发和内容管理系统,Python适合数据科学、机器学习和自动化脚本。1.PHP在构建快速、可扩展的网站和应用程序方面表现出色,常用于WordPress等CMS。2.Python在数据科学和机器学习领域表现卓越,拥有丰富的库如NumPy和TensorFlow。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 个月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
1 个月前By尊渡假赌尊渡假赌尊渡假赌
威尔R.E.P.O.有交叉游戏吗?
1 个月前By尊渡假赌尊渡假赌尊渡假赌

热工具

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)