[原创]编译安装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数据库
  1. yum -y install mariadb*
  2. 启动数据库
  3. systemctl start mariadb
  4. 修改root密码
  5. grant all privileges on *.* to 'root'@'localhost' identified by "root" with grant option;
  6. grant all privileges on *.* to 'root'@'%' identified by "root" with grant option;
  7. flush privileges;
二、编译安装nginx
  1. 1、安装依赖包
  2. yum install -y pcre pcre-devel openssl openssl-devel gcc-c++
  3. 2、创建运行进程的用户
  4. groupadd nginx
  5. useradd -g nginx -s /bin/nologin nginx
  6. 3、编译安装nginx
  7. 我在这儿的软件都放在myapp目录下的
  8. tar -zxvf nginx-1.10.3.tar.gz #解压到当前目录
  9. cd nginx-1.10.3
  10. ./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
  11. make
  12. make install
  13. 4、启动nginx
  14. cd /usr/local/nginx/sbin
  15. ./nginx
  16. 5、验证:浏览器访问http://ip
三、编译安装php
  1. 1、安装依赖包
  2. yum -y install libxml2* curl curl-devel libpng-devel libpng openldap openldap-devel freetype freetype-devel libjpeg-devel libpng-devel bzip2 bzip2-devel
  3. 2、编译安装php
  4. tar -xjf php-5.5.12.tar.bz2
  5. cd php-5.5.12
  6. ./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
  7. make
  8. make test
  9. make install
  10. 3、修改php文件
  11. cp /myapp/php-5.5.12/php.ini-production /usr/local/php/etc/php.ini
  12. cp /usr/local/php/etc/php-fpm.conf.default php-fpm.conf
  13. 4、启动php
  14. /usr/local/php/sbin/php-fpm
  15. 检查启动是否成功
  16. netstat -lntp | grep php-fpm
  17. 显示 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 77087/php-fpm: mast
四、整合nginx支持php
  1. 1、修改nginx配置文件
  2. vi /usr/local/nginx/conf/nginx.conf
  3. [root@localhost conf]# cat nginx.conf | grep -v "#"
  4. user nginx nginx;
  5. worker_processes 1;
  6. events {
  7. worker_connections 1024;
  8. }
  9. http {
  10. include mime.types;
  11. default_type application/octet-stream;
  12.  
  13. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  14. '$status $body_bytes_sent "$http_referer" '
  15. '"$http_user_agent" "$http_x_forwarded_for"';
  16. access_log logs/access.log main;
  17. sendfile on;
  18. keepalive_timeout 65;
  19. server {
  20. listen 80;
  21. server_name localhost;
  22. charset utf8;
  23. location / {
  24. root html;
  25. index index.html index.htm index.php;
  26. }
  27. error_page 500 502 503 504 /50x.html;
  28. location = /50x.html {
  29. root html;
  30. }
  31. location ~ \.php$ {
  32. root html;
  33. fastcgi_pass 127.0.0.1:9000;
  34. fastcgi_index index.php;
  35. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  36. include fastcgi_params;
  37. }
  38. }
  39. 2、创建index.php文件测试
  40. cd /usr/local/nginx/html
  41. vi index.php
  42. [root@localhost html]# cat index.php
  43. <?php
  44. $link=mysql_connect("172.16.20.112","root","root");
  45. if(!$link)
  46. echo "MySQL数据库连接失败!!";
  47. else
  48. echo "MySQL数据库连接成功!!";
  49. phpinfo();
  50. ?>
  51. 保存退出
  52. chmod 775 index.php
  53. 3、验证
  54. 浏览器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. InnoDB 逻辑存储结构

    本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/80 如果创建表时没有显示的定义主键,mysql会按如下方式创建主 ...

  2. bzoj 1855: [Scoi2010]股票交易

    Description 最近lxhgww又迷上了投资股票,通过一段时间的观察和学习,他总结出了股票行情的一些规律. 通过一段时间的观察,lxhgww预测到了未来T天内某只股票的走势,第i天的股票买入价 ...

  3. 一道叉姐的AC自动机鬼题

    题面描述丢失了... 给n个串模板串,然后再给你m个串,对于这m个串的每个串,问在[L,R]的模板串中,在多少个串中出现过; 这题的正解是对于后m个串建AC自动机,然后离线,在fail树上树链求并. ...

  4. 记录一笔关于PHPEXCEL导出大数据超时和内存溢出的问题

    通过查阅资料可以找到PHPEXCEL本身已经有通过缓存来处理大数据的导出了.但是昨晚一直没有成功,这可捉急了.最后想来想去就替换了phpExcel的版本了.最后就成功了.话不多说,代码附上 <? ...

  5. override与重载(overload)的区别

    重载是相同函数名字.参数或参数类型不同,进行多次承载以适应不同的需要.(orerload)是面向过程的重载. (override)是面向对象的重载.是进行基类中的函数重写.

  6. python3 python2 import 的区别

    https://stackoverflow.com/questions/12172791/changes-in-import-statement-python3

  7. php 运行的四种模式

    1)cgi 通用网关接口(Common Gateway Interface)) CGI即通用网关接口(Common Gateway Interface),它是一段程序, 通俗的讲CGI就象是一座桥,把 ...

  8. Android studio Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to

    http://blog.csdn.net/FlyRabbit_1/article/details/74536317 Error:org.gradle.api.internal.tasks.Defaul ...

  9. ABP 框架从源码学习——abp框架启动核心类AbpBootstrapper(2)

    在AbpBootstrapper中的两个至关重要的属性:IIocManager 和 IAbpModuleManager  public class AbpBootstrapper : IDisposa ...

  10. 可视化编程开发板TurnipBit支持LED亮度可调功能

    微软的makecode编辑器更新至版本v0.12.64.新增LED的可调亮度功能.而作为中文版可视化编程的口袋计算机TurnipBit完全兼容micro:bit,同样支持LED的亮度可调功能. 该项功 ...