用源码搭建LNMP环境+部署WordPress
首先要做的是就是关闭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的更多相关文章
- 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 ...
- 在CENTOS上源码搭建LNMP环境
前言 1.操作前提: CentOS Linux release 7.5.1804: sudo用户(需要root权限): 2.需要安装的组件: nginx稳定版:nginx-1.14.0: MariaD ...
- 搭建LNMP环境部署Wordpress博客
!!!首先要做的就是关闭系统的防火墙以及selinux: #systemctl stop firewalld #systemctl disable firewalld #sed -ri 's/^(SE ...
- 源码搭建LNMP
源码安装LNMP 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 欢迎加入:高级运维工程师之路 598432640 前言:非常简单的一个平台LNMP,在生产实际环 ...
- 源码搭建lnmp平台
lnmp平台是指利用linux操作系统,nginx服务器,mysql数据库和php语言搭建高性能web服务器,负载均衡器和邮件代理服务器. 原理图:‘
- CentOS 6.5 下源码搭建LAMP环境
参考网站: http://wenku.baidu.com/link?url=Cvkqss2E9mnxXOZigMWPaCfqwsBxnm0sZ4aKE2oLAgQ888XxeC0DWOChxVqiHz ...
- 终于完成了 源码 编译lnmp环境
经过了大概一个星期的努力,终于按照海生的编译流程将lnmp环境源码安装出来了 nginx 和php 主要参考 http://hessian.cn/p/1273.html mysql 主要参考 http ...
- MyCAT源码分析——分析环境部署
为了更好地了解mycat的原理,计划对mycat源码进行通读一遍,根据实际业务环境进行相关源码优化. 一.环境描述 操作系统:windows 10 x64 软件:jdk 1.7+ maven ...
- ubuntu 源码安装 lnmp 环境
准备篇 下载软件包 1.下载nginx http://nginx.org/download/nginx-1.2.0.tar.gz 2.下载pcre (支持nginx伪静态) ftp://ftp.cs ...
随机推荐
- 翻译:《实用的Python编程》08_01_Testing
目录 | 上一节 (7.5 装饰方法 | 下一节 (8.2 日志) 8.1 测试 多测试,少调试(Testing Rocks, Debugging Sucks) Python 的动态性质使得测试对大多 ...
- vite 动态 import 引入打包报错解决方案
关注公众号: 微信搜索 前端工具人 ; 收货更多的干货 原文链接: 自己掘金文章 https://juejin.cn/post/6951557699079569422/ 关注公众号: 微信搜索 前端工 ...
- 如果要做优化,CSS提高性能的方法有哪些?
一.前言 每一个网页都离不开css,但是很多人又认为,css主要是用来完成页面布局的,像一些细节或者优化,就不需要怎么考虑,实际上这种想法是不正确的 作为页面渲染和内容展现的重要环节,css影响着用户 ...
- Pycharm Fiddler Requests https in _create raise ValueError("check_hostname requires server_hostname
打开Fiddler, 开启抓取https, 在PyCharm中使用requests 发送https请求, 遇到 in _create raise ValueError("check_ho ...
- React函数式组件的性能优化
优化思路 主要优化的方向有2个: 减少重新 render 的次数.因为在 React 里最重(花时间最长)的一块就是 reconction(简单的可以理解为 diff),如果不 render,就不会 ...
- 不推荐别的了,IDEA 自带的数据库工具就很牛逼!
MySQL 等数据库客户端软件市面上非常多了,别的栈长就不介绍了, 其实 IntelliJ IDEA 自带的数据库工具就很牛逼,不信你继续往下看. 本文以 IntelliJ IDEA/ Mac 版本作 ...
- Algorithm(4th) 1.5 union-find算法
问题描述 问题输入是一对整数对,每个整数都代表一个对象,一对整数"p,q"表示 "p与q相连"(具有自反性,传递性,对称性,被归到一个等价类里),要求编写程序来 ...
- 通过钉钉网页上的js学习xss打cookie
做完了一个项目,然后没啥事做,无意看到了一个钉钉的外部链接: 题外话1: 查看源码,复制其中的代码: try { var search = location.search; if (search &a ...
- php 一些神奇加有趣的函数
php里面神奇且又有趣的函数 这么有意思的title,我忍不住要啰嗦俩句,1--只是个人喜欢,不喜勿喷:2--仅个人笔记,未完,待续 列举 get_defined_constants:get_defi ...
- $.ajax()——超时设置
getAjax: function (method, apiUrl, options, callback) { var xhr = $.ajax({ type: method, url: apiUrl ...