在树莓派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" ...
随机推荐
- Xcode 使用自定义字体
添加对应的字体(.ttf或.odf)到工程的resurce,使用cocos2d中的FontLabel库,FontLabel继承于UILabel,象UILabel一样使用就好了 fontName直接使用 ...
- 【开源】前端练手笔记,Chrome扩展应用程序(html+CSS+JS) (1)
项目名称:github-notification 项目地址:https://github.com/WQTeam/github-notification 说明:本人打算抽时间学习前端(html + cs ...
- [R] /usr/share/doc/apache2/README.Debian.gz
Contents======== Apache2 Configuration under Debian GNU/Linux Files and Directories in '/etc/apache2 ...
- linux 下makefile
linux下c编程中makefile是必须会的,我刚开始学,将我对makefile的理解记录下来. 通常我们在windows下编写c程序,有各种ide工具为我们执行makefile工作但在linux下 ...
- GPUImage 自定义滤镜
GPUImage 自定义滤镜 GPUImage 是一个基于 GPU 图像和视频处理的开源 iOS 框架.由于使用 GPU 来处理图像和视频,所以速度非常快,它的作者 BradLarson 称在 iPh ...
- CMD模块定义规范
CMD 模块定义规范 在 Sea.js 中,所有 JavaScript 模块都遵循 CMD(Common Module Definition) 模块定义规范.该规范明确了模块的基本书写格式和基本交互规 ...
- Gray码 (格雷码) 【二进制】
以下内容是看了Matrix67的关于二进制的blog(Link)的一点总结与摘录. Gray码,中文“格雷码”,是一种特殊的编码,相邻两个格雷码的二进制表示中有且仅有一位不同,且 n 阶 Gray 码 ...
- 【转】SharePoint 2013 stand alone服务器安装
原文地址:http://www.cnblogs.com/jianyus/archive/2013/02/01/2889653.html 介绍:文章就是SharePoint2013安装过程的图解,包括 ...
- Instagram的技术架构
http://blogread.cn/it/article/5497 Instagram 被 Facebook 以10亿美金收购.团队规模:13 人.而在被Facebook收购前的一个月,整个团队才7 ...
- 使用NetUserAdd API函数创建远程用户
http://apps.hi.baidu.com/share/detail/33407620 使用NetUserAdd编程创建远程用户Windows API NetUserAdd()可以创建Windo ...