473,396 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

win32service Functions

Does anybody have any practical experience at running PHP scripts as a
Windows service?

I've followed the instructions at
http://www.php.net/manual/en/ref.win32service.php and have downloaded
the php_win32service.dll file and placed it in my extensions directory,
added the line "extension=php_win32service.dll" to my PHP.ini file,
restarted IIS, and when I run phpinfo() it shows as being enabled. Yet
anytime I attempt to create a service all I get back is the number "5".

Platform: Dell Optiplex GX270, Windows XP Pro w/SP2, IIS, PHP 5.0.5
running as ISAPI, Zend Optimizer v2.5.10.

List of loaded extensions:
[0] => bcmath
[1] => calendar
[2] => com_dotnet
[3] => ctype
[4] => ftp
[5] => iconv
[6] => odbc
[7] => pcre
[8] => session
[9] => SPL
[10] => SQLite
[11] => standard
[12] => tokenizer
[13] => zlib
[14] => libxml
[15] => dom
[16] => SimpleXML
[17] => wddx
[18] => xml
[19] => ISAPI
[20] => mcrypt
[21] => mssql
[22] => mysql
[23] => xsl
[24] => win32service
[25] => Zend Optimizer

This is the code I'm using to try and create the service.

---begin-code----
<?php
$details['service']='phpmaintenance';
$details['display']='PHP Maintenance';
$details['params']='C:\\Inetpub\\wwwroot\\maintenance\\php_maintenan ce.php
run';
$details['start_type']="WIN32_SERVICE_AUTO_START";
$x = win32_create_service($details);
echo $x;
?>
---end-code----
No errors or warning are generated.

I'm assuming this should put a service on the list of services when
viewed from the mmc console, but nothing is showing up. I checked
current tasks, nothing matches. I've tried starting it from a command
line as well as via a web browser, yet nothing seems to work.

Anybody have any ideas ?

Daniel

Oct 28 '05 #1
5 4964
Daniel wrote:
Does anybody have any practical experience at running PHP scripts as a
Windows service?

I've followed the instructions at
http://www.php.net/manual/en/ref.win32service.php and have downloaded
the php_win32service.dll file and placed it in my extensions directory,
added the line "extension=php_win32service.dll" to my PHP.ini file,
restarted IIS, and when I run phpinfo() it shows as being enabled. Yet
anytime I attempt to create a service all I get back is the number "5".

Platform: Dell Optiplex GX270, Windows XP Pro w/SP2, IIS, PHP 5.0.5
running as ISAPI, Zend Optimizer v2.5.10.

Question. I have been poking around to learn more about this for myself
and have deduced, but not seen it explicitly mentioned, that this only
for available Php 5.0. Is that correct, or is there something similar
for version 4 (4.4)?
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Oct 28 '05 #2
I've followed the instructions at
http://www.php.net/manual/en/ref.win32service.php and have downloaded


Did you also modify your service script to execute
win32_start_service_ctrl_dispatcher() and then run in a service loop?

Other than that, my only suggestion is return code 5 means "file not
found" - did you give the right path?

---
Steve

Oct 28 '05 #3
Full path (copied and pasted from Windows Explorer) is
"C:\Inetpub\wwwroot\maintenance\php_maintenance.ph p" (looks good from
here.)

This is the "php_maintenance.php" file.
---begin-code----
<?php
if ($argv[1] == 'run') {
win32_start_service_ctrl_dispatcher('phpmaintenanc e');
$dataoutput="Hello World\r\n";

while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message())
{
$filename="C:\\inetpub\\Test_".date("Ymd_His").".l og";
if ($handle = fopen($filename, 'a')) {
fwrite($handle, $dataoutput);
fclose($handle);
}
sleep(3);
}
}
?>
---end-code----

The idea for this piece of test code is to write a new text file
containing "Hello World" every 3 seconds to C:\Inetpub.
I know PHP has write access to that folder as my error handler puts
it's logs there. I figured if it worked and I saw the new files I would
move forward building a new maintenance system, but it's not even doing
that.

It looks simple enough and I might be missing something simple, I just
can't figure out what. I checked security on the php_win32service.dll
file and it does have read, write, and execute permissions for both the
IUSR and IWAM accounts.

The only new thing that has been added lately was the Zend Optimizer. I
may try uninstalling it and see what happens, otherwise I'm at a loss
to figure out why it will not work.

PS:In answer to the 2nd message, if you check this page (PECL library),
http://snaps.php.net/win32/ it looks like there is not a version of the
dll available under PHP 4.x.x. Somebody may correct me later, and
that's Ok, but I don't see one for PHP 4.x.x.

Thank you
Daniel

Oct 28 '05 #4
It dawned on me that IUSR and IWAM accounts probably make no difference
in this case. I did set permissions for "Everyone" in Security to read,
write, and execute. That made no difference.

Is there possibly another file someplace that I might need to change
permissions on?

Thank you
Daniel

Oct 28 '05 #5
I finally figured out why it was not working.
PHP is picking up the same php.ini file being used for the website and
that contains an auto_prepend file, and it was running into errors,
thus the service was not getting created.

If I disable the auto_prepend file it works Ok. I just need to create a
separete PHP folder with the executables and a special php.ini for this
purpose.

Thank you
Daniel

Nov 10 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: hokiegal99 | last post by:
A few questions about the following code. How would I "wrap" this in a function, and do I need to? Also, how can I make the code smart enough to realize that when a file has 2 or more bad...
99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
47
by: Richard Hayden | last post by:
Hi, I have the following code: /******************************** file1.c #include <iostream> extern void dummy(); inline int testfunc() {
2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
7
by: Tim ffitch | last post by:
Hi I have created a VB dll file that contains common functions I use across various projects in VB, Access and Excel. Rather than have to code the functions in each I decided to use the dll...
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
4
by: kkt49 | last post by:
# vim: et sw=4 ts=8 sts from wxPython.wx import * import sys, os, time import pywintypes import win32serviceutil import win32service import win32event import win32process
7
by: Immortal Nephi | last post by:
My project grows large when I put too many member functions into one class. The header file and source code file will have approximately 50,000 lines when one class contains thousand member...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.