view · edit · print · history

Plead: Could someone please make it so we can use system() and exec() commands in PHP

(The answer seems to be "no"; as is noted below, running Apache in Prefork mode, which is necessary to support this, "uses too much memory to be useful on a slug, even when configured conservatively." If you want to experiment, note that Debian has Apache packages for each of the different MPM modes including Prefork, so you could try that.)

Some work has been done on building apache 2.0.x and php 5.x within the unslung package system. The relevant packages are:

  • apr - the Apache Portable Runtime library
  • apr-util - the Apache Portable Runtime Utility library
  • apache - the Apache web server
  • apache-manual - the online HTML manuals for Apache (not needed for operation)
  • php-apache - a PHP module for Apache
  • php - core php support (does not depend on apache)
  • php-ldap - LDAP extension for php
  • php-gd - GD extension for php (graphics and images)
  • php-mbstring - mbstring extension for php
  • php-mysql - MySQL extension for php
  • php-dev - php native development package
  • php-pear - php PEAR support
  • eaccelerator - byte-code cache and peephole optimizer for php

Apache will listen on port 8000 (so as not to get in the way of the built-in web server) by default.

Apache vs. thttpd

Php-thttpd has a subset of the features of apache, and is much more resource-cheap. The main extra features apache has are:

  • Support for .htaccess files.
  • Support for authentication and SSL.
  • Ability to serve multiple clients concurrently.
  • Support for apache-specific CGI extensions. Many publically available CGI scripts make use of these.

If you don't need to serve more than one client, and don't need use any of the other features of apache, you are recommended to use php-thttpd instead.

Known issues

  • heavy memory use: By default, apache will run with all modules enabled; this causes it to have quite a large memory footprint. Users are encouraged to edit httpd.conf and disable modules they do not need. You should edit httpd.conf to insert your email address, and the hostname of your server in appropriate places anyway. If you don't need all the features of apache, php-thttpd is an alternative.
  • no suexec: Apache is configured without suexec support. This is because apache runs as user nobody on the slug. Suexec is only safe when the UID under which Apache runs is not used for anything else. (i.e. we would need an "apache" user in /etc/passwd).
  • no installed build environment: The apr and apr-util packages do not contain headers, or other parts of the apr build environment. This means that you cannot build an Apache module except inside the Unslung build system (look in php.mk to see how). There is a good reason for this, which is described below.
  • no exec(), system() or similar functions available in php: This version of the pkg has the apache worker MPM modules. Becasue of certain problems with threading, any system() type of calls from php scripts will hang the server. It may be possible to build a version with prefork module (instead of the current worker module) and that might overcome this problem. [Chacko 2006.04.05]

Configuration notes

  • Apache is running the "Worker" multiprocessing module, and if you installed the httpd.conf file from a recent package release, will run a small number of threads (about 25) within a single process. Because of the way threads work in linux, process tools such as ps and top will report these threads as extra processes.
  • Because of the worker MPM, it's very important that all apache modules and their dependencies be thread-safe. If you have encountered a bug that may be due to lack of thread-safety of a dependent library, please report the bug to the nslu2-linux mailinglist.
  • We chose to use worker because the prefork MPM simply uses too much memory to be useful on a slug, even when configured conservatively.
  • If you want SSL support, you will need to edit /opt/etc/init.d/S80apache to include a "-D SSL" on the httpd command line. Follow the HowTo Apache HTTPS Instructions for more information.

Developer notes

Apache comes with quite a complicated build system of its own. The most familiar face of this is apxs, a perl script which can be used to build and install apache modules. Apxs "knows" the exact CC and LD that were used to build apache; it can also invoke a customised version of libtool; and copy makefile fragments containing hardcoded paths into various places. Similar complexities afflict apr-config and apu-config, which are the build tools installed by apr and apr-util respectively. Obviously all this is nasty to deal with when doing a staged cross-build.

I've configured apr, apr-util, and apache in such a way that the build system components end up containing paths that lead to the unslung staging directory, while other components, like libraries, contain only paths that make sense on the target system. (For example, for apr this is done by configuring with prefix=$(STAGING)/opt and libdir=/opt/lib). At staging time I install the whole lot into the staging directory. At packaging time, the build system is discarded (it is useless as it is full of hard-written paths that only make sense on the build machine).

The upshot of all this is the apxs binary found in the unslung staging area after "make apache-stage" can be used to build Apache modules from within Unslung. It will use whatever compiler and other tools were used to build apr, and will link opposite libraries in the staging directory. So building an Apache module within Unslung should be as simple as configuring --with-apxs=$(STAGING_DIR)/opt/sbin/apxs. Look at PHP for an example.

-- jp30

For Apache questions or issues, you may wanna search this large unofficial Apache Forum hosted by Nabble which currently archives all the Apache projects' mailing lists to allow cross search and browsing. If you could not find an answer, you can post your question to the approriate sub forum which will forward your post to the corresponding mailing list.

-- Alsopache

Access and error logs for this are at: /opt/var/apache2/log/


--issue i have a problem i only can see text if i want to acces an php page changed index page option => index.php maybe noob but i just dont get it i installed php 2 what am i doing wrong . i got it running befor i fuck up my first hdd and now its just not working


--issue I 'upgraded' to the latest version of apache and I can no longet run PHP, I have tried a clean install and it still doesn't work (same as Jeremy's issue by the sounds of it.) I have come to the conclusion that PHP with the new version of Apache is broken in some way. Can anyone confirm or give me a work around?


I did an ipkg upgrade and got this:

  1. ipkg upgrade

Configuring apache update-alternatives: Linking //opt/sbin/htpasswd to /opt/sbin/apache-htpasswd httpd: Syntax error on line 233 of /opt/etc/apache2/httpd.conf: Cannot load /opt /libexec/mod_access.so into server: /opt/libexec/mod_access.so: cannot open shar ed object file: No such file or directory httpd: Syntax error on line 233 of /opt/etc/apache2/httpd.conf: Cannot load /opt /libexec/mod_access.so into server: /opt/libexec/mod_access.so: cannot open shar ed object file: No such file or directory postinst script returned status 1 ERROR: apache.postinst returned 1 Nothing to be done

Now Apache does not run. I have Unslung V2.3R63-uNSLUng-6.8-beta. What do I need to do?

3/14/07 - i did ipkg install apache and get this error at the end:

An error ocurred, return value: 22. Collected errors: ipkg_download: ERROR: Command failed with return value 1: `wget --passive-ftp -q -P /tmp/ipkg-J1ZfYd? http://ipkg.nslu2-linux.org/feeds/unslung/cross/cyrus-sasl-libs_2.1.22-1_armeb.ipk' Failed to download cyrus-sasl-libs. Perhaps you need to run 'ipkg update'?

i did run ipkg update before installing, it downloads all the other files fine except for that one.

3/15/07 - Trying to install webdav-module I am trying to install a webdav module but didn't really get the part about the staging. Can someone please post the commandoes I need to run. I have unpacked the source and am trying to run ./configure --with-apxs in the source folder...

3/22/07 - ipkg upgrade problem
After using ipkg upgrade, my slugs Linksys pages only disply through my intranet, with the main page visable by browsing It no longer is visable from the internet. Same problem with apache runing from The slug simply does not seem to be brodcasting to the INTERNET connection. This only happens after the ipkg upgrade.

I can see disk 1 and disk 2 from an external connection using FTP but cannot log into password protected locations of the disk.

What has ipkg upgrade done?

Answer: The Apache config file must specify the server name.

7/07/07 - apache zombie issues on OpenWrt

After successfully installing Optware on my OpenWrt WRT54GS with SD mod, I tried to install apache. It starts, but can't serve web pages and the httpd processes go zombie (as via ps aux). The /opt/var/apache/log/error_log only status apache is resuming normal operations, and nothing is logged via /opt/var/log/access_log. Any ideas?

I intially installed on WhiteRussian (RC5), but later reflashed and tried again on Kamikaze 7.06 as indicated in the Optware guide. The same issue appeared both times, though on Kamikaze mod_unique_id doesn't seem to work as well. On WhiteRussian all modules seemed to load without error.

05/08/2007 Performed an upgrade from 2.0 to 2.2.

Biggest gripe is that for some reason it trampled my index.html so that my old web server was lost. Will have to spend several hours rewriting index.html since I didn't have a backup. My fault really. I had symlinked www to my directory.

Why trample index.html???

Also my old conf file can't load modules but I am still investigating.

Page last modified on August 08, 2007, at 02:20 PM