前言

本篇博客使用yum来搭建lnmp环境,将采用动态,静态以及数据库分开安装的方式即nginx,php,mysql.会被分开安装在不同的服务器之上,搭建出来一套lnmp环境,并部署wordpress进行测试。

LNMP准备环境

centos7

firewalld关闭状态

selinux关闭状态

nginx服务器IP:192.168.43.174

php、php-fpm、php-mysql服务器IP: 192.168.43.175

MySQL服务器IP:192.168.43.176

LNMP搭建

第一步:php、php-fpm、php-mysql服务器搭建

下载用于和数据库通信的php-mysql,支持php文件的php以及实现fastcgi的php-fpm

[root@server ~]# yum install php-mysql php php-fpm -y

第二步:配置php-fpm文件

主要修改12行处为本机的IP地址,24行处修改为nginx端的IP地址,保证本机有apache用户

 ; Start a new pool named 'www'.
[www] ; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 192.168.43.175:9000 ##这里修改为本机的IP地址 ; Set listen() backlog. A value of '-1' means unlimited.
; Default Value: -
;listen.backlog = - ; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, conne; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
listen.allowed_clients = 192.168.43.174 ##修改为nginx端的IP地址 ; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to
;listen.owner = nobody
;listen.group = nobody
;listen.mode = ; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = apache #确保有apache用户
; RPM: Keep a group allowed to write in log dir.
group = apache #确保有apache组
...

检查是否有apache用户,如果没有需要下载httpd服务,或者自建apache用户即可

[root@server ~]# id apache
uid=(apache) gid=(apache) groups=(apache)

第三步:启动php-fpm服务

监听本机的9000端口

[root@server ~]# systemctl restart php-fpm
[root@server ~]# ss -tnl | grep
LISTEN 192.168.43.175: *:*

第四步:下载nginx

在192.168.43.174服务器上面下载nginx

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

第五步:配置nginx

添加如下一个location,fastcgi_pass执行刚才配置的php服务器端

[root@proxy ~]# vim /etc/nginx/nginx.conf
...
server {
listen ;
server_name _;
root /var/www/html;
index index.html index.php;
# Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf; location ~ \.php$ {
fastcgi_pass 192.168.43.175:9000;
include fastcgi.conf; }
....

第六步:检查nginx配置

[root@proxy ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

第七步:启动nginx

检查无误后启动nginx

[root@proxy ~]# systemctl restart nginx
[root@proxy ~]# ss -tnl | lsof -i :
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx root 6u IPv4 0t0 TCP *:http (LISTEN)
nginx nginx 6u IPv4 0t0 TCP *:http (LISTEN)

第八步:下载mysql

在mysql服务器端下载数据库

[root@agent ~]# yum install mariadb-server -y

第九步:启动数据库

[root@agent ~]# systemctl restart mariadb

第十步:建立数据库及用户

创建一个wordpress数据库,新建一个wordpress用户

[root@agent ~]# mysql -uroot -p123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> create database wordpress;
Query OK, row affected (0.06 sec) MySQL [(none)]> grant all on wordpress.* to wordpress@'%' identified by '';
Query OK, rows affected, warning (0.07 sec) MySQL [(none)]> flush privileges;
Query OK, rows affected (0.02 sec)

经过以上十步lnmp环境就已经搭建完成

LNMP环境部署wordpress进行测试

第一步:nginx服务器端准备wordpress文件

[root@proxy ~]# cd /var/www/html/
[root@proxy html]# ls
[root@proxy html]# rz
[root@proxy html]# ls
wordpress-3.3.-zh_CN.zip
[root@proxy html]# yum install unzip -y
[root@proxy html]# unzip wordpress-3.3.1-zh_CN.zip

第二步:php服务器端也要准备wordpress文件

至于为什么也要在php服务器端准备wordpress文件是因为nginx文件里面的配置,相当于动静分离架构,动态文件即php文件会来php服务器端来找

[root@server ~]# cd /var/www/html/
[root@server html]# ls
[root@server html]# rz
[root@server html]# ls
wordpress-3.3.-zh_CN.zip
[root@proxy html]# yum install unzip -y
[root@server html]# unzip wordpress-3.3.-zh_CN.zip
[root@server html]# ls
wordpress wordpress-3.3.-zh_CN.zip

第三步:浏览器测试

在浏览器输入nginx服务器的ip地址

点击创建一个配置文件

点击现在就开始

输入之前创建的数据库信息及用户信息,点击提交

提示创建失败,只能进行手工创建(nginx服务器端及php服务器端执行下面同样的操作)

[root@proxy html]# cd wordpress
[root@proxy wordpress]# cp wp-config-sample.php wp-config.php
[root@proxy wordpress]# vim wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress 数据库的名称 */
define('DB_NAME', 'wordpress'); /** MySQL 数据库用户名 */
define('DB_USER', 'wordpress'); /** MySQL 数据库密码 */
define('DB_PASSWORD', ''); /** MySQL 主机 */
define('DB_HOST', '192.168.43.176'); /** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');

再次打开浏览器进行测试

根据提示输入以上信息,点击下面的安装

输入账号和密码进行登录即可

至此LNMP服务搭建完成

Yum搭建LNMP环境(动、静、库分离)(week4_day5)--技术流ken的更多相关文章

  1. centos7 yum搭建lnmp环境及配置wordpress超详细教程

    yum安装lnmp环境是最方便,最快捷的一种方法.源码编译安装需要花费大量的人类时间,当然源码编译可以个性化配置一些其它功能.目前来说,yum安装基本满足我们搭建web服务器的需求. 本文是我根据近期 ...

  2. Centos 7 下yum搭建lnmp环境(yum安装方式)

    我们都知道linux下安装软件主要有三种方式: 1.源码编译安装,即下载软件源代码,利用gcc g++ make 等编译工具进行编译安装: 此方式的优点:可以指定软件版本,可选择性好:编译时可以手动指 ...

  3. yum 搭建lnmp环境详细步骤

    1.关闭防火墙[root@CentOS ~]# chkconfig iptables off 2.关闭selinuxvi /etc/sysconfig/selinux//将SELINUX=enforc ...

  4. CentOS6下yum搭建LNMP环境

    1.关闭防火墙[root@CentOS ~]# chkconfig iptables off 2.关闭selinuxvi /etc/sysconfig/selinux //将SELINUX=enfor ...

  5. Vmware搭建LNMP环境(Centos7+Nginx+Mysql+PHP7.1.8)

    参考:1.Linux学习之CentOS(一)----在VMware虚拟机中安装CentOS 7(图文教程) 2.Centos7搭建LNMP环境 3.MySQL5.7修改默认root密码 4.CentO ...

  6. 阿里云体验实验室 教你如何《快速搭建LNMP环境》

    ## 体验平台简介 面向开发者和中小企业打造的一站式.全云端的开发平台,打开浏览器就可以开发.调试.上线,所测即所得,并结合无服务器的模式,重新定义云原生时代的研发工作方法论.旨在降低开发者上手成本和 ...

  7. CentOS6.6搭建LNMP环境

    CentOS6.6搭建LNMP环境 1.设置yum源,本地安装依赖包 1 yum -y install gcc gcc-c++ automake autoconf libtool make 2.下载依 ...

  8. CentOS 7 源码搭建LNMP环境

    搭建 LNMP 环境 源码包版本 :  CentOS Linux  7 nginx-1.15.1.tar.gz  mysql-boost-5.7.21.tar.gz  php-7.2.7.tar.gz ...

  9. WIN10 vagrant和virtualbox虚拟机和一键搭建lnmp环境配置thinkphp虚拟主机

    版本:win10系统 virtualbox:5.1.26 vagrant :1.9.7 centos 7.0 xshell/git 首先下载好对应版本的软件 配置vagrant和virtualbox ...

随机推荐

  1. 防范 SQL 注入攻击

     防范 SQL 注入攻击 我们执行的 SQL语句中包含变量,执行的时候会直接把变量内容替换进去.而如果攻击者在输入框中输入一些危险的字符(通常包含 SQL 注释符 --,以及其他预先精心设置的内容), ...

  2. peewee基本使用

    PEEWEE基本使用 Content Ⅰ  安装Ⅱ  链接数据库Ⅲ  建表 Ⅳ  增删改 Ⅴ  基础查询 Ⅵ  ForeignKey Ⅷ  事务 参考官方文档:http://docs.peewee-o ...

  3. 本周对于java中lamdba表达式与内部进行了学习 ,以下是我在学习就中遇到的问题

    在java中,可以将一个类定义在另一个类里面或者一个方法里面,这样的类称为内部类.我觉得其实就是类的嵌套,在一个类中再定义一个类,这里已成员内部类为讲,内部类可以自由地运用外部类定义的方法,但外部类想 ...

  4. JavaScript原生实现观察者模式

    观察者模式又叫做发布订阅模式,它定义了一种一对多的关系,让多个观察者对象同时监听某一个主题对象,这个主题对象的状态发生改变时就会通知所有观察着对象. 它是由两类对象组成,主题和观察者,主题负责发布事件 ...

  5. 40个Java多线程面试问题

    1. 多线程有什么用? 一个可能在很多人看来很扯淡的一个问题:我会用多线程就好了,还管它有什么用?在我看来,这个回答更扯淡.所谓"知其然知其所以然","会用"只 ...

  6. 2.AsyncQueryHandler、内容提供者

    会话页面 Test :测试 public class Test extends AndroidTestCase{ public void test(){ Uri uri = Uri.parse(&qu ...

  7. vue组件推荐

    Vue 是一个轻巧.高性能.可组件化的MVVM库,API简洁明了,上手快.从Vue推出以来,得到众多Web开发者的认可.在公司的Web前端项目开发中,多个项目采用基于Vue的UI组件框架开发,并投入正 ...

  8. linux中修改字符编码

    一. ubuntu修改字符编码 1. 添加字符编码,例如zh_CN.UTF-8,有两种方式 方法1:locale-gen zh_CN.UTF-8   #locale-gen命令只在ubuntu中才有 ...

  9. [原创]K8Cscan插件之Mysql密码爆破

    [原创]K8 Cscan 大型内网渗透自定义扫描器 https://www.cnblogs.com/k8gege/p/10519321.html Cscan简介:何为自定义扫描器?其实也是插件化,但C ...

  10. 使用 SharpZipLib 打包数据到 ZIP 文件

    SharpZipLib 是一个优秀的开源的第三方压缩库,可以通过这个库将一些导出的文件打包到一个 ZIP 文件当中供用户下载. GitHub 地址:https://github.com/icsharp ...