最近一周给部门内部搭建考试系统,选择使用PHPEMS。这是个开源的系统,唯一缺点是PHP的版本比较低,只能使用5.2或5.3。而我的树莓派系统更新后使用apt-get安装得到的PHP版本为5.4。由于担心版本不对,使用中会出现问题,最后决定选择编译安装LNMP。谁曾想,这一安装竟然耗费了近5天时间,期间无数次重新卡刷树莓派系统。好在有阿里云的镜像,更新速度还凑活。有几个更新包(bootloader以及doc,sonic pi)必须从raspberrypi的网站上下,那速度太慢了。最后终于搞定安装,下面记录备份一下安装流程。

一.准备工作:

  • 提前下载好各类库源文件:libxml2,libmcypt,zlib,libpng,jpeg,freetype,autoconf,gd,pcre,opessl,ncurses,m4.
  • 准备下载需要程序的PHP,nginx,mysql源码包。这里使用的mysql5.1版本
  • 将上述文件都存放在一起,便于管理。

二.整个过程记录:

按照./configure  && make && make install进行即可。唯一不同过得就是配置参数需要注意,有些参数我也是参考网络。一般配置安装目录都在/usr/local/xxx.

  1. 重新烧写raspbian系统,wheezy版本,启动后扩充空间。重启系统后,更改source.list到阿里云镜像。

    deb http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contrib
    deb-src http://mirrors.aliyun.com/raspbian/raspbian/ wheezy main non-free contrib
    sudo apt-get update && upgrade.更新系统。这里更新需要一段时间。尤其是更新bootloader 等等。

  2. 编译:libxml2

    ./configure --prefix=/usr/local/libxml2 --with-python=no
    make && make install
  3. 编译:libmcrypt
    ./configure --prefix=/usr/local/libmcrypt --enable-ltdl-install
    make && make install
  4. 编译:zlib
    ./configure
    make && make install  
  5. 编译:libpng
    ./configure --prefix=/usr/local/libpng
    make && make instal
  6. 编译:jpeg
    mkdir /usr/local/jpeg9
    mkdir /usr/local/jpeg9/bin
    mkdir /usr/local/jpeg9/lib
    mkdir /usr/local/jpeg9/include
    mkdir -p /usr/local/jpeg9/man/man1
    tar -zxvf jpegsrc.v9.tar.gz
    cd jpeg-/
    ./configure --prefix=/usr/local/jpeg9/ --enable-shared --enable-static
    make && make install  
  7. 安装:freetype,这里没有编译,直接apt安装的libfreetype6-dev,后面再安装php的时候需要用到。编译php报错freetype.h not found.需要建立软连接。
    ln -s /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h 
  8. 编译:autoconf.
    ./configure && make && make install
  9. 编译:gd
    ./configure --prefix=/usr/local/gd2 --with-png=/usr/local/libpng/ --with-jpeg=/usr/local/jpeg9/ --with-freetype=/usr/local/freetype
    make && make install
  10. 编译:pcre
    ./configure
    make && make install
  11. 编译:openssl
    ./config --prefix=/usr/local/openssl
    make && make install 
  12. 编译:ncurses,这个必须安装,否则mysql编译会出错。
  13. ./configure --with-shared --without-debug --without-ada --enable-overwrite
    make && make install

    上面opessl和ncurses编译时间较长,需要耐心等待。

  14. 编译安装nginx。

    groupadd www
      useradd -g www www

    ./configure --user=www --group=www --prefix=/usr/local/nginx --with-openssl=/lnmp/openssl-1.0.0l --with-http_stub_status_module --with-http_ssl_module
    make && make install

    配置nginx.conf.

    配置nginx;
    vi /usr/local/nginx/conf/nginx.conf
    #第35行server下找到location / 修改为如下,root为根路径,index为默认解析
    location / {
    root /var/www/html;
    index index.html index.htm index.php;
    }
    #修改fastcgi配置,在server下找到location ~ \.php$(第74行),并修改为如下
    location ~ \.php$ {
    root /var/www/html;
    fastcgi_pass 127.0.0.1:;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
    include fastcgi_params;
    }
  15. 编译安装mysql。具体方法参考http://blog.csdn.net/yangzhawen/article/details/7431865.
    1. 建立组和用户。

      groupadd mysql
      useradd -g mysql mysql
    2. 配置编译
       ./configure --prefix=/usr/local/mysql --enable-local-infile
      make
      make install
    3. 可能会出现错误:提示m4的库文件没有,需要下载安装。配置使用默认选择即可。
    4. 安装选项文件,将源文件里的support-files里的conf文件用作模板。
      cp support-files/my-medium.cnf /etc/my.cnf
    5. 设置mysql的权限。
      cd /usr/local/mysql
      chown -R mysql .
      chgrp -R mysql .
    6. 新建mysql数据表
      /usr/local/mysql/bin/mysql_install_db --user=mysql
    7. 改变/usr/local/mysql/var文件权限
      chown -R mysql var
    8. 拷贝执行文件
      cp /usr/local/src/mysql-5.1./support-files/mysql.server /etc/init.d/mysql
    9. 测试运行mysql
      usr/local/mysql/bin/mysqld_safe --user=mysql &
      service mysql start
    10. 修改mysql的管理员密码
      /usr/local/mysql/bin/mysqladmin -u root password 你的password
    11. 登录使用mysql
      /usr/local/mysql/bin/mysql -u root -p
    12. 链接mysql文件,解决command not found 问题。
       cd /usr/local/mysql/bin/
      for file in *;
      > do
      > ln -s /usr/local/mysql/bin/$file /usr/bin/$file;
      > done
    13. 测试mysql,在任意目录使用mysql -u root -p 应该有提示密码输入。
    14. netstat -atln 检查3306端口使用情况。
    15. Service mysql start启动mysql服务
    16. Service mysql stop停止mysql服务,Service mysql status检查状态。

  16. 编译安装php5.2.17
    ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg9/ --with-freetype-dir --with-gd --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets --enable-fpm --with-pdo-mysql=/usr/local/mysql/ --with-png-dir=/usr/local/libpng/

    编译会出错node.c的错误,百度即可解决,下面为方法。

    $ curl -o php-5.2..patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
    $ tar jxf php-5.2..tar.bz2
    $ cd php-5.2.
    $ patch -p0 -b <../php-5.2..patch
  17. 启动php-fpm,如果提示错误,需要注意php安装目录下conf文件是否存在php-fpm.conf.并将其中nobody改为前面添加的用户名及组名www。
  18. 安装phpMadmin。需要注意php的版本与其应匹配。直接下载解压缩到站点目录即可。
  19. 安装完毕后添加各启动项目到/etc/rc.local里面exit 0前面即可保证开机启动。
    if [ "$_IP" ]; then
    printf "My IP address is %s\n" "$_IP"
    fi /usr/local/nginx/sbin/nginx
    /usr/local/php/sbin/php-
    fpm
    service mysql start
    exit
  20. 安装phpems,按照官方手册安装即可。需要注意修改数据库配置文件,修改data文件和files文件的权限。

至此,lnmp系统安装完毕。安装需要耐心,一定需要耐心,特别是要编译到树莓派这类处理能力不高的系统上!!

在树莓派1B上编译安装lnmp服务器的更多相关文章

  1. MAC 上编译安装nginx-rtmp-module 流媒体服务器

    MAC 上编译安装nginx-rtmp-module 流媒体服务器 记录踩坑过程 下载nginx和nginx-rtmp-module wget http://nginx.org/download/ng ...

  2. Centos 6.8编译安装LNMP环境

    Centos 6.8编译安装LNMP环境 参考资料: http://www.jb51.net/article/107429.htm https://phperzh.com/articles/1360 ...

  3. 阿里云centos6.5实践编译安装LNMP架构web环境

    LNMP 代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构. 本次测试需求: **实践centos6.5编译安装 LNMP生产环境 架构 web生产环境 使用 ngx_pa ...

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

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

  5. CentOS编译安装LNMP环境

    这里是教大家如何在centos下利用源码编译安装LNMP环境. 工具/原料 centos服务器一台 自用电脑一台 准备篇 配置好IP.DNS .网关,确保使用远程连接工具能够连接服务器 配置防火墙,开 ...

  6. SaltStack之编译安装LNMP环境

    使用saltstack编译安装LNMP环境 一,系统版本查看 二,安装salt-master和salt-minion 安装配置过程参考SaltStack概述及安装 三,修改配置文件 /etc/salt ...

  7. Linux上编译安装PHP

    这篇文章主要介绍了关于Linux上编译安装PHP,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 之前在服务器上编译安装了PHP运行环境,但是安装完过了一段时间就差不多忘记了,只是零零星 ...

  8. Windows 编译安装 nginx 服务器 + rtmp 模块

    有关博客: <Windows 编译安装 nginx 服务器 + rtmp 模块>.<Ubuntu 编译安装 nginx>.<Arm-Linux 移植 Nginx> ...

  9. centos下编译安装lnmp

    centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...

随机推荐

  1. C++ STL的基本基本原理

    STL都是在内存的堆区分配的,但是其析构也是STL帮我们做好的,不用手动去delete. 1.vector 逻辑地址连续的一片内存空间,当空间不足,重新申请新的地址空间,将原有的数据复制过去,而新的地 ...

  2. TestNG Listener

    常用接口 IExecutionListener   监听TestNG运行的启动和停止. IAnnotationTransformer 注解转换器,用于TestNG测试类中的注解. ISuiteList ...

  3. mysql 语句资料总结

    一.UNION命令 UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的 SELECT 语句必须拥有相同数量的列.列也必须拥有相似的数据类型.同时,每条 SE ...

  4. php中判断变量是否为空

    从数据库中取出值后判断是否为空,这个看起来很简单,只要和null比较一下就可以了,其实不然, if($obj==null){ } 这样写会报错的:Notice: Trying to get prope ...

  5. Linux操作:

    1.在Linux中第一个字符代表这个文件是目录.文件或链接文件等等. 当为[ d ]则是目录,当为[ - ]则是文件,若是[ l ]则表示为链接文档(link file),若是[ b ]则表示为装置文 ...

  6. PHP 开启 ssh2

    首先,为PHP安装SSH2扩展需要两个软件包, libssh2和ssh2(php pecl拓展). 两者的最新版本分别为libssh2-1.5.0.tar.gz和ssh2-0.12.tgz,下载地址分 ...

  7. List<String^>^ 引用空间

    莫名其妙报错 需要在.h和.cpp文件中都引用: using namespace System::Collections;using namespace System::Collections::Ge ...

  8. 【Linux】常用命令-统计代码行数

    公司人员流动大,经常有新的维护任务,交接时喜欢看看新来的模块的代码量,那么问题来了, 如何统计代码行数? 1,最先想到的肯定是 wc. wc -l *.h 将查看[当前目录]下头文件的代码行数,输出结 ...

  9. nosql数据库选型

    http://blogread.cn/it/article/6654 今天在书店里翻完了一遍<七天七数据库>.这本书简单介绍了postgreSQL,riak,mongodb,HBase,r ...

  10. h.264语法结构分析

    NAL Unit Stream Network Abstraction Layer,简称NAL. h.264把原始的yuv文件编码成码流文件,生成的码流文件就是NAL单元流(NAL unit Stre ...