设为首页 收藏本站
查看: 1380|回复: 0

[经验分享] 基于loongson1b开发板(mips架构)移植apache+sqlite3+php5

[复制链接]

尚未签到

发表于 2015-11-17 12:29:42 | 显示全部楼层 |阅读模式
  环境
  编译平台:Ubuntu12.04
  交叉工具链:gcc-3.4.6
  
  一、移植Sqlite
  解压Sqlite-3.6.20.tar.gz 到工具目录下:tar zxf Sqlite-3.6.20.tar.gz -C /home/xxx/tools
  进入sqlite-3.6.20目录中:cd sqlite-3.6.20
  1):./configure --host=mipsel-linux(指定交叉编译工具链) --prefix=/opt/mispel-linux-sqlite
  2make
  3)  make install
  在执行make中会出现下面错误:
  libtool: link: mipsel-linux-gcc -shared .libs/tclsqlite.o -Wl,-rpath -Wl,/opt/sqlite-3.6.20-embedded/.libs -Wl,-rpath -Wl,/opt/mipsel-linux-sqlite/lib ./.libs/libsqlite3.so -L/opt/tcl8.5.15/unix -ltclstub8.5 -lpthread -Wl,-soname -Wl,libtclsqlite3.so -o .libs/libtclsqlite3.so/opt/gcc-4.3-ls232-softfloat/lib/gcc/mipsel-linux/4.3.0/../../../../mipsel-linux/bin/ld: skipping incompatible /opt/gcc-4.3-ls232-softfloat/lib/gcc/mipsel-linux/4.3.0/../../../../mipsel-linux/lib/libtclstub8.5.a when searching for -ltclstub8.5/opt/gcc-4.3-ls232-softfloat/lib/gcc/mipsel-linux/4.3.0/../../../../mipsel-linux/bin/ld: cannot find -ltclstub8.5collect2: ld returned 1 exit statusmake: *** [libtclsqlite3.la] 错误 1
  出现:skipping incompatible 一般是不同处理器架构引用了不属于自己处理器架构的库,
  上面出现的情况,就是mipsel架构的引用了x86架构的库 libtclstub8.5
  所以要源码交叉编译tclsh才能解决上述问题。
  解决方法:解压tcl8.5.15-src.tar.gz,并进入源码文件夹tcl8.5.15
  执行:
  1./configure --host=mipsel-linux --prefix=/opt/mipsel-linux-tclsh
  2) make
  3) make install
  但在 ./configure --host=mipsel-linux --prefix=/opt/mipsel-linux-tclsh
  过程中会出现以下错误:
  fixstrtod.o: In function `fixstrtod':fixstrtod.c:(.text+0x0): multiple definition of `fixstrtod'strtod.o:strtod.c:(.text+0x0): first defined herecollect2:
  ld returned 1 exit statusmake: *** [libtcl8.5.so] 错误 1
  执行下面语句:
  [iyunv@CaM/opt/tcl-embedded/unix 11:45]#export ac_cv_func_strtod=yes
  [iyunv@CaM/opt/tcl-embedded/unix 11:46]#export tcl_cv_strtod_buggy=1
  就可以解决了。
  编译安装完成后,在mipsel-linux-sqlite目录下分别生成binincludelib目录。
  bin/sqlite3lib/libsqlite3.so.0.8.6别拷至文件系统/bin目录与/lib目录下,
  并将libsqlite3.so.0.8.6更名为libsqlite3.so.0完成移植。
  二、移植apache
  $ su (切换到root用户)
  1. 本机编译
   $ cd /usr/local/apache-pc/apache_1.3.39
  $ ./configure
  错误提示:
  Configuring for Apache, Version 1.3.39
+ Warning: Your ‘echo’ command is slightly broken.
+ It interprets escape sequences per default. We already
+ tried ‘echo -E’ but had no real success. If errors occur
+ please set the SEO variable in ‘configure’ manually to
+ the required ‘echo’ options, i.e. those which force your
+ ‘echo’ to not interpret escape sequences per default.
+ using installation path layout: Apache (config.layout)
Creating Makefile
Creating Configuration.apaci in src
Syntax error — The configuration file is used only to
define the list of included modules or to set Makefile in src
options or Configure rules, and I don’t see that at all:
`$(SRCDIR)/apaci`
default
default
no
no
no
yes
no
default
no
default
default
  解决:


  这是由于某些shell脚本文件使用了错误的interpreter,使用下面的命令就可以解决。
  # rm -f /bin/sh
# ln -s /bin/bash /bin/sh
  
   $ make
   错误提示:
DSC0000.jpg
   解决:
  将提示的c文件中冲突的函数另改别名:如getline 改成get_line,总共有三个c文件要改。
  执行完make后就完成本机编译了,生成了我们需要使用的编译工具。
  2. 交叉编译
  (注意交叉工具链的环境)
   $ cd /usr/local/apache-mipsel/apache_1.3.39
   $ CC=mipsel-linux-gcc ./configure --prefix=/usr/local/apache-php/apache --enable-module=so
   接着如下修改:
cp /usr/local/apache-pc/apache-1.3.39/src/main/gen_test_char /usr/local/apache-pc/apache-1.3.39/src/main/gen_uri_delims /usr/local/apache-mipsel/apache-1.3.39/src/main/
   $ make
   错误提示:
DSC0001.jpg
   解决:
   $ cp /usr/local/apache-pc/apache_1.3.39/src/main/gen_test_char /usr/local/apache-pc/apache_1.3.39/src/main/gen_uri_delims /usr/local/apache-mipsel/apache_1.3.39/src/main/
   $ make install
DSC0002.jpg
   如图所示,则安装成功
   查看是否为交叉编译文件
   $ file /usr/local/apache-php/apache/bin/httpd
  
  
  三、移植PHP
  1.  本地编译php
  $  cd /usr/local/apache-pc/php-5.2.0
  $  ./configure
  错误提示 :
DSC0003.jpg
  解决
  sudo apt-get install flex
  
  错误提示2
DSC0004.jpg
  解决
  sudo apt-get install libxml2-dev
  
  $   make
  
  2. 交叉编译
  安装zlib-1.2.3
  $ cd /usr/local/apache-mipsel/zlib-1.2.3
  $ CC=mipsel-linux-gcc ./configure --prefix=/usr/local/apache-php/zlib
  $ make
  $ make install
  $  cd /usr/local/apache-mipsel/php-5.2.0
  $ CC=mipsel-linux-gcc ./configure --host=mipsel-linux
  --prefix=/usr/local/apache-php/php --with-apxs=/usr/local/apache-php/apache/bin/apxs --enable-pdo=shared --with-sqlite=shared --with-pdo-sqlite=shared --with-zlib --with-zlib-dir=/usr/local/apache-php/zlib --without-iconv
  错误提示1
DSC0005.jpg
  解决:
  打开脚本/usr/local/apache-mipsel/php-5.2.0/configure搜索“$APXS -q
  CFLAGS >/dev/null 2>&1”进行如下代码的注释。  
DSC0006.jpg
  错误提示2
DSC0007.jpg
  解决 :
  安装libxml2-2.6.11
  $ cd libxml2-2.6.11
  $ CC=mipsel-linux-gcc ./configure --host=mipsel-linux --prefix=/usr/local/apache-php/zlib
  $ make
  $ make install
  ./configure
  首先修改phpMakefile在开始出添加LDFLAGS += -ldl ,这里是为了链接dlopen
  然后修改main/php.h 在开始处添加#define HAVE_LIBDL 1 ,这个宏是为了交叉编译时强制使用dlopen
  紧接着修改ext/standard/dl.c &#57347;这段代码中添加#include <dlfcn.h> &#57347;这个是dlopen的头文
  件。
  #if defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H
  #include <stdlib.h>
  #include <stdio.h>
  #include <dlfcn.h>
  最后修改 sapi/apache/php_apache_http.h
  #include &quot;httpd.h&quot;
  #include &quot;http_config.h&quot;
  # include &quot;ap_compat.h&quot;
  #  include &quot;compat.h&quot;
  #include &quot;http_core.h&quot;
  #include &quot;http_main.h&quot;
  #include &quot;http_protocol.h&quot;
  #include &quot;http_request.h&quot;
  #include &quot;http_log.h&quot;   
  #include &quot;util_script.h&quot;
  将其修改为#include &quot;/usr/local/apache-php/apache/include/httpd.h&quot;这个路径(这些头文件的目录)
  # make (时间有点长,去喝杯水休息一下吧00!!)
  错误提示1
DSC0008.jpg
  解决:
  修改mod_php5.c23行错误&#57345;头文件加上/usr/local/apache-arm11/apache/include路径
  
  错误提示2
DSC0009.jpg
  解决:
  $ cp /opt/gcc-3.4.6-2f/lib/libxml2.so /us r/lib/i386-linux-gnu/
  
  错误提示3:
DSC00010.jpg
  解决
  暂时不知道哪里出了问题,只能注释了其中的代码
  
  $ make install
  错误提示 1
DSC00011.jpg
  解决
  $mv /usr/local/apache-php/apche/bin/httpd /usr/local/apache-php/apache/bin/httpd_backup
  $ cp /usr/local/apache-pc/apache/bin/http /usr/local/apache-php/apache/bin/httpd
  
  错误提示2
DSC00012.jpg
  解决
  $mv /usr/local/apache-mipsel/php-5.2.0/sapi/cli/php /usr/local/apache-mipsel/php-5.2.0/sapi/cli/php_backup
  $ cp /usr/local/apache-pc/php-5.2.0/sapi/cli/php /usr/local/apache-mipsel/php-5.2.0/sapi/cli/
  
  不出意外应该成功了,可以去/usr/local/apache-php/php/看下是否有目录
  把原来的mips版的phphttpd还原回去 :
  cp /usr/local/apache-mips/php-5.2.0/scpi/cli/php_backup /usr/local/apache-php/php/bin/
  cp /usr/local/apache-mips/apache/bin/httpd_backup /usr/local/apache-php/apache/bin/httpd
  
  四、配置httpd.confphp.ini
  l 修改httpd.conf
  $ vim /usr/local/apache-php/apache/conf/httpd.conf 添加红色部分
  
  #
  # DirectoryIndex: Name of the file or files to use as a pre-written HTML
  # directory index.  Separate multiple entries with spaces.
  #
  <IfModule mod_dir.c>
  DirectoryIndex index.html
      DirectoryIndex index.php
      DirectoryIndex index.php3
      DirectoryIndex index.phtml
  </IfModule>
  
  #
  # AccessFileName: The name of the file to look for in each directory
  # for access control information.
  #
  AccessFileName .htaccess
  ...
  # documents in the realname directory are treated as applications and
  # run by the server when requested rather than as documents sent to the client.
  # The same rules about trailing &quot;/&quot; apply to ScriptAlias directives as to
  # Alias.
  #
  ScriptAlias /cgi-bin/ &quot;/usr/local/apache-php/apache/cgi-bin/&quot;
   ScriptAlias /php5/ &quot;/usr/local/apache-php/php/bin/&quot;
  

  #
  # &quot;/usr/local/apache-php/apache/cgi-bin&quot; should be changed to whatever your ScriptAliased
  # CGI directory exists, if you have that configured.
  ...
  #
  # AddType allows you to tweak mime.types without actually editing it, or to
  # make certain files to be certain types.
  #
  AddType application/x-tar .tgz
    AddType application/x-httpd-php .php3
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php .phtml
  
  #
  # AddEncoding allows you to have certain browsers uncompress
  # information on the fly. Note: Not all browsers support this.
  # Despite the name similarity, the following Add* directives have nothing
  l 修改php.ini
  $ cp /usr/local/apache-mips/php-5.2.0/php.ini-dist /usr/local/apache-php/php/lib/
  $ mv /usr/local/apache-php/lib/php.ini-dist /usr/local/apache-php/lib/php.int
  $ vim /usr/local/apache-php/lib/php.int
  
  ; to possible security problems, if the code is not very well thought of.
  register_globals = On
  
  ; Whether or not to register the old-style input arrays, HTTP_GET_VARS
  ; and friends.  If you're not using them, it's recommended to turn them off,
  
  五、移植至loongson1B
  ps进过九九八十一难终于可以烧进板啦
  1、打包apachephp
  # tar cjf apache-php.tar.bz2 apache-php
  2、经nfs共享至开发板
  3、开发板建立/usr/local/
  4、解压至/usr/local/  :与宿主机一致
  5、进入/usr/local/apache-php/apache/bin
  # ./apachectl start
其中需要注意,因为Aapche不支持root用户,所以需要确认Linux文件系统中有nobody组和nogroup组。
在/etc添加两个用户
vi /etc/passwd :
root::0:0:root:/:/bin/bash
nobody::65534:65533:nobody:/:/bin/bash
vi /etc/group :
body::65533:
nogroup::65534:nobody
root::0:
users::100:
正常启动会弹出
DSC00013.jpg
  若有其他问题goole、度娘一下,都是常见问题
  6、打开浏览器输入http://ip:8080就能看见apache测试画面啦
   DSC00014.jpg

  7、后面加程序名就能运行程序:http://ip:8080/test.php
DSC00015.jpg
  至此,搭建lasp环境完成...
  
         版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-140314-1-1.html 上篇帖子: 基于loongson1b的appweb+php5+sqlite环境搭建 下篇帖子: Linux应用程序开发(一)---移植thttpd+Sqlite3+PHP5到arm linux(1)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表