Jump to content
The Uniform Server Community
Sign in to follow this  
danp84

Launching the PHP CLI

Recommended Posts

I am running uniform server 3.3 (standard configuration) on a Windows XP platform. I continue to get error messages whenever I launch the PHP CLI. The error messages say:

 

"PHP Startup: Unable to load dynamic library '/usr/local/PHP/extensions\php_curl.dll' - The specified module cannot be found"

 

This message is repeated for php_gd2.dll, php_mbstring.dll, php_mysql.dll, php_openssl.dll, and php_sockets.dll.

 

Note that I have tried to enable cURL and SSL functions to interact with common api's, which is why I am doing this.

 

All of these files are in the "/extensions" directory, and are all 5.1.1.1 versions, which is the version of PHP I am trying to run. I have also edited the php.ini file to "uncomment" these extensions. Also, I have copied the appropriate files to my system32 folder on my Windows machine. I've tried copying the missing files to a number of different locations in the PHP folder, and tried searching for different ideas around the web but none of the permutations seem to work.

 

--------------------------------------------------------------------------------------------------------------------------

 

In a related note, I have had success running the Stunnel plugin to establish SSL connections, but am having trouble making the integrated SSL functionality that comes with uniform server 3.3 which uses OpenSSL work.

 

I have resigned to using the Stunnel plugin, but I would like to at least know how to configure uniform server 3.3 to do this without the aid of the plugin.

 

Is there some modifications that have to be made to the Apache (ver 2.0.55) .conf files or do I have add the mod_ssl.so file in? Or is it something else entirely?

 

--------------------------------------------------------------------------------------------------------------------------

 

Can anyone be of any help?

 

Totally confused noob.

Share this post


Link to post
Share on other sites

For any one that does not know, CLI standards for command line input. This allows you to run a PHP script directly without the need for either a server or browser.

 

For example this script test1.php saved (on drive f in folder test)

 

<?php

echo "This is a PHP-CLI Script";

?>

 

can be run from a command “cmd” prompt using the following command line:

 

E:\> php f:\test\test1.php

 

Note:

E:\> is the command prompt where E:\ is the top level of E drive

php is the executable file (php.exe) the file extension is not required

f:\test\test1.php is the full path to the test file

 

This failed as expected because I have not set or specified a full path to php.exe

The error message you receive: ‘php’ is not recognised as an internal or external command, operatable program or batch file.

 

Solution 1)

Run the servers and used the path that is set. Using default drive the path will be:

W:\usr\local\php

Hence you would type this in at the prompt:

W:\usr\local\php\php f:\test\test1.php

 

Solution 2)

If you do not want to run the servers you can use the actual path where you saved all the UniServer files

 

F:\uni_server_33_clean\UniServer3_3\Uniform_Server\diskw\usr\local\php

 

Hence you would type the following at the command prompt:

F:\uni_server_33_clean\UniServer3_3\Uniform_Server\diskw\usr\local\php\php f:\test\test1.php

 

Solution 3)

After you have made several typing errors you may prefer this solution it uses a batch file to set the windows path. You run it once when in a command window it does not permanently change the path only the local command window version.

 

path.bat

 

path %PATH%; W:\usr\local\php

 

Note: You can use either of the path from solution 1) or 2) however you must run the servers first for solution 1)

 

From the command prompt you would type the following:

 

E:\> path.bat

E:\> php f:\test\test1.php

 

Note: Assumes that path.bat is save in E:

 

That really should have been the solution to the original question, set the correct paths so the files can be found. The path to php.exe works because the test script is being processed. However to my surprise I received the following errors:

 

"PHP Startup: Unable to load dynamic library '/usr/local/PHP/extensions\php_gd2.dll' - The specified module cannot be found"

 

This message is repeated for:

php_mbstring.dll

php_mysql.dll

php_sockets.dll.

 

The only reason I did not receive errors for these two files:

php_openssl.dll

php_curl.dll

is because they are not part of UniServer 3.3 distribution (Well that’s partially answered the question)

 

If you type any of these commands at the prompt:

php –v (gives version)

php –m (list modules)

 

same error messages.

 

Time to have a quick look at file php.ini located in folder *diskw\usr\local\php zap down to line 450:

 

extension_dir = "/usr/local/PHP/extensions"

 

I tried a few mods that should have produced a specific results however it acts strangely not quite what I expected. I forced it to look in the current folder and was surprised to see that it was the php folder. Modify the line to:

 

extension_dir = "./extensions"

 

That’s the line you want to make CLI work.

Would be interesting to see if that would resolve similar problems I found while Googling.

 

Hope that helps :rolleyes:

Share this post


Link to post
Share on other sites

I implemented the last changed you mentioned, which was:

 

Change the line in php.ini:

 

From: extension_dir = "/usr/local/PHP/extensions"

 

To: extension_dir = "./extensions"

 

...and the PHP-CLI worked!

 

Thanks for your help!

 

-----------------------------------------------------------------------------------------------------------------------------

 

I'm still a bit confused about the Stunnel/OpenSSL other issue I mentioned in the post as well...

Share this post


Link to post
Share on other sites

The path remains set only during an active command window session once you close this window the path is lost and you need to run the batch file again in every new CMD window. If you find this to be a pain set the Windows path permanently (well you can change it back at any time).

 

Command line interface: Update

 

How to add php.exe path to the Windows PATH environment variable.

1) Start > Control panel

2) Switch to classic view (top left)

3) Click on system

4) Select Advance tab

5) Click on Environment Variables button

6) Highlight “Path” in “System variables” and click Edit button

7) The Edit System Variable box is displayed. Click in the “Variable value” window. Move cursor to the end of whatever is already there and add the path: ;w:\usr\local\php

8) Click OK and OK again OK to finish

To see what is in the PATH variable, open a command window (start > run > cmd) and enter "echo %PATH%".

Note: If you already have a CMD window open close it. Open a new one and the new path will be picked up.

-------

I never had time to address the Stunnel issue because I was in the process of writing a few notes to explain its installation.

“I'm still a bit confused about the Stunnel/OpenSSL other issue I mentioned in the post as well...”

This may or may not help:

http://center.uniformserver.com/stunnel/stunnel_1_intro.html

 

All the best

 

:)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...