OpenWrt Forum Archive

Topic: PHP error

The content of this topic has been archived on 22 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Both /usr/bin/php-cgi and /usr/bin/php-fcgi returns:

[apc-error] apc_shm_create: shmget(0, 31457280, 914) failed: Cannot allocate memory. It is possible that the chosen SHM segment size is higher than the operation system allows. Linux has usually a default limit of 32MB per segment.

How can I get around this? Thx.

Why are you trying to run php-cgi from command line? php-cli runs fine.

However, php-cgi doesn't seem to be working with the web server (lighttpd), either. So, this error from command line (I get it as well) and my problem with lighttpd may be manifestations of the same root cause.

Please post here if you figure it out - for now it looks like we are both stuck sad

Hi, I managed to get it to work. To get around that apc-error just mount swap, I used usb hdd and cca 300MB of space. I am currently using php-cgi according to http://forum.openwrt.org/viewtopic.php?id=10330.

krotus wrote:

To get around that apc-error just mount swap, I used usb hdd and cca 300MB of space

Did you repartition your usb hdd (to create swap partition)? I would hope that it wouldn't be necessary; but if it's the only way to go - hey, what can I say!

No, I am swapping into file.

mkswap /path/filename
swapon /path/filename

You need to create the file of desired size at first, for example with dd command, or you can use existing file.

krotus

You are awesome! Thank you very much. Creating swap file also got php-cgi working inside lighttpd.

To the developers: it's still needs to be fixed, right?

I noticed that I need to run swapon after reboot. Therefore, I can't start lighttpd/php automatically, because it dies until I run swapon.

It's not a big deal for me, since I am rebooting router once a month or so.

On the second thought, there may be a different reason. My USB partition isn't mounted automatically. If there is a way to make it mount that would be nice (somehow in fstab, I guess...). I am assuming that most people have swap file (200-300MB, as recommended by krotus) on the external drive, so this probably applies to everybody.

Anyway, I have to
1. mount USB drive (X-Wrt allows you to do it through UI - nice!)
2. swap /mnt/myswapfile.swp
3. /etc/init.d/lighttpd start

Hope it helps somebody!

Before I reboot next time, I'll try to put these commands in /etc/init.d/custom-user-startup

(Last edited by ymhee_bcex on 20 Mar 2009, 04:29)

instead of using lighttpd, you can go on a smaller approach using busybox's httpd but you still have to use the swapfile

opkg install php5-cgi


mkdir /www2
echo "<?php
             phpinfo();
         ?>" > /www2/index.php

edit php.ini :
change doc_root to /www2
uncomment cgi.force_redirect and set it to 0

edit/create /etc/httpd.conf:
*.php:/usr/bin/php-cgi

edit /etc/config/httpd
add after last option config:

config 'httpd'
        option 'port' '81'
        option 'home' '/www2'
        option 'c_file' '/etc/httpd.conf'



then http://routerip:81/index.php

have fun

kadettgte wrote:

instead of using lighttpd, you can go on a smaller approach using busybox's httpd but you still have to use the swapfile

opkg install php5-cgi


mkdir /www2
echo "<?php
             phpinfo();
         ?>" > /www2/index.php

edit php.ini :
change doc_root to /www2
uncomment cgi.force_redirect and set it to 0

edit/create /etc/httpd.conf:
*.php:/usr/bin/php-cgi

edit /etc/config/httpd
add after last option config:

config 'httpd'
        option 'port' '81'
        option 'home' '/www2'
        option 'c_file' '/etc/httpd.conf'



then http://routerip:81/index.php

have fun

i had install php5?php5-cgi  ,ang do this ,but http://routerip:81/index.php      ,it is error: HTTP 404  found
# php-cgi info.php
Status: 404 Not Found
X-Powered-By: PHP/5.2.6
Content-type: text/html

No input file specified.


and i do  :   http:/routerip:81/index.html( it is rtorrent index.html ) , it is error: loading....., then note: 404 not found  !  Your web server does not support PHP. Correct this and try again.

?

I  do  this  because i want to manage rtorrent  on web , how can i do ?   thk!

(Last edited by ccbcfan on 28 Dec 2009, 17:12)

if you're using my configuration, you must put files under /www2 and in phpini set the docroot to /www2

THKS!!

This is my conf:

opkg install php5-cgi                  #all right


mkdir /jffs/www-rt                        #my homedir=/jffs/www-rt   
echo "<?php
             phpinfo();
         ?>" > /jffs/www-rt/11.php     

edit php.ini :
change doc_root to /jffs/www-rt                       # my homedir=/jffs/www-rt
uncomment cgi.force_redirect and set it to 0          # i do  it

edit/create /etc/httpd.conf:                       #all right
*.php:/usr/bin/php-cgi                           

edit /etc/config/httpd
add after last option config:

config 'httpd'                                    #
        option 'port' '88'                       #  my port=88
        option 'home' '/jffs/www-rt'              #  my homedir=/jffs/www-rt
        option 'c_file' '/etc/httpd.conf'   #  all right

i put all rtorrent web files to /jffs/www-rt ,

then http://routerip:88/11.php      # i also do http://routerip:88/index.html


But error.

Is this homedir must set to /www2 ?    and   can‘t I reset to anyother  dir ???

(Last edited by ccbcfan on 29 Dec 2009, 01:47)

ups, sorry, my bad, try to add *.html:/usr/bin/php-cgi to /etc/httpd.conf , and yes you cant put the homedir to whatever you like as long as you update all the other configs

all right ,now PHP-info is work well !

and can go in rutorrent , but no download date,  log error :

[29.12.2009 23:45:50] WebUI started.
[29.12.2009 23:45:56] PHP module PCRE is not installed. ruTorrent will not work.         #i had install  php5-mod-pcre
[29.12.2009 23:45:58] Bad response: (501) <HTML><HEAD><TITLE>501 Not Implemented</TITLE></HEAD> <BODY><H1>501 Not Implemented</H1> The requested method is not recognized </BODY></HTML>


ON my pc ntorrent work well  through router port 22,  rtorrent is 0.8.6  ? rutorrent is 2.8   ?

.rtorrent.rc     conf:

scgi_port = :5000
umask = 0000
encoding_list = UTF-8

(Last edited by ccbcfan on 29 Dec 2009, 17:10)

after installing php5-mod-pcre go to /etc/php.ini and uncomment extension=pcre.so or something like that smile

vi /etc/php.ini

;extension=ftp.so
;extension=gd.so
;extension=mysql.so
extension=pcre.so
;extension=session.so
;extension=sockets.so
;extension=xml.so



i do it : uncomment extension=pcre.so

then open http://routerip:88/rtorrent/index.html   in Firefox

it stoped at loading........!     

Are you sure that httpd+php5+rutorrent  is work well ?  anythoer need   installed ?

with rutorrent i do not know, but with simplestuff like phpsysinfo , yes, it works, try to set display_errors to on

hummm i managed to get my rutorrent to work, but it's sluggish as hell to start

I set display_errors to on

php log:

rutorrent 1.7 error log:

[01-Jan-2010 16:36:09] PHP Warning:  Cannot load module 'pdo_sqlite' because required module 'pdo' is not loaded in Unknown on line 0
[01-Jan-2010 16:36:13] PHP Warning:  Cannot load module 'pdo_sqlite' because required module 'pdo' is not loaded in Unknown on line 0
[01-Jan-2010 16:36:15] PHP Warning:  Cannot load module 'pdo_sqlite' because required module 'pdo' is not loaded in Unknown on line 0

rutorrent 2.8 error log:

[01-Jan-2010 6:38:01] PHP Warning:  Cannot load module 'pdo_sqlite' because required module 'pdo' is not loaded in Unknown on line 0
[01-Jan-2010 16:38:02] PHP Fatal error:  Balloc() allocation exceeds list boundary in /jffs/www2/rtorrent/xmlrpc.php on line 14

that's weird, are you using trunk or 8.09 ?

I am using trunk of Kamikaze (r18405)?

/etc/httpd.conf  ?

*.php:/usr/bin/php-cgi
*.html:/usr/bin/php-cgi

/etc/php.ini   ?

extension=pdo.so
extension=pdo_sqlite.so
;extension=ftp.so
;extension=gd.so
;extension=mysql.so
extension=pcre.so
extension=session.so
extension=sockets.so
extension=xml.so


now  php.log ?

[02-Jan-2010 01:05:41] PHP Fatal error:  Balloc() allocation exceeds list boundary in /jffs/www2/rtorrent/xmlrpc.php on line 14
[02-Jan-2010 01:10:04] PHP Fatal error:  Balloc() allocation exceeds list boundary in /jffs/www2/rtorrent/xmlrpc.php on line 14



I look lighttpd+php+php-fcgi+rutorrent  it work well ! 

http://code.google.com/p/rutorrent/wiki/WebserverSetup

that need set etc/lighttpd.conf:

server.modules = ( 
#    "mod_rewrite",
#    "mod_redirect",
#    "mod_alias",
#    "mod_auth",
#    "mod_status",
#    "mod_setenv",
    "mod_fastcgi",
#    "mod_proxy",
#    "mod_simple_vhost",
#    "mod_cgi",
#    "mod_ssi",
#    "mod_usertrack",
#    "mod_expire",
#    "mod_webdav",
                "mod_scgi",
                "mod_access"

And add code at last:

scgi.server = ( "/RPC2" =>

                   ( "127.0.0.1" =>

                     (

                       "host" => "127.0.0.1",

                       "port" => 5000,

                       "check-local" => "disable"

                     )

                   )

                )


For the Apache web-server:
Install the module mod_scgi. If don't know where to get it for your sustem, download it's sources and compile it by yourself.
Add the following string to the configuration file (httpd.conf):
SCGIMount /RPC2 127.0.0.1:5000



I  try add set my /etc/httpd.conf:
SCGIMount /RPC2 127.0.0.1:5000

but not start httpd, error :  httpd: config error 'SCGIMount/RPC2127.0.0.1:5000' in '/etc/httpd.conf'

Is luci-httpd  without mod_scgi  ?

and I think : how to set in  my  /etc/httpd.conf   ?

(Last edited by ccbcfan on 2 Jan 2010, 06:04)

The discussion might have continued from here.