首先要做的是就是关闭Centos7.4的防火墙及selinux

#systemctl stop firewalld
#systemctl disable firewalld
#sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
#setenforce 0 \\临时启用

一:用源码安装nginx:

1、首先安装nginx的编译环境:

#yum -y install make zlib zlib-devel gcc gcc-c++ libtool openssl openssl-devel autoconf

2、下载并解压nginx:

#wget http://mirrors.sohu.com/nginx/nginx-1.6.1.tar.gz
#tar -zxvf nginx-1.6.1.tar.gz

3、预编译 nginx:

#cd /root/nginx-1.6.1
#./configure --prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scg--with-pcre

  预编译成功,会出现如下的提示信息:

4、创建/var/tmp/nginx/client/目录:

#mkdir -p /var/tmp/nginx/client

5、编译安装nginx:

#cd /root/nginx-1.6.1
#make && make install

  编译安装完成没有报错,说明安装成功

6、创建给nginx使用的nginx用户以及组

#groupadd -r nginx               #创建一个系统账户
#useradd -r -g nginx nginx #创建一个系统账户,所属组为nginx

7、在/usr/local/nginx/nginx.conf  目录下修改以下内容

[root@localhost ~]vim /usr/loca/nginx/nginx.conf
//添加 index.php:
location / {
root /usr/local/nginx/html;
index index.php index.html index.htm; (红色部分是需要添加的内容)       
} //修改:①、先去掉一下部分内容前面的注释“#”;②、将php-fpm所指的目录指向nginx的工作目录
location ~ \.php$ {
root /usr/local/nginx/html; (此路径是绝对路径,应该与 nginx 工作目录的路径一致)
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name; include fastcgi_params;
        }

8、启动nginx服务:

#/usr/local/nginx/sbin/nginx          \\启动nginx服务
#/usr/local/nginx/sbin/nginx -s reload   \\重新载入配置
#/usr/local/nginx/sbin/nginx -s reopen   \\重启nginx服务
#/usr/local/nginx/sbin/nginx -s stop    \\停止nginx服务

9、测试nginx首页

  在浏览器的地址栏输入自己主机的IP地址:例如:192.168.1.1,就会出现如下界面

二、安装数据库(mariadb-server)

1、用yum安装mariadb-server

#yum install –y mariadb-server mariadb
#systemctl start mariadb
#systemctl enable mariadb

2、数据库初始化

#mysql_secure_installation
或者
#mysqladmin –u root password ‘password’

3、进入数据库,创建等会要用的WordPress的数据库

#mysql -u root -p    #输入密码
MariaDB [(none)]> create database wordpressdb;
MariaDB [(none)]> create user wordpress@localhost identified by '123456';
MariaDB [(none)]> grant all privileges on wordpressdb.* to wordpress@localhost;
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

三、用源码安装PHP7的版本

1、安装epel和webtatic扩展包

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2、安装PHP编译环境

#yum install -y mcrypt mhash libxml2-devel openssl-devel bzip2-devel curl-devel libmcrypt-devel readline-devel systemtap-sdt-devel libjpeg-devel libpng-devel freetype-devel

3、下载PHP并且解压

#wget http://mirrors.sohu.com/php/php-7.0.10.tar.gz
#tar -zxvf php-7.0.10.tar.gz

4、预编译PHP

#cd php-7.0.10
./configure --prefix=/usr/local/php
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/usr/local/mysql/commondir/mysql.sock \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--enable-soap \
--enable-gd-native-ttf \
--enable-ftp \
--enable-mbstring \
--enable-exif \
--with-pear \
--with-curl \
--with-openssl

  预编译出现以下提示信息,就预编译成功:

 

5、编译安装PHP7

#cd /root/php-7.0.10
#make && make install

  编译安装过程没有报错,代表安装成功

6、修改 php-fpm.conf.default 为 php-fpm.conf,并编辑 php-fpm.conf 里面的部分内容

#cd /usr/local/php/etc
#mv php-fpm.conf.default php-fpm.conf
#vim php-fpm.conf
pid = run/php-fpm.pid #去掉前面的分号(;)

7、 修改 www.conf.default 为 www.conf

#cd /usr/local/php/php-fpm.d
#cp -a www.conf.default www.conf

8、复制 php.ini 配置文件

#cd /root/php-7.0.10
#cp -a php.ini-production /usr/local/php/etc/php.ini

9、复制 php-fpm 启动脚本到 init.d,并赋予执行权限

#cp -a sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#chmod u+x /etc/init.d/php-fpm

10、给PHP创建 www 群组和 www 用户 

#groupadd -r www                     #创建一个系统账户
#useradd -r -g www www  #创建一个系统账户,所属组为www

11、启动 php-fpm

#/etc/init.d/php-fpm start  

四、在nginx的工作目录首页编辑一个测试PHP的首页,判断nginx是否支持解析PHP

1、在 nginx 的工作目录下,编辑测试 PHP 文件 test.php(测试文件名可以随意,但是必须是以“.php”结尾的文件)

#cd /usr/local/nginx/html/
#vim test.php
<?php
phpinfo();
?>

2、在浏览器地址栏输入:IP/test.php

例如:192.168.1.1/test.php;就会看到如下的PHP测试首页

五、LNMP环境已经搭建成功,下面就可以开始上传WordPress了

1、下载解压 wordoress

wget https://wordpress.org/latest.tar.gz
tar –zxvf latest.tar.gz

2、将wordpress里面所有内容移到/usr/local/nginx/html 目录下

mv /root/wordpress/* /usr/local/nginx/html

3、将 wp-config-sample.php 更换成 wp-config.php,并修改以下内容

#cd /usr/local/nginx/html
#mv wp-config-sample.php wp-config.php
#vim wp-config.php
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpressdb' ); \\数据库名
/** MySQL database username */
define( 'DB_USER', 'wordpress' ); \\数据用户名
/** MySQL database password */
define( 'DB_PASSWORD', '123456' ); \\数据库密码

4、将/usr/local/nginx/html  下的所有文件的用户改为root用户

#chown -R root:root /usr/local/nginx/html

5、在浏览器地址栏输入自己主机的IP地址,即可出现wordpress安装界面

扩展【 https://www.runoob.com/linux/nginx-install-setup.html   源码安装Nginx】

用源码搭建LNMP环境+部署WordPress的更多相关文章

  1. 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 ...

  2. 在CENTOS上源码搭建LNMP环境

    前言 1.操作前提: CentOS Linux release 7.5.1804: sudo用户(需要root权限): 2.需要安装的组件: nginx稳定版:nginx-1.14.0: MariaD ...

  3. 搭建LNMP环境部署Wordpress博客

    !!!首先要做的就是关闭系统的防火墙以及selinux: #systemctl stop firewalld #systemctl disable firewalld #sed -ri 's/^(SE ...

  4. 源码搭建LNMP

      源码安装LNMP 作者:尹正杰   版权声明:原创作品,谢绝转载!否则将追究法律责任.       欢迎加入:高级运维工程师之路 598432640 前言:非常简单的一个平台LNMP,在生产实际环 ...

  5. 源码搭建lnmp平台

    lnmp平台是指利用linux操作系统,nginx服务器,mysql数据库和php语言搭建高性能web服务器,负载均衡器和邮件代理服务器. 原理图:‘

  6. CentOS 6.5 下源码搭建LAMP环境

    参考网站: http://wenku.baidu.com/link?url=Cvkqss2E9mnxXOZigMWPaCfqwsBxnm0sZ4aKE2oLAgQ888XxeC0DWOChxVqiHz ...

  7. 终于完成了 源码 编译lnmp环境

    经过了大概一个星期的努力,终于按照海生的编译流程将lnmp环境源码安装出来了 nginx 和php 主要参考 http://hessian.cn/p/1273.html mysql 主要参考 http ...

  8. MyCAT源码分析——分析环境部署

    为了更好地了解mycat的原理,计划对mycat源码进行通读一遍,根据实际业务环境进行相关源码优化. 一.环境描述 操作系统:windows 10 x64 软件:jdk 1.7+   maven   ...

  9. ubuntu 源码安装 lnmp 环境

    准备篇 下载软件包 1.下载nginx http://nginx.org/download/nginx-1.2.0.tar.gz 2.下载pcre  (支持nginx伪静态) ftp://ftp.cs ...

随机推荐

  1. Echarts概述

    1. Echarts概述 ECharts是百度开源的纯 Javascript 图表库,目前开源可以与highcharts相匹敌的一个图表库.支持折线图(区域图).柱状图(条状图).散点图(气泡图).K ...

  2. [Fundamental of Power Electronics]-PART I-3.稳态等效电路建模,损耗和效率-3.4 如何获得模型的输入端口

    3.4 如何获得模型的输入端口 Fig 3.16 Buck converter example 让我们尝试使用3.3.3节的步骤来推导图3.16所示的Buck变换器的模型.电感绕组电阻同样由串联电阻\ ...

  3. php添加excel更新数据表数据

    公司有个需求,是用excel更新数据的,把错误的行列放到一个数组返回出来,正常的数据则插入,且返回数量 1.先需要引入phpspreadsheet,这里使用composer 安装 composer r ...

  4. Leedcode算法专题训练(搜索)

    BFS 广度优先搜索一层一层地进行遍历,每层遍历都是以上一层遍历的结果作为起点,遍历一个距离能访问到的所有节点.需要注意的是,遍历过的节点不能再次被遍历. 第一层: 0 -> {6,2,1,5} ...

  5. 利用查询条件对象,在Asp.net Web API中实现对业务数据的分页查询处理

    在Asp.net Web API中,对业务数据的分页查询处理是一个非常常见的接口,我们需要在查询条件对象中,定义好相应业务的查询参数,排序信息,请求记录数和每页大小信息等内容,根据这些查询信息,我们在 ...

  6. win10美化,让你的win10独一无二,与众不同!

    2020.06.23 更新 1 原则 美化之前,得先有一个目标对不对,笔者是一个喜欢简单的人,因此美化本着三大原则:简单,干净,整洁. 呃....好像很抽象的样子,上图吧.反正没图没真相. 怎么样,还 ...

  7. Knight Moves UVA - 439

    A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the sh ...

  8. Tree UVA - 548

      You are to determine the value of the leaf node in a given binary tree that is the terminal node o ...

  9. Day09_43_Set集合_HashSet_02(HashCode方法 与 equals方法 )

    HashSet - 向Hash表中添加元素的过程? 1. 先调用将要被存储的值key的HashCode方法得出Hash值,如果该Hash值在现有Hash表中不存在,那么直接加入元素. 2. 如果该Ha ...

  10. Python 面像对象编程(上)

    一: 对象的概念 "面向对象"的核心是"对象"二字,而对象的精髓在于"整合",什么意思? 所有的程序都是由"数据"与&q ...