怎样创建自己的博客(如何在博客里介绍你自己)

seo大杂烩 (98) 2020-10-31 11:35:52

1. 申请域名

2. 申请服务器

说明:
这个是我自己在 腾讯云上面申请的,具体可以自己去腾讯云上面购买和申请!
我申请的域名为 www.tokenmi.cn 
服务器 IP 地址为: 123.207.253.29
这个可以通过 ping www.tokenmi.cn 得到 IP 地址
2017/09/27 搭建了网站,但是没有备案 发现今天被屏蔽了

上面两个步骤就不多说; 申请后记得放开 80 端口,默认之放开了 22 端口.

域名信息:

怎样创建自己的博客(如何在博客里介绍你自己) (https://www.cxta.com/) seo大杂烩 第1张

服务器信息:

怎样创建自己的博客(如何在博客里介绍你自己) (https://www.cxta.com/) seo大杂烩 第2张

放开 80 端口:

怎样创建自己的博客(如何在博客里介绍你自己) (https://www.cxta.com/) seo大杂烩 第3张

博客三板斧 Nginx + PHP (WordPress) + Mysql

机器信息:

[root@VM_123_161_centos ~]# uname -a
Linux VM_123_161_centos 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@VM_123_161_centos ~]# free -m
 total used free shared buff/cache available
Mem: 992 780 78 0 133 69
Swap: 0 0 0
[root@VM_123_161_centos ~]# cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 79
model name	: Intel(R) Xeon(R) CPU E5-26xx v4
stepping	: 1
microcode	: 0x1
cpu MHz		: 2394.452
cache size	: 4096 KB
physical id	: 0
siblings	: 1
core id		: 0
cpu cores	: 1
apicid		: 0
initial apicid	: 0
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch avx2 rdseed adx xsaveopt
bogomips	: 4788.90
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management:

------------------------------------------Nginx 篇 -----------------------------------------------------

1. 安装 nginx:

[root@VM_123_161_centos ~]# yum install nginx -y
// nginx-1.10.2-1.el7.x86_64

2. 启动 nginx:

[root@VM_123_161_centos system]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service
[root@VM_123_161_centos system]# ps aux | grep nginx
root 32553 0.0 0.2 122768 2204 ? Ss Sep27 0:00 nginx: master process /usr/sbin/nginx
nginx 32554 0.0 0.3 125312 3200 ? S Sep27 0:00 nginx: worker process
root 32733 0.0 0.0 112648 960 pts/0 R+ 15:51 0:00 grep --color=auto nginx
[root@VM_123_161_centos system]#

这里可以通过 :

service nginx restart
#或者
/bin/systemctl restart nginx.service
#来启动 nginx

启动后 可以通过在 浏览器里面输入域名查看到 nginx 提供的默认主页!

3. nginx.service 文件以及路径:

[root@VM_123_161_centos system]# cat nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@VM_123_161_centos system]# pwd
/usr/lib/systemd/system

4. nginx 配置文件路径: (最终我们为了让 nginx 支持 php 要修改 nginx.conf 文件)

[root@VM_123_161_centos nginx]# ls
fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf
fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default
[root@VM_123_161_centos nginx]# pwd
/etc/nginx

修改具体见:

https://my.oschina.net/tsh/blog/1544443

-------------------------------------- php 篇 ---------------------------------------------

1. 安装 PHP

[root@VM_123_161_centos nginx]# yum install php -y
//安装包 php-5.4.16-42.el7.x86_64

2. 安装 php-fpm

[root@VM_123_161_centos nginx]# yum install php-fpm -y
//安装包 php-fpm-5.4.16-42.el7.x86_64

可以通过下面的命令来启动 php-fpm

[root@VM_123_161_centos nginx]# service php-fpm restart
Redirecting to /bin/systemctl restart php-fpm.service

安装好后可以发现 127.0.0.1:9000 会被监听 (用于 nginx 和 php-fpm 通信)

怎样创建自己的博客(如何在博客里介绍你自己) (https://www.cxta.com/) seo大杂烩 第4张

---------------------------------------- wordpress 篇 ----------------------------------

1. 下载 wordpress

主页

怎样创建自己的博客(如何在博客里介绍你自己) (https://www.cxta.com/) seo大杂烩 第5张

2. 上传 wordpress 到服务器

说明:
这里 我是 通过 xshell 登录到 linux 机器的, 默认情况下机器没有提供 rz sz 命令,这个可以自己编译安装
或者通过 winscp 上传

3. 目录树:

[root@VM_123_161_centos nginx]# ls
html modules wordpress
[root@VM_123_161_centos nginx]# pwd
/usr/share/nginx
[root@VM_123_161_centos nginx]# cd wordpress/
[root@VM_123_161_centos wordpress]# pwd
/usr/share/nginx/wordpress
[root@VM_123_161_centos wordpress]# ls
index.php wp-activate.php wp-comments-post.php wp-content wp-links-opml.php wp-mail.php wp-trackback.php
license.txt wp-admin wp-config.php wp-cron.php wp-load.php wp-settings.php xmlrpc.php
readme.html wp-blog-header.php wp-config-sample.php wp-includes wp-login.php wp-signup.php

-----------------------------------------------mysql篇----------------------------

1. 安装 mysql

CentOS7的yum源中未找到mysql服务。所以,我们要先下载mysql的repo源.

下载命令:wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

[root@VM_123_161_centos data]# cd /data
[root@VM_123_161_centos data]# rm -rf ./mysql-community-release-el7-5.noarch.rpm
[root@VM_123_161_centos data]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
--2017-09-28 16:18:26-- http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 173.223.141.174
Connecting to repo.mysql.com (repo.mysql.com)|173.223.141.174|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6140 (6.0K) [application/x-redhat-package-manager]
Saving to: ‘mysql-community-release-el7-5.noarch.rpm’
100%[==================================================================================================================================>] 6,140 --.-K/s in 0s 
2017-09-28 16:18:27 (583 MB/s) - ‘mysql-community-release-el7-5.noarch.rpm’ saved [6140/6140]

安装 rpm 包

[root@VM_123_161_centos data]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
Preparing... ################################# [100%]

通过 yum 安装 mysql

[root@VM_123_161_centos data]# yum install mysql-server
//mysql-community-server-5.6.37-2.el7.x86_64

启动 mysql

[root@VM_123_161_centos data]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@VM_123_161_centos data]#
[root@VM_123_161_centos data]# ps aux | grep mysql
mysql 1193 0.0 0.1 113252 1588 ? Ss 16:22 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql 1360 3.6 46.3 1316684 471268 ? Sl 16:22 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root 1388 0.0 0.0 112648 964 pts/0 R+ 16:22 0:00 grep --color=auto mysql

添加新mysql用户:

1. 修改一下配置文件

[root@VM_123_161_centos etc]# vim /etc/my.cnf

怎样创建自己的博客(如何在博客里介绍你自己) (https://www.cxta.com/) seo大杂烩 第6张

修改这一行就可以了,否则添加用户的时候会报错

2. 登录到mysql (这里默认没有密码,提示输入密码直接回车就可以了)

[root@VM_123_161_centos etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
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> insert into mysql.user(Host, User, Password) values ('localhost', 'tsh185', password('qwer1234'));
Query OK, 1 row affected, 3 warnings (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit;

这里就创建了一个 用户名为 tsh185 密码为 qwer1234 的 mysql 用户! 当前如果用这个用户登录 mysql 是会提示失败的!

原因是 mysql 里面存在一个 为空的用户(直接在 shell>>mysql 就可以登录到 mysql),要删除该用户才能使用 tsh185 这个用户登录到 mysql

[root@VM_123_161_centos etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
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 mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> delete from user where User='';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit;

3. 创建数据库(tsh185blog), 并且授权给用户 tsh185

[root@VM_123_161_centos etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
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 tsh185blog;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| blogdb |
| mysql |
| performance_schema |
| tsh185blog |
+--------------------+
5 rows in set (0.00 sec)
mysql> grant all privileges on tsh185blog.* to tsh185@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye

4. 验证一把 tsh185 用户 对 tsh185blog 的权限

(这里可以通过 tsh185 登录 mysql 可以看到数据库 tsh185blog )

[root@VM_123_161_centos etc]# mysql -u tsh185 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.37 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| tsh185blog |
+--------------------+
2 rows in set (0.00 sec)
mysql> quit;
Bye

到此 通过 修改 nginx.conf 配置文件来启动 wordpress 了

[root@VM_123_161_centos nginx]# vim /etc/nginx/nginx.conf

配置文件内容见: https://my.oschina.net/tsh/blog/1544443

----------------------------------最后-----------------------------------

1. 打开浏览器输入你的域名:就可以配置 wordpress 了

这里要填写的信息,就是上面的mysql 创建的信息.

比如我这里的 数据库就是: tsh185blog

我这里的用户名 就是: tsh185

我这里的密码就是: qwer1234

我这里的 数据库主机是: localhost

表前缀我这里填写的是: bm_

怎样创建自己的博客(如何在博客里介绍你自己) (https://www.cxta.com/) seo大杂烩 第7张

配置完成后 网站就搭建完成了!

THE END

发表评论