搭建wordpress博客教程

2019-06-08 分类:wordpress 阅读(9) 评论(0)

环境准备

  • 一台服务器
  • 一个域名,直接通过ip访问好傻好傻的样子,哈哈。
  • linux知识
  • 肯折腾

    部署nginx环境

    1.安装nginx依赖包

    yum install -y gcc gcc-c++ autoconf pcre pcre-devel make automake wget httpd-tools vim tree

    2.配置nginx官方yum源

    [root@web ~]# vim /etc/yum.repos.d/nginx.repo
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/centos/7/$basearch/
    gpgcheck=0
    enabled=1

    3.检查配置的yum源是否生效。有nginx说明配置没问题

    [root@web ~]# yum repolist
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    nginx                                      | 2.9 kB     00:00     
    nginx/x86_64/primary_db                      |  46 kB   00:03     
    repo id          repo name                                  status
    base/7/x86_64    CentOS-7                                   10,019
    epel/x86_64      Extra Packages for Enterprise Linux 7 - x8 13,217
    extras/7/x86_64  CentOS-7                                      409
    nginx/x86_64     nginx repo                                    152
    updates/7/x86_64 CentOS-7                                    1,982
    repolist: 25,779

    4.检查nginx版本 通过配置官方yum源安装的是最新稳定版的

    [root@web ~]# yum list nginx
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Available Packages
    nginx.x86_64               1:1.16.0-1.el7.ngx                nginx

    5.安装nginx

    yum install -y nginx

    6.配置nginx 配置文件

    
    [root@web conf.d]# cat /etc/nginx/conf.d/01www.conf 
    server   {
    listen       80;           ##监听端口 ;http协议默认
    server_name   localhost;  ##通过什么域名访问,如果你购买了域名。可以改成你的域名
    access_log  /var/log/nginx/access_www.log  main;      ##访问日志的存放路径
    root   /home/www/blog;      ##站点目录。这里可以任意修改,之后不要忘记创建这个目录
    location / {                     ##location 用来匹配URI的, 
    index  index.php index.html index.htm;          ##首页文件
    }
    location ~* \.(php|php5)$ {                             ##nginx只能处理静态页面,动态页面需要交给php处理,这里的就表示如果访问时php结尾的文件就交给php处理。
       fastcgi_pass   127.0.0.1:9000;
       fastcgi_index  index.php;
       fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_scri
    pt_name;
       include        fastcgi_params;
    }

}

###7.检查语法之后重启加入开机自启动

[root@web conf.d]# gzip default.conf ##把默认的配置文件加个注释反正不要以.conf结尾就好了,不然会冲突 [root@web conf.d]# nginx -t ##检查配置文件语法是否有问题 ,出现下面的表示没问题 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@web conf.d]# systemctl start nginx && systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

###8.创建站点目录

mkdir -p /home/www/blog

##简单测试下配置是否有问题
###1.追加文件到站点目录下的首页文件

echo www> /home/www/blog/index.html ##直接追加就行即使没有这个文件也会直接创建的

2.浏览器输入你的公网ip

如果没问题会出现你追加的内容

image.png

到这里nginx部署完成

部署php环境

1.安装php依赖包

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2.安装php 上面两个安装不上php是安装不了的

yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb

3.php配置

[root@web01 ~]# egrep  -n '^user|^group' /etc/php-fpm.d/www.conf 
8:user = nginx                       ##所有者修改为nginx
10:group = nginx                   ##所属组改为nginx
[root@web01 ~]# 
[root@web01 ~]# 
[root@web01 ~]# systemctl restart php-fpm.service 
[root@web01 ~]# ss -lntup|grep 9000
tcp    LISTEN     0      128    127.0.0.1:9000                  *:*                   users:(("php-fpm",pid=15344,fd=9),("php-fpm",pid=15343,fd=9),("php-fpm",pid=15342,fd=9),("php-fpm",pid=15341,fd=9),("php-fpm",pid=15340,fd=9),("php-fpm",pid=15339,fd=7))
[root@web01 ~]# ps -ef |grep php 
root     15339     1  0 12:42 ?        00:00:00 php-fpm: master process (/etc/php-fpm.conf)
nginx    15340 15339  0 12:42 ?        00:00:00 php-fpm: pool www
nginx    15341 15339  0 12:42 ?        00:00:00 php-fpm: pool www
nginx    15342 15339  0 12:42 ?        00:00:00 php-fpm: pool www
nginx    15343 15339  0 12:42 ?        00:00:00 php-fpm: pool www
nginx    15344 15339  0 12:42 ?        00:00:00 php-fpm: pool www
root     15348  3551  0 12:43 pts/0    00:00:00 grep --color=auto php

部署MySQL环境

1.安装MySQL

yum install -y mariadb-server 

2.启动 mysql 并检查 端口和基础

[root@web conf.d]# systemctl start mariadb.service 
[root@web conf.d]# ss -lntup|grep mysql
tcp    LISTEN     0      50        *:3306                  *:*                   users:(("mysqld",pid=3926,fd=13))
[root@web conf.d]# ps -ef|grep mysql
mysql     3764     1  0 11:17 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql     3926  3764  0 11:17 ?        00:00:00 /usr/libexec/mysqd --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root      3976  3320  0 11:18 pts/0    00:00:00 grep --color=automysql

配置mysql

[root@web ~]# mysql                   ##命令行输入mysql即可进行数据库
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> 

查看所有数据库

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

查看系统中所有的用户

MariaDB [(none)]> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1       |
|      | localhost |
| root | localhost |
|      | web01     |
| root | web01     |
+------+-----------+
6 rows in set (0.00 sec)

创建数据库

MariaDB [(none)]> create   database  wordpress;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| wordpress          |
+--------------------+
5 rows in set (0.00 sec)

创建用户

grant all      on wordpress.*       to 'wordpress'@'172.16.1.%'  identified by '123456';
grant all      on wordpress.*       to 'wordpress'@'localhost'  identified by '123456';

所有权限 wordpress数据库.所有表 '用户名'@'172.登录' 密码是 123456

检查输入密码是否能进入数据库

[root@web01 ~]# mysql -uwordpress -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> Bye

检查与测试

检查nginx与php 之间 是否有问题

[root@nginx /home/www/blog]# cat  info.php

6IDV6M(WL)%RSJB3D_@$D{R.png

检查php与mysql 之间 是否有问题

[root@nginx /home/www/blog]# cat  mysqli.php

C[BHI_$)$UG])M%2Q16I0H9.png

上传代码

网盘下载链接:提取码:tdno

[root@web01 ~]# tar xf wordpress-5.2.1.tar.gz 
[root@web01 ~]# ll
total 10944
drwxr-xr-x 5 nobody 65534     4096 May 22 02:24 wordpress
-rw-r--r-- 1 root   root  11199196 Jun  6 09:25 wordpress-5.2.1.tar.gz
[root@web01 ~]# mv wordpress/*   /home/www/blog/
[root@web01 ~]# chown -R nginx.nginx  /home/www/blog/

BL_4GSZOY@W9N%Z`1)26MY1.png

`ZOF64NQAKZCJX%BO0OZ7CO.png

您可能也喜欢:

评论&留言
欢迎新朋友你的到来!
还没有人抢沙发呢~
昵称
邮箱
网站

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

切换登录

注册