lnmp环境搭建(centos6.9+mysql5.7+php7.1+nginx1.10)
安装前准备:CentOS 6.9 64位 最小化安装
yum install -y make gcc gcc-c++ perl zlib-devel libaio libpng libpng-devel libjpeg-devel pcre-devel
yum install -y libXpm-devel openssl openssl-devel libxml2-devel bzip2-devel.x86_64 libjpeg-turbo-devel
yum install -y freetype freetype-devel libtool cmake ncurses-devel bison re2c curl-devel wget
rpm -ivh "http://mirrors.sohu.com/fedora-epel/epel-release-latest-6.noarch.rpm"
yum install -y libmcrypt-devel re2c
一、安装MySql
mysql的安装请参考LAMP环境搭建(centos6.9+apache2.4+mysql5.7+php7.1)和里面的安装方法一样。
二、php安装
下载php安装包并解压进入
cd /usr/local/src
wget http://mirrors.sohu.com/php/php-7.1.3.tar.gz
tar zxvf php-7.1.3.tar.gz
cd php-7.1.3
编译
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=nobody \
--with-fpm-group=nobody \
--with-mysql-sock=/tmp/mysql.sock \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-libxml-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-iconv-dir \
--with-zlib-dir \
--with-bz2 \
--with-openssl \
--with-mcrypt \
--enable-soap \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-sockets \
--enable-exif \
--disable-ipv6
安装
make && make install
复制配置文件
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/src/php-7.1.3/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp -v /usr/local/php/etc/{php-fpm.conf.default,php-fpm.conf}
cp -v /usr/local/php/etc/php-fpm.d/{www.conf.default,www.conf}
vi /usr/local/php/etc/php-fpm.d/www.conf 修改 (如果user和group在编译参数里设置了,这里就不用修改了)
user = nobody
group = nobody
修改php.ini
vi /usr/local/php/etc/php.ini
date.timezone = Asia/Chongqing
授权添加进服务并启动
chmod 755 /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start
三、安装nginx
下载nginx安装包解压并进入目录
cd /usr/local/src
yum install -y pcre-devel
wget http://mirrors.sohu.com/nginx/nginx-1.10.3.tar.gz
tar zxvf nginx-1.10.3.tar.gz
cd nginx-1.10.3
编译并安装
./configure --prefix=/usr/local/nginx --with-pcre
make && make install
vi /etc/init.d/nginx
把nginx脚本(在最下面复制nginx启动脚本)保存为 /etc/init.d/nginx,找到下面三行
nginx="/usr/sbin/nginx"
pidfile="/var/run/${prog}.pid"
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
修改为:
nginx="/usr/local/nginx/sbin/nginx"
pidfile="/usr/local/nginx/logs/${prog}.pid"
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
保存后,执行以下命令设置开机启动以及启动服务
chmod +x /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
/etc/init.d/nginx start
五、配置解析php
vi /usr/local/nginx/conf/nginx.conf
找到
location / {
root html;
index index.html index.htm;
}
改成
location / {
root html;
index index.html index.htm index.php;
}
找到
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
改成
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
测试nginx配置文件是否正确
/usr/local/nginx/sbin/nginx -t
重新加载配置文件
/etc/init.d/nginx reload
测试解析php
vi /usr/local/nginx/html/1.php
写入:
<?php
echo "php解析正常";
echo phpinfo();
?>
保存后,继续测试:
curl localhost/1.php
查看结果已经可以成功解析。
ngnix启动脚本
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
sysconfig="/etc/sysconfig/$prog"
lockfile="/var/lock/subsys/nginx"
pidfile="/var/run/${prog}.pid"
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f $sysconfig ] && . $sysconfig
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest_q || return 6
stop
start
}
reload() {
configtest_q || return 6
echo -n $"Reloading $prog: "
killproc -p $pidfile $prog -HUP
echo
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
configtest_q() {
$nginx -t -q -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
# Upgrade the binary with no downtime.
upgrade() {
local oldbin_pidfile="${pidfile}.oldbin"
configtest_q || return 6
echo -n $"Upgrading $prog: "
killproc -p $pidfile $prog -USR2
retval=$?
sleep 1
if [[ -f ${oldbin_pidfile} && -f ${pidfile} ]]; then
killproc -p $oldbin_pidfile $prog -QUIT
success $"$prog online upgrade"
echo
return 0
else
failure $"$prog online upgrade"
echo
return 1
fi
}
# Tell nginx to reopen logs
reopen_logs() {
configtest_q || return 6
echo -n $"Reopening $prog logs: "
killproc -p $pidfile $prog -USR1
retval=$?
echo
return $retval
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest|reopen_logs)
$1
;;
force-reload|upgrade)
rh_status_q || exit 7
upgrade
;;
reload)
rh_status_q || exit 7
$1
;;
status|status_q)
rh_$1
;;
condrestart|try-restart)
rh_status_q || exit 7
restart
;;
*)
echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}"
exit 2
esac
lnmp环境搭建(centos6.9+mysql5.7+php7.1+nginx1.10)的更多相关文章
- 阿里云(ECS)Centos服务器LNMP环境搭建
阿里云( ECS ) Centos7 服务器 LNMP 环境搭建 前言 第一次接触阿里云是大四的时候,当时在校外公司做兼职,关于智能家居项目的,话说当时俺就只有一个月左右的 php 后台开发经验(还是 ...
- LNMP环境搭建哈哈
经过一番折腾,终于将LNMP环境搭建完成了.本文介绍的LNMP环境是在windows的Oracle VM VirtualBox中的Centos虚拟机上搭建的,各个软件的版本为:Centos7 + Ng ...
- zabbix学习(一)——LNMP环境搭建及zabbix安装
第一部分:LNMP环境搭建 一.环境说明: OS: centos7.6_x64nginx:nginx-1.16.0php: php-7.1.11mysql:mysql-5.6.44 zabbi ...
- LNMP环境搭建
LNMP环境搭建 Linux + Nginx + MySQL + PHP PHP是一种脚本语言,当前中国乃至世界上使用PHP语言开发的网站非常普遍 Nginx是一个web服务软件,和apache是一类 ...
- LNMP环境搭建:Nginx安装、测试与域名配置
Nginx作为一款优秀的Web Server软件同时也是一款优秀的负载均衡或前端反向代理.缓存服务软件 2.编译安装Nginx (1)安装Nginx依赖函数库pcre pcre为“perl兼容正则表达 ...
- LNMP环境搭建——MySQL篇
The world's most popular open source database 1.Install MySQL root@kallen:~# apt-get install mysql-s ...
- LNMP环境搭建之php安装,wordpress博客搭建
LNMP环境搭建之php安装,wordpress博客搭建 一.介绍: 1.什么是CGI CGI全称是"通用网关接口"(Common Gateway Interface),HTTP服 ...
- Ubuntu16.04 lnmp 环境搭建
Ubuntu16.04 lnmp 环境搭建 nginx 安装 sudo apt-add-repository ppa:nginx/stablesudo apt-add-repository ppa:o ...
- LNMP环境搭建之编译安装指南(php-5.3.27.tar.gz)
测试环境:CentOS release 6.5 (Final) 软件安装:nginx mysql-5.5.32-linux2.6-x86_64.tar.gz php-5.3.27.tar.gz ...
随机推荐
- css属性之flex属性
flex属性 规定了弹性元素如何伸长或缩短以适应flex容器中的可用空间.是一个简写属性,可以同时设置flex-grow, flex-shrink, flex-basis三个子属性. /* Basic ...
- 由JDK源码学习HashMap
HashMap基于hash表的Map接口实现,它实现了Map接口中的所有操作.HashMap允许存储null键和null值.这是它与Hashtable的区别之一(另外一个区别是Hashtable是线程 ...
- Java基础知识强化之多线程笔记07:同步、异步、阻塞式、非阻塞式 的联系与区别
1. 同步: 所谓同步,就是在发出一个功能调用时,在没有得到结果之前,该调用就不返回.但是一旦调用返回,就必须先得到返回值了. 换句话话说,调用者主动等待这个"调用"的结果. 对于 ...
- 【小M的作物】
这是一道我好像没写过的最小割 这道题如果没有那\(m\)条限制,我们完全可以贪心来做 但是硬要用网络流怎么办 可以转化为最小割模型 我们将源点\(S\)表示为耕地\(A\),汇点\(T\)表示为耕地\ ...
- WAPM环境配置(PHP入门2)
WAMP介绍 W:Window:开源免费 A:Apache:开源免费 M:MySQL:开源免费 P:PHP:开源免费 Apache下载 Apache下载地址:https://www.apachehau ...
- LINUX升级PHP版本至5.4.26
参考网址:http://www.itbulu.com/wdcp-php54.html文件:链接:http://pan.baidu.com/s/1slbbNxr 密码:s0yb 1.运行下载PHP版本文 ...
- 12c数据库重启后自动启动pdb
由于最近管理12c数据库,创建了9个新的pdb.相对于以前11g版本每天一个一个的环境检查,方便了很多. 但是因为一次意外宕机,数据库重启.虽然数据库重启,但是管理的pdb确不能自动重启,所以需要手动 ...
- angular路由传参和获取路由参数的方法
1.首先是需要导入的模块 import { Router } from "@angular/router";//路由传参用到 import{ActivatedRoute,Param ...
- vue+echarts实现可拖动节点的折现图(支持拖动方向和上下限的设置)
本篇文档主要是利用echarts实现可拖动节点的折现图,在echarts中找到了一个demo,传送门:https://echarts.baidu.com/examples/editor.html?c= ...
- CentOS6安装各种大数据软件 第十章:Spark集群安装和部署
相关文章链接 CentOS6安装各种大数据软件 第一章:各个软件版本介绍 CentOS6安装各种大数据软件 第二章:Linux各个软件启动命令 CentOS6安装各种大数据软件 第三章:Linux基础 ...