在树莓派1B上编译安装lnmp服务器
最近一周给部门内部搭建考试系统,选择使用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.
- 重新烧写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 等等。 编译:libxml2
./configure --prefix=/usr/local/libxml2 --with-python=no
make && make install- 编译:libmcrypt
./configure --prefix=/usr/local/libmcrypt --enable-ltdl-install
make && make install - 编译:zlib
./configure
make && make install - 编译:libpng
./configure --prefix=/usr/local/libpng
make && make instal - 编译: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 - 安装:freetype,这里没有编译,直接apt安装的libfreetype6-dev,后面再安装php的时候需要用到。编译php报错freetype.h not found.需要建立软连接。
ln -s /usr/include/freetype2/freetype.h /usr/include/freetype2/freetype/freetype.h
- 编译:autoconf.
./configure && make && make install
- 编译:gd
./configure --prefix=/usr/local/gd2 --with-png=/usr/local/libpng/ --with-jpeg=/usr/local/jpeg9/ --with-freetype=/usr/local/freetype
make && make install - 编译:pcre
./configure
make && make install - 编译:openssl
./config --prefix=/usr/local/openssl
make && make install - 编译:ncurses,这个必须安装,否则mysql编译会出错。
./configure --with-shared --without-debug --without-ada --enable-overwrite
make && make install上面opessl和ncurses编译时间较长,需要耐心等待。
- 编译安装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;
} - 编译安装mysql。具体方法参考http://blog.csdn.net/yangzhawen/article/details/7431865.
- 建立组和用户。
groupadd mysql
useradd -g mysql mysql - 配置编译
./configure --prefix=/usr/local/mysql --enable-local-infile
make
make install - 可能会出现错误:提示m4的库文件没有,需要下载安装。配置使用默认选择即可。
- 安装选项文件,将源文件里的support-files里的conf文件用作模板。
cp support-files/my-medium.cnf /etc/my.cnf
- 设置mysql的权限。
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql . - 新建mysql数据表
/usr/local/mysql/bin/mysql_install_db --user=mysql
- 改变/usr/local/mysql/var文件权限
chown -R mysql var
- 拷贝执行文件
cp /usr/local/src/mysql-5.1./support-files/mysql.server /etc/init.d/mysql
- 测试运行mysql
usr/local/mysql/bin/mysqld_safe --user=mysql &
service mysql start - 修改mysql的管理员密码
/usr/local/mysql/bin/mysqladmin -u root password 你的password
- 登录使用mysql
/usr/local/mysql/bin/mysql -u root -p
- 链接mysql文件,解决command not found 问题。
cd /usr/local/mysql/bin/
for file in *;
> do
> ln -s /usr/local/mysql/bin/$file /usr/bin/$file;
> done - 测试mysql,在任意目录使用mysql -u root -p 应该有提示密码输入。
- netstat -atln 检查3306端口使用情况。
- Service mysql start启动mysql服务
Service mysql stop停止mysql服务,Service mysql status检查状态。
- 建立组和用户。
- 编译安装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 - 启动php-fpm,如果提示错误,需要注意php安装目录下conf文件是否存在php-fpm.conf.并将其中nobody改为前面添加的用户名及组名www。
- 安装phpMadmin。需要注意php的版本与其应匹配。直接下载解压缩到站点目录即可。
- 安装完毕后添加各启动项目到/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 - 安装phpems,按照官方手册安装即可。需要注意修改数据库配置文件,修改data文件和files文件的权限。
至此,lnmp系统安装完毕。安装需要耐心,一定需要耐心,特别是要编译到树莓派这类处理能力不高的系统上!!
在树莓派1B上编译安装lnmp服务器的更多相关文章
- MAC 上编译安装nginx-rtmp-module 流媒体服务器
MAC 上编译安装nginx-rtmp-module 流媒体服务器 记录踩坑过程 下载nginx和nginx-rtmp-module wget http://nginx.org/download/ng ...
- Centos 6.8编译安装LNMP环境
Centos 6.8编译安装LNMP环境 参考资料: http://www.jb51.net/article/107429.htm https://phperzh.com/articles/1360 ...
- 阿里云centos6.5实践编译安装LNMP架构web环境
LNMP 代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构. 本次测试需求: **实践centos6.5编译安装 LNMP生产环境 架构 web生产环境 使用 ngx_pa ...
- WordPress安装篇(5):源码编译安装LNMP并部署WordPress
与YUM方式安装相比,源码编译安装方式更灵活,安装过程中能自定义功能和参数,特别是在批量部署服务器又要求软件版本及配置一致时,源码编译安装的优势很明显.本文介绍如何通过源码编译方式安装Nginx1.1 ...
- CentOS编译安装LNMP环境
这里是教大家如何在centos下利用源码编译安装LNMP环境. 工具/原料 centos服务器一台 自用电脑一台 准备篇 配置好IP.DNS .网关,确保使用远程连接工具能够连接服务器 配置防火墙,开 ...
- SaltStack之编译安装LNMP环境
使用saltstack编译安装LNMP环境 一,系统版本查看 二,安装salt-master和salt-minion 安装配置过程参考SaltStack概述及安装 三,修改配置文件 /etc/salt ...
- Linux上编译安装PHP
这篇文章主要介绍了关于Linux上编译安装PHP,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 之前在服务器上编译安装了PHP运行环境,但是安装完过了一段时间就差不多忘记了,只是零零星 ...
- Windows 编译安装 nginx 服务器 + rtmp 模块
有关博客: <Windows 编译安装 nginx 服务器 + rtmp 模块>.<Ubuntu 编译安装 nginx>.<Arm-Linux 移植 Nginx> ...
- centos下编译安装lnmp
centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...
随机推荐
- 关于JavaScript的类的继承
其实最一开始学JS的时候就看过继承的实现.当时只是去试着理解从书上看来的代码段而已.今天又重新思考了一下,感觉这是一个思维探索演进的结果. 继承,即复用. 如果抛开继承的固有思想,让b复用a的成员,最 ...
- Spring与Jdbc Demo
方法一:继承JdbcTemplate来实现 1.配置applicationContext <!-- 获取数据源连接 dbcp --> <bean id="dataSourc ...
- 【POJ3580】【块状链表】SuperMemo
Description Your friend, Jackson is invited to a TV show called SuperMemo in which the participant i ...
- skip-grant-tables的作用
skip-grant-tables:非常有用的mysql启动参数(不启动grant-tables授权表) skip-grant-tables:非常有用的mysql启动参数 介绍一个非常有用的mys ...
- Servlet监听器类型
------------------------serlvet对象监听器------------------------------------------- request监听器(ServletRe ...
- cocod2d-x 之 HelloWorld
cocos2d-x 2.2创建项目 进入cocos2d-x-2.2/tools/project-creator,运行命令 python create_project.py -project MyGam ...
- PHPCMS收集标签使用
调用子栏目(在栏目首页模板需要用到) {pc:content action="category" catid="$catid" num="25&quo ...
- HDU 1996
Problem Description n个盘子的汉诺塔问题的最少移动次数是2^n-1,即在移动过程中会产生2^n个系列.由于发生错移产生的系列就增加了,这种错误是放错了柱子,并不会把大盘放到小盘上, ...
- 造成session丢失的原因和解决方法
win2003 server下的IIS6默认设置下对每个运行在默认应用池中的工作者进程都会经过20多个小时后自动回收该进程, 造成保存在该进程中的session丢失. 因为Session,Appl ...
- Java中间件
传统的HTML已经满足不了如今web系统的诸多的功能需求,建立一个交互式的Web,便诞生了各种Web开发语言,如ASP,JSP,PHP等,这些语言与传统的语言有着密切的联系,如JSP基于Java语言. ...