Posted by: Wildan Maulana | July 9, 2007

Compiling PHP & lighttpd for avr32

Prerequisite :

# apt-get install flex bison

Step 1 : Download PHP source
http://downloads.openwrt.org/sources/php-5.1.6.tar.bz2

Step 2 : Extract the php source
#tar jxv php-5.1.6.tar.bz2

Step 3 : Download new config.guess and config.sub
#wget http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
#wget http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub

Step 4 : Replace config.guess and config.sub in root source directory, with the file you download at Step 3

Step 5 : Configure

# CC=avr32-linux-gcc ./configure –host=avr32-linux –prefix=/home/wildan/netherland-project/ngw100/packagesByW/php/dist/ –enable-fastcgi –enable-sockets –enable-discard-path –enable-force-redirect –with-config-file-path=/tmp –disable-ipv6 –without-iconv –disable-xml –without-pear –disable-xmlreader –disable-xmlwriter –disable-libxml –disable-dom –disable-simplexml  –with-pdo-sqlite=/home/wildan/netherland-project/ngw100/packagesByW/sqlite/
Step 6 : Make

# CC=avr32-linux-gcc ARCH=avr32 make CROSS=avr32-linux-

Step 7 : Install
#make install

Step 8: Copy the result to the /nfs (root fs ngw100)
#cd dist/
#cp -rv bin/ /nfs/
#cp -rv include/ /nfs/
#cp -rv lib/ /nfs/

Result :

bin # php -v
PHP 5.1.6 (cgi-fcgi) (built: Jul 19 2007 21:23:30)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
lighttpd
=========

lighttpd

Step 1 : Download
#wget -c http://downloads.openwrt.org/sources/lighttpd-1.4.15.tar.bz2

Step 2 : Extract
tar jxvf lighttpd-1.4.15.tar.bz2

Step 3 :
Applying the following patch (configfilecpatch.doc), this patch is taken from [1]

#####configfile.c.patch
— lighttpd-1.4.15.orig/src/configfile.c 2006-02-08 13:39:29.000000000 +0100
+++ lighttpd-1.4.15/src/configfile.c 2006-03-15 15:32:12.000000000 +0100
@@ -863,8 +863,12 @@
int ret;
buffer *source;
buffer *out;
+#ifdef PATH_MAX
char oldpwd[PATH_MAX];
-
+#else
+ char oldpwd[4096];
+#endif
+
if (NULL == getcwd(oldpwd, sizeof(oldpwd))) {
log_error_write(srv, __FILE__, __LINE__, “s”,
“cannot get cwd”, strerror(errno));
———end here —–

root@elekta:/home/wildan/netherland-project/ngw100/packagesByW/lighttpd/lighttpd-1.4.15# patch -p1 < configfile.c.patch
patching file src/configfile.c

Step 4 : Configure

# CC=avr32-linux-gcc ./configure –host=avr32-linux –prefix=/home/wildan/netherland-project/ngw100/packagesByW/lighttpd/dist/ –disable-ipv6

Step 5 : Make
#CC=avr32-linux-gcc make CROSS_COMPILE=avr32-linux-

Step 6 : Install

#make install

Step 7 : Copy the result to the root fs of ngw 100

#cd dist/
#cp -rv bin/ /nfs/
# cp -rv sbin/ /nfs/
#cp -rv lib/ /nfs/

Step 8 : Enable fastcgi module on lighttpd confguration file, below is the complete configuration. put this file on /etc
(/nfs/etc/lighttpd.conf):

#/etc/lighttpd.conf
# lighttpd configuration file
#
# use a it as base for lighttpd 1.0.0 and above
#
# $Id: lighttpd.conf,v 1.6 2004/08/29 09:44:53 weigon Exp $

############ Options you really have to take care of ####################

## modules to load
# at least mod_access and mod_accesslog should be loaded
# all other module should only be loaded if really neccesary
# – saves some time
# – saves memory
server.modules = (
# “mod_rewrite”,
# “mod_redirect”,
“mod_access”,
# “mod_auth”,
# “mod_status”,
“mod_fastcgi”,
# “mod_simple_vhost”,
# “mod_evhost”,
# “mod_cgi”,
# “mod_compress”,
# “mod_ssi”,
# “mod_usertrack”,
# “mod_rrdtool”,
# “mod_accesslog”
)

## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = “/www/”

## where to send error-messages to
# server.errorlog = “”

# files to check for if …/ is requested
server.indexfiles = ( “index.php”, “index.html”,
“index.htm”, “default.htm” )

# mimetype mapping
mimetype.assign = (
“.pdf” => “application/pdf”,
“.sig” => “application/pgp-signature”,
“.spl” => “application/futuresplash”,
“.class” => “application/octet-stream”,
“.ps” => “application/postscript”,
“.torrent” => “application/x-bittorrent”,
“.dvi” => “application/x-dvi”,
“.gz” => “application/x-gzip”,
“.pac” => “application/x-ns-proxy
-autoconfig”,
“.swf” => “application/x-shockwave-flash”,
“.tar.gz” => “application/x-tgz”,
“.tgz” => “application/x-tgz”,
“.tar” => “application/x-tar”,
“.zip” => “application/zip”,
“.mp3″ => “audio/mpeg”,
“.m3u” => “audio/x-mpegurl”,
“.wma” => “audio/x-ms-wma”,
“.wax” => “audio/x-ms-wax”,
“.ogg” => “audio/x-wav”,
“.wav” => “audio/x-wav”,
“.gif” => “image/gif”,
“.jpg” => “image/jpeg”,
“.jpeg” => “image/jpeg”,
“.png” => “image/png”,
“.xbm” => “image/x-xbitmap”,
“.xpm” => “image/x-xpixmap”,
“.xwd” => “image/x-xwindowdump”,
“.css” => “text/css”,
“.html” => “text/html”,
“.htm” => “text/html”,
“.js” => “text/javascript”,
“.asc” => “text/plain”,
“.c” => “text/plain”,
“.conf” => “text/plain”,
“.text” => “text/plain”,
“.txt” => “text/plain”,
“.dtd” => “text/xml”,
“.xml” => “text/xml”,
“.mpeg” => “video/mpeg”,
“.mpg” => “video/mpeg”,
“.mov” => “video/quicktime”,
“.qt” => “video/quicktime”,
“.avi” => “video/x-msvideo”,
“.asf” => “video/x-ms-asf”,
“.asx” => “video/x-ms-asf”,
“.wmv” => “video/x-ms-wmv”
)

# Use the “Content-Type” extended attribute to obtain mime type if possible
# mimetypes.use-xattr = “enable”

#### accesslog module
# accesslog.filename = “/www/logs/access.log”

## deny access the file-extensions
#
# ~ is for backupfiles from vi, emacs, joe, …
# .inc is often used for code includes which should in general not be part
# of the document-root
url.access-deny = ( “~”, “.inc” )

######### Options that are good to be but not neccesary to be changed #######

## bind to port (default: 80)
#server.port = 81

## bind to localhost (default: all interfaces)
#server.bind = “grisu.home.kneschke.de”

## error-handler for status 404
#server.error-handler-404 = “/error- handler.html”
#server.error-handler-404 = “/error-handler.php”

###### virtual hosts
##
## If you want name-based virtual hosting add the next three settings and load
## mod_simple_vhost
##
## document-root =
## virtual-server-root + virtual-server-default-host + virtual-server-docroot or
## virtual-server-root + http-host + virtual-server-docroot
##
#simple-vhost.server-root = “/home/weigon/wwwroot/servers/”
#simple-vhost.default-host = “grisu.home.kneschke.de”
#simple-vhost.document-root = “/pages/”

##
## Format: .html
## -> …./status-404.html for ‘File not found’
#server.errorfile-prefix = “/home/weigon/projects/lighttpd/doc/status-”

## virtual directory listings
#server.dir-listing = “enable”

## send unhandled HTTP-header headers to error-log
#debug.dump-unknown-headers = “enable”

### only root can use these options
#
# chroot() to directory (default: no chroot() )
#server.chroot = “/”

## change uid to (default: don’t care)
#server.username = “wwwrun”

## change uid to (default: don’t care)
#server.groupname = “wwwrun”

#### compress module
#compress.cache-dir = “/tmp/lighttpd/cache/compress/”
#compress.filetype = (“text/plain”, “text/html”)

#### fastcgi module
## read fastcgi.txt for more info
fastcgi.server = ( “.php” =>
( “grisu” =>
(
# “host” => ” 172.17.1.20″,
# “port” => 1026,
“bin-path”=> “/bin/php”,
“socket”=>”/tmp/php.socket”
)
)
)

#### CGI module
#cgi.assign = ( “.pl” => “/usr/bin/perl”,
# “.cgi” => “/usr/bin/perl” )
#

#### SSL engine
#ssl.engine = “enable”
#ssl.pemfile = “server.pem”

#### status module
# status.status-url = “/server-status”
# status.config-url = “/server-config”

#### auth module
## read authentification.txt for more info
# auth.backend = “plain”
# auth.backend.plain.userfile = “lighttpd.user”
# auth.backend.plain.groupfile = “lighttpd.group”

# auth.backend.ldap.hostname = “localhost”
# auth.backend.ldap.base-dn = “dc=my-domain,dc=com”
# auth.backend.ldap.filter = “(uid=$)”

# auth.require = ( “/server-status” =>
# (
# “method” => “digest”,
# “realm” => “download archiv”,
# “require” => “group=www|user=jan|host= 192.168.2.10″
# ),
# “/server-info” =>
# (
# “method” => “digest”,
# “realm” => “download archiv”,
# “require” => “group=www|user=jan|host=192.168.2.10″
# )
# )

#### url handling modules (rewrite, redirect, access)
# url.rewrite = ( “^/$” => “/server-status” )
# url.redirect = ( “^/wishlist/(.+)” => ” http://www.123.org/$1″ )

#
# define a pattern for the host url finding
# %% => % sign
# %0 => domain name + tld
# %1 => tld
# %2 => domain name without tld
# %3 => subdomain 1 name
# %4 => subdomain 2 name
#
# evhost.path-pattern = “/home/storage/dev/www/%3/htdocs/”

#### expire module
# expire.url = ( “/buggy/” => “access 2 hours”, “/asdhas/” => “access plus 1 seconds 2 minutes”)

#### ssi
# ssi.extension = ( “.shtml” )

#### rrdtool
# rrdtool.binary = “/usr/bin/rrdtool”
# rrdtool.db-name = “/var/www/lighttpd.rrd”

Step 9 : Start the lighttpd
Login to the ngw100 and start the lighttpd server by issuing this command :

# lighttpd -f /etc/lighttpd.conf

Step 9 : Testing
- Create a simple file at /nfs/www, for testing :
- nano /nfs
#jed /nfs/www/index.php
<?php echo phpinfo() ; ?>

Open your brower and enter the address of ngw100 :

http://172.17.1.20/index.php

—References–:
[1]http://trac.lighttpd.net/trac/ticket/580


Responses

  1. Hi!
    When I try to generate the configure-file with

    CC=avr32-linux-gcc ./configure –host=avr32-linux –prefix=/home/wildan/netherland-project/ngw100/packagesByW/php/dist/ –enable-fastcgi –enable-sockets –enable-discard-path –enable-force-redirect –with-config-file-path=/tmp –disable-ipv6 –without-iconv –disable-xml –without-pear –disable-xmlreader –disable-xmlwriter –disable-libxml –disable-dom –disable-simplexml –with-pdo-sqlite=/home/wildan/netherland-project/ngw100/packagesByW/sqlite/

    then I get such error message:
    configure: warning: –host=avr32-linux: invalid host type
    configure: warning: –prefix=/home/wildan/netherland-project/ngw100/packagesByW/php/dist/: invalid host type
    configure: error: can only configure for one host and one target at a time

    Can anyone help me? I had not seen any answer in the internet.
    Thanks
    Christoph

  2. Please use the newest make from savannah which recognize avr32-linux architecture …

    Best Regards
    Wildan

  3. I have the newest make version, but I also tried it with the newest version from savannah. But it still not work.
    Any more ideas?

    Christoph

  4. Sorry, automake was not installed.
    At the moment I have the problem that a new error is shown:
    bash: ./configure: No such file or directory

    Christoph

  5. For the easiest way ..,
    Do you ever try the buildroot envrotment
    provided by atmel ?

    http://www.atmel.no/buildroot/

    I’m sure this tool will make you life more easy ..:)

    Best Regards,
    Wildan

  6. Hi ,

    I installed php and lighttpd, the problem now is that I can not get proper web server lighttpd.

    If someone at an idea that could help me here because I drown.

    Code:
    -sh-3.2#lighttpd -f etc/lighttpd.conf
    -sh-3.2# /bin/php: can’t resolve symbol ‘mblen’
    /bin/php: can’t resolve symbol ‘__avr32_s32_to_f32′
    /bin/php: can’t resolve symbol ‘/bin/php: can’t resolve symbol ‘mblen’
    mblen’
    /bin/php: can’t resolve symbol ‘__avr32_s32_to_f32′
    /bin/php: can’t resolve symbol ‘__avr32_s32_to_f32′
    /bin/php: can’t resolve symbol ‘mblen’
    /bin/php: can’t resolve symbol ‘__avr32_s32_to_f32′
    2006-12-31 23:11:37: (log.c.75) server started
    Out of memory: kill process 238 (portmap) score 100 or a child
    Killed process 238 (portmap)
    Out of memory: kill process 392 (lighttpd) score 98 or a child
    Killed process 393 (php)
    Out of memory: kill process 392 (lighttpd) score 79 or a child
    Killed process 394 (php)
    Out of memory: kill process 395 (php) score 73 or a child
    Killed process 397 (php)
    Out of memory: kill process 302 (proftpd) score 61 or a child
    Killed process 302 (proftpd)

    Best Regards

  7. This is ABSOLUTELY AMAZING!!
    I could finally build the Temperature server.
    Tons of thanks to you. d(´・ω・)b

    Flash Temperature Server.
    http://mustapha.hopto.org/gauge.html

  8. Add avr32 beside avr keywords inside config.sub.
    | avr | avr32 >

    This will help!

  9. Hallo,

    i’m trying to install PHP on NGW100.
    I’m using Cygwin.

    Compiling Lighttpd, works fine, but i have problems running configure PHP.

    ….
    checking lex output file root… ./configure: line 3246: lex: command not found
    configure: error: cannot find output from lex; giving up
    …..

    How to install flex bison ?

    Regards,

    Gordian

  10. I have the same problem as JRapin. I get the following output when executing php on the AVR32 board:

    -sh-3.2# php -v
    php: can’t resolve symbol ‘mblen’
    php: can’t resolve symbol ‘__avr32_s32_to_f32′
    PHP 5.1.6 (cli) (built: Jul 9 2008 16:40:42)
    Copyright (c) 1997-2006 The PHP Group
    Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    -sh-3.2#

    Php works fine, but the error message is kinda annoying. Anyone got it fixed?

    P.S.: To install flex bison (in ubuntu) just type sudo apt-get install flex bison in a console on the HOST system.

  11. Hallo,

    trying to configure PHP i always have the same error:

    ……
    ……
    checking for sqlite 3 support for PDO… yes
    checking for PDO includes… checking for PDO includes… /ph
    checking for sqlite3 files in default path… not found
    configure: error: Please reinstall the sqlite3 distribution

    i already have reinstalled the sqlite package, but there are no changes :-(

    What is the reason for this error ?
    How to solve the problem ?

    Thanks

    Gordian

  12. I have a problem getting this to work.

    For the PHP-part:
    Nomatter what I do, it always complains about the two arguments after host and prefix in this line:
    CC=avr32-linux-gcc ./configure –host=avr32-linux –prefix=/opt/packages/php –enable-discard-path -enable-force-redirect [more arguments]
    Why is that?

    If I remove “enable-discard-path” it just complains about the next one with the same error (“invalid host”).

    The error looks like this:
    —————————
    configure: warning: -host=avr32-linux: invalid host type
    configure: warning: -prefix=/opt/packages/php: invalid host type
    —————————

  13. Hi, i have tryed to compile through the buildroot but i get an error.
    sapi/cgi/php-cgi ERROR 1
    and another ./built ERRO 2

    I would appreciatte any help.

    Thanks

  14. To those getting the error that the first comment has “invalid host”, the answer is that your browser has turned the “- – ” into “-”

    You need to make sure they are two dashes. So the command starts wtih:

    CC=avr32-linux-gcc ./configure –host=avr32-linux

  15. [...] to compile PHP and Lighttp using the instructions found on Wildan Maulana’s blog entitled Compiling PHP & lighttpd for avr32, but it was less then ideal. After some experimentation and Googling, I discovered that with [...]

  16. Hi!

    I want to ask everybody why not to host somewhere binaries for lighthttpd, php, mysql, sqlite for NGW1000? Because doing everything to successfully build this applications is not a simple task for beginners…

    With the best wishes,
    Eldar Ablaev.

  17. Hallo Eldar,

    Ok, I hope i have spare time this weekend todo that, i will host the binaries on google code

    Warm Regards from Indonesia,
    Wildan Maulana


Leave a response

Your response:

Categories