简介:

Lnmp 环境的搭建还是非常简单的,之前由于博客迁移等原因,导致丢失了好多博文,这次重新整理记录一下。

Lnmp 即:Linux 、Nginx 、Mysql 、PHP

Lnmp 是一套 Web 环境,Linux 作为底层操作系统,Nginx 提供 web 服务,Mysql 提供数据库服务,PHP 负责解析 PHP 代码。

强烈建议宿主机内存大于、等于 1G ,否则建议还是安装低版本的 Mysql 跟 PHP !!!

一、Nginx

下载地址:http://nginx.org/download/nginx-1.8.0.tar.gz # 现在最新稳定版已经发展到了 1.8.0

shell > yum -y install gcc gcc-c++ make wget zlib-devel pcre-devel openssl-devel

shell > wget http://nginx.org/download/nginx-1.8.0.tar.gz

shell > tar zxf nginx-1.8..tar.gz
shell > cd nginx-1.8.
shell > ./configure --prefix=/usr/local/nginx ; make ; make install # --prefix 参数指定 Nginx 安装路径 shell > /usr/local/nginx/sbin/nginx # 启动 Nginx
shell > netstat -anpt | grep nginx # 确认是否启动
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx shell > curl -I http://127.0.0.1 # 访问成功
HTTP/1.1 OK
Server: nginx/1.8.
Date: Fri, Aug :: GMT
Content-Type: text/html
Content-Length:
Last-Modified: Fri, Aug :: GMT
Connection: keep-alive
ETag: "55c49ed6-264"
Accept-Ranges: bytes shell > iptables -I INPUT -p tcp --dport -j ACCEPT
shell > service iptables save

## 至此 Nginx 就可以外网通过浏览器访问了

二、Mysql ( 传送门:http://www.cnblogs.com/wangxiaoqiangs/p/5336048.html )

三、PHP

下载地址:http://cn2.php.net/distributions/php-5.6.11.tar.gz

shell > yum -y install epel-release
shell > yum -y install gd-devel libtool libjpeg-devel libpng-devel freetype-devel libxml2-devel zlib-devel bzip2-devel libcurl-devel libxslt-devel openssl-devel glibc-devel glib2-devel libmcrypt-devel shell > wget http://cn2.php.net/distributions/php-5.6.11.tar.gz shell > tar zxf php-5.6..tar.gz
shell > cd php-5.6.
shell > ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php \
--with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-gd --with-xsl --with-bz2 --with-zlib --with-curl --with-pear --without-iconv --with-mcrypt \
--with-gettext --with-openssl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir \
--with-libdir=lib64 --enable-ftp --enable-fpm --enable-exif --enable-soap --enable-bcmath --enable-calendar \
--enable-sockets --enable-mbstring --enable-gd-native-ttf --disable-rpath --disable-debug

# 这堆参数怎么说呢: 你也不必太在意,能解决大多数需求,有几个需要解释一下
# --prefix= 指定安装路径
# --with-config-file-path 指定 php.ini 存放位置
# --with-mysql 指定 Mysql 安装路径
# --enable-fpm Nginx 连接 php 全靠这个东西,如果没有它,你的 Nginx 就不能解析 php

shell > make ; make install

shell > cp /usr/local/src/php-5.6./php.ini-production /usr/local/php/php.ini

shell > cp /usr/local/src/php-5.6./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
shell > chmod a+x /etc/init.d/php-fpm shell > cat /usr/local/php/etc/php-fpm.conf.default > /usr/local/php/etc/php-fpm.conf shell > chkconfig --add php-fpm # 加入开机启动
shell > chkconfig --level php-fpm on shell > service php-fpm start # 启动 php-fpm
shell > netstat -anpt | grep php-fpm
tcp 127.0.0.1: 0.0.0.0:* LISTEN /php-fpm

四、让 Nginx 支持 PHP

shell > vim /usr/local/nginx/conf/nginx.conf # 修改配置文件,使其可以解析 PHP

server {
listen ;
server_name localhost; location / {
root html;
index index.php index.html index.htm; # 加入 index.php
} error_page /50x.html;
location = /50x.html {
root html;
} location ~ \.php$ { # 整段注释去掉
root html;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; # 修改为自己的根目录
include fastcgi_params;
}
}

# 当然,这只是让 Nginx 支持 PHP 而已,实际工作中可以还有更多的配置

## 创建测试页面 ( echo "<?php phpinfo(); ?>" > /usr/local/nginx/html/info.php ) , 重启 Nginx 、php-fpm 放问测试!( 好久前测试记得需要 iptables -I INPUT -i io -j ACCEPT )

五、报错汇总:( 记录一些常见的错误及解决方法 )

1、没有安装 gcc 导致报错 ( yum -y install gcc )

checking for OS
+ Linux 2.6.-.el6.x86_64 x86_64
checking for C compiler ... not found ./configure: error: C compiler cc is not found

2、没有安装 pcre-devel 导致报错 ( yum -y install pcre-devel )

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

3、没有安装 zlib-devel 导致报错 ( yum -y install zlib-devel )

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

# 上面是关于 Nginx 的报错

4、没有安装 gcc-c++ 导致报错 ( yum -y install gcc-c++ )

CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.

# 上面是关于 Mysql 的报错

5、没有安装 libxml2-devel 导致报错 ( yum -y install libxml2-devel )

configure: error: xml2-config not found. Please check your libxml2 installation.

6、没有安装 bzip2-devel 导致报错 ( yum -y install bzip2-devel )

configure: error: Please reinstall the BZip2 distribution

7、没有安装 libcurl-devel 导致报错 ( yum -y install libcurl-devel )

configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/

8、没有安装 libjpeg-devel 导致报错 ( yum -y install libjpeg-devel )

configure: error: jpeglib.h not found.

9、没有安装 libpng-devel 导致报错 ( yum -y install libpng-devel )

configure: error: png.h not found.

10、没有安装 freetype-devel 导致报错 ( yum -y install freetype-devel )

configure: error: freetype-config not found.

11、没有安装 libmcrypt-devel 导致报错 ( yum -y install epel-release ; yum -y install libmcrypt-devel )

configure: error: mcrypt.h not found. Please reinstall libmcrypt.

12、找不到 libmysqlclient.so.18 导致报错 ( ln -s /usr/local/mysql/lib /usr/local/mysql/lib64 )

configure: error: Cannot find libmysqlclient under /usr/local/mysql/.
Note that the MySQL client library is not bundled anymore!

13、跟上一个错误有连带性,我猜的 ( ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/ )

configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no

14、没有安装 libxslt-devel 导致报错 ( yum -y install libxslt-devel )

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1. distribution

Lnmp 源码编译安装、常见错误整理的更多相关文章

  1. LNMP源码编译安装(centos7+nginx1.9+mysql5.6+php7)

    1.准备工作: 1)把所有的软件安装在/Data/apps/,源码包放在/Data/tgz/,数据放在/Data/data,日志文件放在/Data/logs,项目放在/Data/webapps, mk ...

  2. Android 源码编译及常见错误及解决方法

    最近要往arm开发板上移植android系统,大大小小的问题遇到了太多太多,都是泪啊.本人初接触嵌入式开发,对问题的根源不是太了解,不过好在每解决一个问题,便记录一下.话不多说,正式罗列问题: hos ...

  3. LNMP源码编译安装

    思路:根据Linux系统以及公司网站系统的信息,选择合适的安装包进行安装 一.查看系统信息 # uname -a                        # 查看内核/操作系统/CPU信息 # ...

  4. lnmp源码编译安装zabbix

    软件安装 Mysql 安装 tar xf mysql-5.7.13-1.el6.x86_64.rpm-bundle.tar -C mysql rpm -e --nodeps  mysql-libs-5 ...

  5. centos7源码编译安装lamp/lnmp

    centos7源码编译安装lamp/lnmp 进程:是包工头(相当于是个门,只管开门关门,不管门内的事儿) 线程:是各种工种(cpu调度的是线程) 进程 是一件事情, 线程 是 同一个时间范围内 同时 ...

  6. CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境

    CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境 什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/ ...

  7. WordPress安装篇(5):源码编译安装LNMP并部署WordPress

    与YUM方式安装相比,源码编译安装方式更灵活,安装过程中能自定义功能和参数,特别是在批量部署服务器又要求软件版本及配置一致时,源码编译安装的优势很明显.本文介绍如何通过源码编译方式安装Nginx1.1 ...

  8. LNMP架构——源码编译安装

    LNMP架构--源码编译安装 1.编译安装nginx服务 2.编译安装mysql服务 3.编译安装php解析环境 1.编译安装nginx服务: systemctl stop firewalld sys ...

  9. 源码编译安装lnmp环境

    一.源码编译安装步骤 首先说明源码安装的好处   速度快,可自定义路径 主要有三步:1.配置 进入源码安装包  ./configure --prefix=/uer/local/nginx  可指定参数 ...

随机推荐

  1. Java并发--Thread类详情

    以下是本文的目录大纲: 一.线程的状态 二.上下文切换 三.Thread类中的方法 转载原文链接:http://www.cnblogs.com/dolphin0520/p/3920357.html 一 ...

  2. (C#)if (this == null)?你在逗我,this 怎么可能为 null!用 IL 编译和反编译看穿一切

    if (this == null) Console.WriteLine("this is null"); 这句话一写,大家一定觉得荒谬,然而 if 内代码的执行却是可能的!本文讲介 ...

  3. hadoop2.x配合ZooKeeper集群环境搭建

    前期准备就不详细说了,课堂上都介绍了1.修改Linux主机名2.修改IP3.修改主机名和IP的映射关系 ######注意######如果你们公司是租用的服务器或是使用的云主机(如华为用主机.阿里云主机 ...

  4. ubuntu 配置静态IP及DNS

    http://blog.csdn.net/njchenyi/article/details/8715417

  5. CentOS解压rar文件

    默认不能解压rar文件. 进官网下载:http://www.rarsoft.com/download.htm RAR 5.40 for Linux x64 安装: # tar -zxvf rarlin ...

  6. WPF绘制简单常用的Path(转)

    写代码出身的我们经常需要使用一些简单 但是不是规则图形的Path 但限于美工功底有限 不知道怎么去画 下面我告诉大家一些简单的小技巧 用代码来画Path 个人还是比较喜欢用代码 因为数值控制的更精细 ...

  7. 一款直接时空处理分析的开源数据库---geomesa

    一款直接时空处理分析的开源数据库---geomesa,可用于交通轨迹数据存储分析等相关领域, 在分布式列数据库的基础上进行扩展,目前支持Accumulo, HBase, Cassandra, and ...

  8. openresty websocket 使用

      openresty websocket 使用 1. 代码如下: local server =require"resty.websocket.server" local wb, ...

  9. 数据库视图View的使用

    一.视图的概念: 概念: 视图是指计算机数据库中的视图,是一个虚拟表,其内容由查询定义.同真实的表一样,视图包含一系列带有名称的列和行数据.但是,视图并不在数据库中以存储的数据值集形式存在.行和列数据 ...

  10. Java API 操作Zookeeper

    一.依赖 <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookee ...