基于loongson1b开发板(mips架构)移植apache+sqlite3+php5
环境 编译平台: Ubuntu12.04 交叉工具链: gcc-3.4.6 一、移植 Sqlite 解压 Sqlite-3.6.20.tar.gz 到工具目录下: tarzxfSqlite-3.6.20.tar.gz-C/home/xxx/tools 进入 sqlite-3.6.20 目录中: cdsqlite-3.6.20 1 ): ./configure--host=mipsel-linux( 指定
环境
编译平台: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
2) make
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
执行下面语句:
[root@CaM/opt/tcl-embedded/unix 11:45]#export ac_cv_func_strtod=yes
[root@CaM/opt/tcl-embedded/unix 11:46]#export tcl_cv_strtod_buggy=1
就可以解决了。
编译安装完成后,在mipsel-linux-sqlite目录下分别生成bin、include和lib目录。
将bin/sqlite3与lib/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
错误提示:
解决:
将提示的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
错误提示:
解决:
$ 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
如图所示,则安装成功
查看是否为交叉编译文件
$ file /usr/local/apache-php/apache/bin/httpd
三、移植PHP
1. 本地编译php
$ cd /usr/local/apache-pc/php-5.2.0
$ ./configure
错误提示 :
解决 :
sudo apt-get install flex
错误提示2 :
解决 :
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:
解决:
打开脚本/usr/local/apache-mipsel/php-5.2.0/configure搜索“$APXS -q
CFLAGS >/dev/null 2>&1”进行如下代码的注释。
错误提示2:
解决 :
安装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后
首先修改php的Makefile在开始出添加LDFLAGS += -ldl ,这里是为了链接dlopen库
然后修改main/php.h 在开始处添加#define HAVE_LIBDL 1 ,这个宏是为了交叉编译时强制使用dlopen。
紧接着修改ext/standard/dl.c 这段代码中添加#include
件。
#if defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H
#include
#include
#include
最后修改 sapi/apache/php_apache_http.h
#include "httpd.h"
#include "http_config.h"
# include "ap_compat.h"
# include "compat.h"
#include "http_core.h"
#include "http_main.h"
#include "http_protocol.h"
#include "http_request.h"
#include "http_log.h"
#include "util_script.h"
将其修改为#include "/usr/local/apache-php/apache/include/httpd.h"这个路径(这些头文件的目录)
# make (时间有点长,去喝杯水休息一下吧0﹏0!!)
错误提示1:
解决:
修改mod_php5.c中23行错误头文件加上/usr/local/apache-arm11/apache/include路径
错误提示2 :
解决:
$ cp /opt/gcc-3.4.6-2f/lib/libxml2.so /us r/lib/i386-linux-gnu/
错误提示3: :
解决 :
暂时不知道哪里出了问题,只能注释了其中的代码
$ make install
错误提示 1 :
解决 :
$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 :
解决 :
$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版的php、httpd还原回去 :
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.conf和php.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.
#
DirectoryIndex index.html
DirectoryIndex index.php
DirectoryIndex index.php3
DirectoryIndex index.phtml
#
# 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 "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/usr/local/apache-php/apache/cgi-bin/"
ScriptAlias /php5/ "/usr/local/apache-php/php/bin/"
#
# "/usr/local/apache-php/apache/cgi-bin" 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、打包apache和php
# 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:
正常启动会弹出
若有其他问题goole、度娘一下,都是常见问题
6、打开浏览器输入http://ip:8080就能看见apache测试画面啦
7、后面加程序名就能运行程序:http://ip:8080/test.php

至此,搭建lasp环境完成...

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

SpringDataJPA is based on the JPA architecture and interacts with the database through mapping, ORM and transaction management. Its repository provides CRUD operations, and derived queries simplify database access. Additionally, it uses lazy loading to only retrieve data when necessary, thus improving performance.

Paper address: https://arxiv.org/abs/2307.09283 Code address: https://github.com/THU-MIG/RepViTRepViT performs well in the mobile ViT architecture and shows significant advantages. Next, we explore the contributions of this study. It is mentioned in the article that lightweight ViTs generally perform better than lightweight CNNs on visual tasks, mainly due to their multi-head self-attention module (MSHA) that allows the model to learn global representations. However, the architectural differences between lightweight ViTs and lightweight CNNs have not been fully studied. In this study, the authors integrated lightweight ViTs into the effective

The learning curve of the Go framework architecture depends on familiarity with the Go language and back-end development and the complexity of the chosen framework: a good understanding of the basics of the Go language. It helps to have backend development experience. Frameworks that differ in complexity lead to differences in learning curves.

PHP belongs to the backend in web development. PHP is a server-side scripting language, mainly used to process server-side logic and generate dynamic web content. Compared with front-end technology, PHP is more used for back-end operations such as interacting with databases, processing user requests, and generating page content. Next, specific code examples will be used to illustrate the application of PHP in back-end development. First, let's look at a simple PHP code example for connecting to a database and querying data:

"Understanding VSCode: What is this tool used for?" 》As a programmer, whether you are a beginner or an experienced developer, you cannot do without the use of code editing tools. Among many editing tools, Visual Studio Code (VSCode for short) is very popular among developers as an open source, lightweight, and powerful code editor. So, what exactly is VSCode used for? This article will delve into the functions and uses of VSCode and provide specific code examples to help readers
