cannot get lighttpd configured to PHP 7 - php

Apart from logging to the wrong file (the error log defined for that vhost defined last),
lighty does not let me use PHP 7. What am I missing?
cgi.fix_pathinfo is enabled in /etc/php/7.0/fpm/php.ini.
How can I make sure you're using the FastCGI-enabled version? What else should I look for?
version info (shrinked to the necessary)
> lsb_release -a
Description: Ubuntu 16.04.1 LTS
Codename: xenial
> lighttpd -v
lighttpd/1.4.35 (ssl) - a light and fast webserver
Build-Date: Apr 18 2016 15:36:10
> php -v
PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
> php-cgi -v
PHP 5.6.23-1+deprecated+dontuse+deb.sury.org~trusty+1 (cgi-fcgi)
> php-fpm7.0 -v
PHP 7.0.8-0ubuntu0.16.04.3 (fpm-fcgi)
lighty config file excerpt
> head -41 /etc/lighttpd/lighttpd.conf | tail -9
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "1000"
),
"broken-scriptfilename" => "enable"
)))
tryouts
If I change the socket to an invalid path, restarting lighttpd works fine; but the server is unreachable. (bind failed for: (invalid path) in the error log); so this seems like the correct config file.
Modifying /etc/lighttpd/conf-available/15-fastcgi-php.conf in the same way has no effect at all.
Changing the socket to "/var/run/php/php7.0-fpm.sock" has no effect either (php_info() still says PHP 5.6 after restarting lighty).
After changing bin-path to /usr/sbin/php-fpm7.0 , I still get no error when restarting lighttpd, but the web server is unreachable.
error log excerpt
> tail /var/log/lighttpd/error.log
(no output)
> tail /var/log/lighttpd/somevhost/error.log
2016-10-10 16:48:02: (log.c.164) server started
2016-10-10 16:48:02: (mod_fastcgi.c.1112) the fastcgi-backend /usr/sbin/php-fpm7-0 failed to start:
2016-10-10 16:48:02: (mod_fastcgi.c.1116) child exited with status 2 /usr/sbin/php-fpm7-0
2016-10-10 16:48:02: (mod_fastcgi.c.1119) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.
If this is PHP on Gentoo, add 'fastcgi' to the USE flags.
2016-10-10 16:48:02: (mod_fastcgi.c.1406) [ERROR]: spawning fcgi failed.
2016-10-10 16:48:02: (server.c.1022) Configuration of plugins failed. Going down.
update
I just uninstalled php5 hoping this would resolve the issues; but that didnĀ“t help either. Instead, I seem to have no way to get php5 back.

Tried a search engine?
https://www.google.com/?gws_rd=ssl#q=lighttpd+ubuntu+php+7
The first hit:
https://www.howtoforge.com/tutorial/installing-lighttpd-with-php7-php-fpm-and-mysql-on-ubuntu-16.04-lts/
suggests
## Start an FastCGI server for php (needs the php7.0-cgi package)
fastcgi.server += ( ".php" =>
((
"socket" => "/var/run/php/php7.0-fpm.sock",
"broken-scriptfilename" => "enable"
))
)
to go along with php.ini cgi.fix_pathinfo=1
You can follow the instructions on the page above to have Ubuntu run php7.0-fpm as a service, or you can configure lighttpd to start up the fastcgi.server backend by setting "bin-path" in the fastcgi.server definition, but do not do both.

Related

No oci8 module in phpinfo()

I try to set up connection with oracle database, but I still can't even set up the module. I have rhel 7. 2 server, and I followed whole tutorial for setting up oracle instantclient and configured it with php. One thing I completely don't understand is that oci8 module displays after php -i execution:
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.3
Revision => $Id: 59f993160cf983dd24bb391b68a65a17303d2dba $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
But there is no such module in phpinfo() inside the script. How to fix it?
PHP Version 7.0.13
Server Apache (httpd)
LD library path:
[![enter image description here][2]][2]
The common problem would be that LD_LIBRARY_PATH isn't set for Apache.
Try adding it to /etc/sysconfig/httpd like:
LD_LIBRARY_PATH=/full/path/to/oracle-client
If I have my versions right, this version of Apache (i) doesn't like the export keyword for setting variables (ii) requires a full path since it won't expand environment variables. If I'm wrong, try either or both of those.
There is a lot of information about setting the environment in the free Underground Oracle & PHP Manual, see, for example 'Setting Oracle Environment Variables for Apache' on p 108
You say you followed 'whole tutorial'. There are many tutorials. I'd recommend Oracle's installation instructions.
The answer is:
setsebool -P allow_execstack 1
You also can enable executable stack for only oci8.so with:
execstack -c /usr/lib64/php/modules/oci8.so
https://serverfault.com/questions/314336/centos-6-php-can-not-load-gdchart-so-and-oci8-so-compiled-by-me
make sure that the oci8.so is in the php extension folder
in centos is /usr/lib64/php/modules
in ubuntu xammp is /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
cd <extension folder >
sudo chmod 755 oci8.so
It works for me after
ps ax | grep "fpm"
check the pid of "php-fpm: master process"
sudo kill -9 <pid>
start php-fpm again
sudo service php-fpm start
inspired by https://stackoverflow.com/a/21693610/2538630

Call to undefined function oci_connect, php_oci8_12c.dll, windows 8.1, php5.6.6

I have a simple php script:
<?php
$db_user = 'myusername';
$db_pass = 'mypassword';
$db_sid = 'mysid';
$conn = oci_connect( $db_user, $db_pass, $db_sid );
?>
When I run it (from a browser or from the command line), I get the error:
Call to undefined function oci_connect
I'm using php 5.6.6 which came with php_oci8_12c.dll already there.
I have extension=php_oci8_12c.dll in my php.ini
I have installed instant client (12.1) - tried 32 bit version AND 64 bit version
I have ORACLE_HOME and TNS_ADMIN environment variables pointing at the instant client folder ( C:\instantclient_12_1 ).
I also have C:\instantclient_12_1 in my path
I have a tnsnames.ora in that same folder with this relevant entry in it:
MYSID =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost.net)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MYSERVICE)
)
)
I have also downloaded SQLDeveloper from http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
SQLDeveloper works, recognizes the above mentioned tnsnames.ora and connects and successfully runs a query on the same database that my php script is trying to access.
I have spent several hours over several days trying different things to no avail.
I'm using:
php 5.6.6
windows 8.1
IIS (so no answers involving apache please)
cmd (run as administrator)
Oracle Database 11g Enterprise Edition 11.2.0.3.0
Some other information that might prove useful:
I would ideally like to use oci 1.4.10 to match the production server, but not too worried about that for now.
pear install oci8-1.4.10.tgz
gives me this error:
The DSP oci8.dsp does not exist
I can't find any explanation on that error that means anything to me.
What am I missing - can anyone help me
EDIT:
I have tried the various suggestions in other posts on stackoverflow, namely:
extension=oci8.so with and without extension=php_oci8_12c.dll
I don't have the line extension=php_oracle.dll in my php.ini file
EDIT:
phpinfo tells me that I am using the correct php.ini file:
Loaded Configuration File => C:\php5.6.6\php.ini
This line from phpinfo might also be of use:
Configure Command => cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--disable-isapi" "--disable-nsapi" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-sdk\oracle\x86\instantclient_12_1\sdk,shared" "--with-enchant=shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--without-analyzer" "--with-pgo"
EDIT:
It seems that dsp files are VC++ project files - I am now venturing on learning how to create a php extension, and hopefully when I've done that I'll have enough knowledge to compile the oci8 1.4.10 source code into a dll that works on windows 8 - unless somebody rescues me with the answer to this question - this looks like it is going to take me some time :-)
EDIT:
Adding display_startup_errors = On to php.ini tells me that the oci dll is not a valid Win32 application
Edit: Hmm. Trying this on Windows 8 appears to generate the same error as you specified. I'm currently investigating...
My mistake (I had enabled the wrong extension_dir line). It works in Win8 just as documented below.
The following steps should be all you need to get OCI working with PHP (I've just verified this on a freshly installed Windows 2008 R2 Standard x64 virtual machine):
Download and extract PHP (I used C:\php from php-5.6.7-nts-Win32-VC11-x86.zip).
Download and extract InstantClient (I used C:\instantclient_12_1 from instantclient-basic-nt-12.1.0.2.0.zip).
Add the above paths to the system path.
Copy c:\php\php.ini-production to c:\php\php.ini.
in php.ini:
enabled line extension_dir = "ext".
enabled line extension=php_oci8_12c.dll.
Install Microsoft Visual C++ 2010 Runtime (x86). This is needed for the OCI8 extension.
Install Microsoft Visual C++ 2012 Runtime (x86). This is needed for PHP.
At this point running php --ri oci8 in a command prompt shows me the following output:
C:\>php --ri oci8
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.0.9
Revision => $Id: f5a3ee1083d1ffa6adb5143efda6eafa210b8414 $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off
Statistics =>
Active Persistent Connections => 0
Active Connections => 0
And checking for the oci_connect function:
C:\>php -r "var_dump(function_exists('oci_connect'));"
bool(true)
In addition to what was said to fix the problem, I would like to add the php CLI side of things, as some people need to run OCI-enabled applications in CLI mode. In my case, I had to copy an instance of oci.dll into the wamp/bin/php/php<version>/ folder for php --ri oci8 to show that oci8 was correctly loaded. That doesn't prove that other files were not needed to correctly run a full-fledged application (see my technical footnote).
Including the path to the instantclient 12 distribution wouldn't do it.
Technical notes:
My environment being: Windows 7 + WAMP3 (php 5.6.15, apache 2.4.17), I was, after a number of experiments, able to narrow down the minimal set of three files that needed to be copied to the bin directory (Apache's for non-cli apps) from the instantclient 12 distribution, to allow instantiate an Oracle adapter within Zend Framework, perform an SQL query and read the recordset.
This set is: oci.dll, oraociei12.dll and orans.dll.
In particular, copying just oci.dll wouldn't allow the application to work (unknow Exception raised)

php custom C++ module works from command line, not on webserver

I made a custom PHP module with C++ and Swig. It works from the command line, but not with my webserver:
php index.php
php-cgi index.php
Both of those work fine.
I'm using lighttpd and php. I didn't configure these in any special way. I just installed them using sudo apt-get install.
Unfortunately if I make a webpage I get this:
Fatal error: Call to undefined function minikey_to_wif() in /var/www/index.php on line 6
Calling function_exists("minikey_to_wif") returns False too.
The phpinfo() does not show my module called minikey, and shows the same configuration path as the file I edited (/etc/php5/cgi/php.ini):
extension=/path/to/php-ext/minikey/minikey.so
I also tried copying it to where the other PHP extensions seem to be installed (/usr/lib/php5/20090626+lfs/) but that didn't work either.
I've been stopping, and starting lighttpd countless times. Each time, when I run ps aux | grep php, there are no results. I've also rebooted a few times to no effect. I have no idea what's up.
OK found the answer.
The extension relied on a library which was installed in a non-standard location. Normally I set LD_LIBRARY_PATH in ~/.bashrc. But when the web server ran the extension, it didn't have that environment variable.
Fix was to create a file in /etc/ld.so.conf.d/genjix.conf with /home/genjix/usr/lib and run ldconfig as root.
Try running phpinfo() using lighty. Make sure that its pointing to the correct php.ini.
If you think this is the problem you can launch php using the -c switch from inside lighttpd.conf with "bin-path" => "/path/to/php-cgi -c /path/to/php.ini":
e.g.
fastcgi.server = (
".php" => (
(
"bin-path" => "/path/to/php-cgi -c /path/to/php.ini",
"socket" => "/tmp/php.socket",
"max-procs" => 4,
"idle-timeout" => 30,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "1000"
)
)
)
)

wso2, wsf-php segmentation fault on script shut down

I'm trying to use WSO2 Web Services Framework for PHP 2.1.0 on Kubuntu 11.04 with php 5.3.5-1ubuntu7.7
I have minimal php installation, xml, xslt, lib-ssl, libaxis2c libraries:
apt-get install php5 php5-dev php5-xsl libxml2-dev libssl-dev libaxis2c
Everything went fine -- compiled, and installed, added to include path.
I see the library in php -i output:
wsf
wsf support => enabled
wsf version => 2.1.0
Directive => Local Value => Master Value
wsf.attachment_cache_dir => /tmp => /tmp
wsf.enable_attachment_caching => 0 => 0
wsf.home => /usr/lib/php5/20090626/wsf_c => /usr/lib/php5/20090626/wsf_c
wsf.log_level => 4 => 4
wsf.log_path => /tmp => /tmp
wsf.rm_db_dir => /tmp => /tmp
So I've tried to access simple web-service:
http://www.w3schools.com/webservices/tempconvert.asmx?wsdl
Like this:
$client = new WSClient(array(
'wsdl'=>'http://www.w3schools.com/webservices/tempconvert.asmx?wsdl'
));
$proxy = $client->getProxy();
$response = $proxy->CelsiusToFahrenheit(array('Celsius'=>11));
Script seems to run fine -- got wsdl, connected, parse response and I can print_r the response data:
Array
(
[CelsiusToFahrenheitResult] => 51.8
)
Then script trying to finish and falls with segmentation fault:
[Fri Apr 6 15:42:35 2012] [info] [rampart] rampart_mod shutdown
[Fri Apr 6 15:42:35 2012] [info] [rahas] Rahas module shutdown
Segmentation fault
If I'll comment the soap call, then segmentations fault will disappear.
Is there a way to eliminate this segfault? Thanks.
Which version of SSL are you using?
I've been trying to figure this out for myself as well and come across this
https://wso2.org/jira/browse/WSFPHP-467

Lighttpd + PHP + FCGI

I have a problem with Lighttpd, PHP and CGI.
I use OpenSUSE.10.
I have builded lighttpd (version 1.4.23) and php (version 5.3.0).
This is lighttpd build command lines:
./configure --prefix=/home/gosh/Desktop/web_server/lighttpd_native_installed --without-zlib --enable-ssl --enable-openssl --with-openssl=/home/gosh/Desktop/web_server/openssl_native_installed --with-openssl-includes=/home/gosh/Desktop/web_server/openssl_native_installed/include --with-openssl-libs=/home/gosh/Desktop/web_server/openssl_native_installed/lib --without-pcre --with-zlib --without-bzip2
make
make install
This is php build command lines:
./configure --prefix=/home/gosh/Desktop/web_server/php_native_installed --without-iconv --disable-libxml --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear --enable-fastcgi --enable-force-cgi-redirect
make
make install
This is php, php-cgi -v:
gosh#suse:~/Desktop/web_server> /home/gosh/Desktop/web_server/php_native_installed/bin/php -v
PHP 5.3.0 (cli) (built: Aug 30 2009 03:56:22)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
gosh#suse:~/Desktop/web_server> /home/gosh/Desktop/web_server/php_native_installed/bin/php-cgi -v
PHP 5.3.0 (cgi-fcgi) (built: Aug 30 2009 03:55:55)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
gosh#suse:~/Desktop/web_server>
This is lighttpd.conf:
server.document-root = "/home/gosh/Desktop/web_server"
server.port = 81
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
index-file.names = ( "index.php" )
server.modules = (
"mod_fastcgi",
"mod_accesslog"
)
accesslog.filename = "/home/gosh/Desktop/web_server/lighttpd_access0.log"
server.accesslog = "/home/gosh/Desktop/web_server/lighttpd_access000.log"
fastcgi.debug = 1
fastcgi.server = (
".php" =>
((
"bin-path" => "/home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini",
"socket" => "php.socket"
)),
".html" =>
((
"bin-path" => "/home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini",
"socket" => "php.socket"
))
)
$SERVER["socket"] == "127.0.0.1:443" {
server.document-root = "/home/gosh/Desktop/web_server"
ssl.engine = "enable"
ssl.pemfile = "/home/gosh/Desktop/web_server/lighttpd.pem"
server.errorlog = "/home/gosh/Desktop/web_server/lighttpd_error.log"
server.accesslog = "/home/gosh/Desktop/web_server/lighttpd_access1.log"
accesslog.filename = "/home/gosh/Desktop/web_server/lighttpd_access2.log"
}
This is command line to start lighttpd:
sudo /home/gosh/Desktop/web_server/lighttpd_native_installed/sbin/lighttpd -f /home/gosh/Desktop/web_server/lighttpd.conf -m /home/gosh/Desktop/web_server/lighttpd_native_installed/lib
And, finally, lighttpd creates lighttpd_error.log:
2009-08-30 04:44:01: (log.c.172) server started
2009-08-30 04:44:01: (mod_fastcgi.c.1365) --- fastcgi spawning local
proc: /home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini
port: 0
socket php.socket
min-procs: 4
max-procs: 4
2009-08-30 04:44:01: (mod_fastcgi.c.1390) --- fastcgi spawning
port: 0
socket php.socket
current: 0 / 4
2009-08-30 04:44:01: (mod_fastcgi.c.1087) the fastcgi-backend /home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini failed to start:
2009-08-30 04:44:01: (mod_fastcgi.c.1091) child exited with status 2 /home/gosh/Desktop/web_server/php_native_installed/php-cgi -c /home/gosh/Desktop/web_server/php.ini
2009-08-30 04:44:01: (mod_fastcgi.c.1094) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.
If this is PHP on Gentoo, add 'fastcgi' to the USE flags.
2009-08-30 04:44:01: (mod_fastcgi.c.1398) [ERROR]: spawning fcgi failed.
2009-08-30 04:44:01: (server.c.928) Configuration of plugins failed. Going down.
My questionis are:
1) has anybody successful experience in launching lighttpd + PHP + FastCGI on Ubuntu or OpenSUSE?
2) why spawning fcgi failed?
I.e. I want to use such index.php to test my web-server:
<? php
phpinfo();
?>
P.S.:
If I remove
$SERVER["socket"] == "127.0.0.1:443" {
server.document-root = "/home/gosh/Desktop/web_server"
ssl.engine = "enable"
ssl.pemfile = "/home/gosh/Desktop/web_server/lighttpd.pem"
server.errorlog = "/home/gosh/Desktop/web_server/lighttpd_error.log"
server.accesslog = "/home/gosh/Desktop/web_server/lighttpd_access1.log"
accesslog.filename = "/home/gosh/Desktop/web_server/lighttpd_access2.log"
}
from lighttpd.conf, lighttpd successfully starts and Firefox displays index.html (but not index.php):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Yabaaa!!!</title>
</head>
<body>
HELLO!!!
</body>
</html>
Update:
Thanks for the responses.
lighttpd_error.log exactly says that there is a problem with FCGI and PHP interpreter.
Yes, backports are available ion SUSE or Ubuntu, but they do NOT work too.
I think it is the OS problem.
I have embedded device:
CPU: AMD AU1000 (MIPS platform, not x86)
RAM: 64 MB
HDD: 120 GB
LAN: ethernet controller
Cross compiler to buils apps for this device:
mipsel-linux-gcc
So, I have builded Lighttpd and php for MIPS target, copied them to this device and... server started to work normally. I could see index.php from Mozilla!
I do not know why Lighttpd+PHP does not work on PC.
DECISION: I score on the problem.
If I remove
$SERVER["socket"] == "127.0.0.1:443" {
server.document-root = "/home/gosh/Desktop/web_server"
ssl.engine = "enable"
ssl.pemfile = "/home/gosh/Desktop/web_server/lighttpd.pem"
server.errorlog = "/home/gosh/Desktop/web_server/lighttpd_error.log"
server.accesslog = "/home/gosh/Desktop/web_server/lighttpd_access1.log"
accesslog.filename = "/home/gosh/Desktop/web_server/lighttpd_access2.log"
}
from lighttpd.conf, lighttpd
successfully starts and Firefox
displays index.html
This might be a different problem, here only concerning SSL and Logfiles.
Do these Logfiles exist?
Where's the information about your key-file for SSL?
I'd generally prefer the use of prebuilt-packages. Are there no backports available for SuSE or Ubuntu?
not sure, but most installation guides say that u should add this at the end of you php.ini
cgi.fix_pathinfo = 1
On ubuntu i have notice that the path setup for the php-cgi binary does not use the real binary name, ubuntu install php5-cgi were as the default configuration trys to point to php-cgi hence you get the above error. It had me guessing for a few minutes myself.

Categories