LNMP搭建WordPress

LNMP搭建WordPress

链接:https://pan.baidu.com/s/1yRtV7Z0H466Qp8aKIKrOlQ
提取码:rvhv
1、 环境准备
1.1、 Centos7虚拟机一台
1.2、 把lnmp.tar.gz上传到centos
1.3、 解压lnmp.tar.gz到/opt/下

[root@localhost ~]# tar -zxvf lnmp.tar.gz -C /opt/

1.4、 配置yum
将原本的yum移走到/home

[root@localhost ~]# mv /etc/yum.repo.d/* /home/

编写配置文件lnmp.repo

[root@localhost ~]# vi /etc/yum.repo.d/lnmp.repo

内容:

[lnmp]
name=lnmp
baseurl=file:///opt/lnmp
gpgcheck=0
enabled=1

检查是否有用

[root@localhost ~]# yum repolist

1.5、 关闭防火墙

[root@localhost ~]# systemctr stop firewalld
[root@localhost ~]# systemctr disable firewalld

关闭selinux

[root@localhost ~]# vi /etc/sysconfig/selinux
SELINUX=disabled

2、 部署MySQL服务

[root@localhost ~]# yum -y install mariadb-server
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl enable mariadb

在这里插入图片描述

安装成功可以使用没有密码
3、 部署Nginx服务
老版本centos7中yum源中没有Nginx包,新版本有包。本实验使用自己的本地yum安装。

[root@localhost ~]# yum -y install nginx

查看版本为1.6

[root@localhost ~]# nginx -v
nginx version: nginx/1.16.1

4、 部署PHP服务

[root@localhost ~]# yum -y install php

查看版本

Centos7安装默认为5版本

[root@localhost ~]# php -v
PHP 5.4.16 (cli) (built: Apr  1 2020 04:07:17) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

在这里插入图片描述

查看是否有该目录有这成功安装

5、 修改Nginx配置文件
路径:/etc/nginx/nginx.conf
修改为

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
		index index.php index.html;
        server_name  _;
        root         /usr/share/nginx/html;
	index index.php index.html;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
		root		/var/www/html;
        }

	location ~ \.php$ {
		root		html;
		fastcgi_pass	127.0.0.1:9000;
		fastcgi_index	index.php;
		fastcgi_param	SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
		include		fastcgi_params;
	}


        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }
    server {
        listen       8080 default_server;
        listen       [::]:8080 default_server;
                index index.php index.html;
        server_name  _;
        root         /usr/share/nginx/html;
	index index.php index.html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                root            /usr/share/nginx/html;
        }

        location ~ \.php$ {
                root            html;
                fastcgi_pass    127.0.0.1:9000;
                fastcgi_index   index.php;
                fastcgi_param   SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name;
                include         fastcgi_params;
        }


        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }


# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#        location = /404.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#        location = /50x.html {
#        }
#    }

}

配置文件:nginx.conf

6、 Nginx服务默认不支持PHP文件,需要安装php-fpm服务:

[root@localhost ~]# yum -y install php-fpm
[root@localhost ~]# systemctl restart php-fpm

7、 启动Nginx服务

[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl enable nginx

8、 安装PHP连接数据库的中间件

[root@localhost ~]# yum -y install php-mysql php-gd

配置MySQL支持中文:

[root@localhost ~]# vi /etc/my.cnf

在这里插入图片描述

character-set-server=utf8

重启服务

[root@localhost ~]# systemctl restart mariadb php-fpm

9、 部署WordPress博客
9.1、安装所需插件

[root@localhost ~]# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

9.2、解压WordPress压缩包

[root@localhost ~]# cd /opt/
[root@localhost opt]# unzip wordpress-zh_CN.zip
 

在这里插入图片描述

9.3、部署WordPress环境

[root@localhost opt]# rm -rf /usr/share/nginx/html/*
[root@localhost opt]# cp -r wordpress/* /usr/share/nginx/html/
[root@localhost opt]# chmod 777 -R /usr/share/nginx/html/wp-content/
 

在这里插入图片描述

9.4、创建数据库并设置访问权限

[root@localhost ~]# mysql -uroot -p
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '000000' with grant option;
MariaDB [(none)]> grant all privileges on *.* to root@"%" identified by '000000' with grant option;

在这里插入图片描述

9.5、浏览器访问http://IP:8080
在这里插入图片描述

9.6、配置数据库连接
在这里插入图片描述

配置数据如图
9.7、编辑wp-config.Php
出现如下图则需自己配置文件
在这里插入图片描述

路径:/usr/share/nginx/html/

[root@localhost ~]# cd /usr/share/nginx/html/

在这里插入图片描述

可以发现是没有wp-config.php文件的,需要将wp-config-sample.php复制并命名为wp-config.php 才能行。

[root@localhost html]# cp wp-config-sample.php wp-config.php

在这里插入图片描述

修改wp-config.php内容

[root@localhost html]# vim wp-config.php

在这里插入图片描述

根据下图填写上面内容
在这里插入图片描述

完成后点击进行安装
在这里插入图片描述

出现下图,
在这里插入图片描述

填写完成后进行安装。
在这里插入图片描述

登录
在这里插入图片描述
在这里插入图片描述

完成部署安装WordPress

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值