[原创]编译安装lnmp环境

准备软件:nginx1.10.3+php-5.5.12+mariadb10.0.8(数据库在此使用的yum安装)

mariadb10.0.8数据库的编译安装地址:http://www.cnblogs.com/JeremyWYL/p/7251435.html

依赖包均已yum在线安装

一、yum安装mariadb数据库
yum -y install mariadb*
启动数据库
systemctl start mariadb
修改root密码
grant all privileges on *.* to 'root'@'localhost' identified by "root" with grant option;
grant all privileges on *.* to 'root'@'%' identified by "root" with grant option;
flush privileges;
二、编译安装nginx
1、安装依赖包
yum install -y pcre pcre-devel openssl openssl-devel gcc-c++
2、创建运行进程的用户
groupadd nginx
useradd -g nginx -s /bin/nologin nginx
3、编译安装nginx
我在这儿的软件都放在myapp目录下的
tar -zxvf nginx-1.10.3.tar.gz #解压到当前目录
cd nginx-1.10.3
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-pcre --with-http_gzip_static_module --without-http_gzip_module --with-http_stub_status_module
make
make install
4、启动nginx
cd /usr/local/nginx/sbin
./nginx
5、验证:浏览器访问http://ip
三、编译安装php
1、安装依赖包
yum -y install libxml2* curl curl-devel libpng-devel libpng openldap openldap-devel freetype freetype-devel libjpeg-devel libpng-devel bzip2 bzip2-devel
2、编译安装php
tar -xjf php-5.5.12.tar.bz2
cd php-5.5.12
./configure -prefix=/usr/local/php --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local/ --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64
make
make test
make install
3、修改php文件
cp /myapp/php-5.5.12/php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default php-fpm.conf
4、启动php
/usr/local/php/sbin/php-fpm
检查启动是否成功
netstat -lntp | grep php-fpm
显示 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 77087/php-fpm: mast
四、整合nginx支持php
1、修改nginx配置文件
vi /usr/local/nginx/conf/nginx.conf
[root@localhost conf]# cat nginx.conf | grep -v "#"
user nginx nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream; 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 logs/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
charset utf8;
location / {
root html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
2、创建index.php文件测试
cd /usr/local/nginx/html
vi index.php
[root@localhost html]# cat index.php
<?php
$link=mysql_connect("172.16.20.112","root","root");
if(!$link)
echo "MySQL数据库连接失败!!";
else
echo "MySQL数据库连接成功!!";
phpinfo();
?>
保存退出
chmod 775 index.php
3、验证
浏览器http://IP/index.php

Centos7环境搭建lnmp环境的更多相关文章

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

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

  2. centos7 简单搭建lnmp环境

    1:查看环境: 1 2 [root@10-4-14-168 html]# cat /etc/redhat-release CentOS release 6.5 (Final) 2:关掉防火墙 1 [r ...

  3. CentOS7快速搭建LNMP环境

    名词解释: LNMP:Linux+Nginx+MySql+PHPLAMP:LInux+Apache+MySql+PHPNginx的正确读法应该是Engine X我们使用CentOS自带的YUM来安装 ...

  4. centos7下面搭建lnmp环境

    参考大神博客: http://www.linuxzen.com/lnmphuan-jing-da-jian-wan-quan-shou-ce-si-lnmpda-jian-yuan-ma-an-zhu ...

  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. CentOS7——搭建LNMP环境(WordPress案例)

    CentOS7--搭建LNMP环境(WordPress案例) LNMP组成介绍 LNMP(Linux-Nginx-MySQL-PHP)网站架构是目前国际流行的Web框架,该框架包括:Linux操作系统 ...

  7. Yum搭建LNMP环境(动、静、库分离)(week4_day5)--技术流ken

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

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

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

  9. Docker之使用Docker-compose搭建LNMP环境

    之前有随笔介绍使用Docker-compose搭建LNMP环境(centos6 php5.6) https://www.cnblogs.com/minseo/p/10146982.html 本文介绍D ...

随机推荐

  1. Spring入门篇总结:

    本文是对慕课网上"搞定SSM开发"路径的系列课程的总结,详细的项目文档和课程总结放在github上了.点击查看 视频传送门:Spring入门篇 该门课程主要从Spring的Bean ...

  2. Java中的UDP应用

    我在<JavaSE项目之聊天室>中通过遵守TCP协议的ServerSocket与Socket实现了聊天室的群聊窗口.同时,在介绍OSI与TCP/IP参考模型时,也曾提及TCP与UDP(全称 ...

  3. Ubuntu Nginx 开机自启动

    #! /bin/sh # chkconfig: 2345 55 25 # Description: Startup script for nginx webserver on Debian. Plac ...

  4. lesson - 3 ls /cd /path /alias /快捷键

    内容概要: 1. 命令ls -l   详细信息-a  查看隐藏的文件或目录-d   只看目录本身,不列出目录下面的文件和目录-t 以时间先后排序 2  目录结构/bin, /sbin, /usr/bi ...

  5. js解析xml浏览器兼容性处理

    /****************************************************************************** 说明:xml解析类 ********** ...

  6. android之monkey测试

    本文同时发表于本人个人网站 www.yaoxiaowen.com monkey测试算是android自动化测试当中最简单的一种工具了.虽然简单,不过对于测试app的稳定健壮,减少崩溃还是比较有用的.所 ...

  7. 淘宝NPM源的使用

    npm作为国外的node仓库安装工具,自然会受到我大长城防火墙的干扰,国内用户在安装相关的资源的时候,会出现安装失败,以及速度很慢的情况.为了解决npm安装的问题,国内出现了很多npm的镜像网址,ta ...

  8. Head First设计模式之装饰者模式

    一.定义 装饰者模式,英文叫Decorator Pattern,在不必改变原类文件和使用继承的情况下,动态地扩展一个对象的功能.它是通过创建一个包装对象,也就是装饰来包裹真实的对象. 动态将职责附加到 ...

  9. Jenkins 学习笔记(三):我们的JAVA 项目是这么发布的

    发布拓扑 1. 拓扑图 2. 流程说明: Git 插件从 Git Server 上面拉取源代码. Maven 插件将源代码安装我们设定的指令进行编译打包,存放于项目的 WorkSpace. Publi ...

  10. 纯css提示效果 提示层

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD xHTML 1.0 Transitional//EN"><HTML> <HEAD ...