php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 20, 2020 05:24AM

Hello,
I am using wamp 3.2.0 64bit running under Win10 Pro 64bit.
Apache 2.4.41
PHP 7.1.33
mysql 5.7.28
physical server with Windows where I have full rights.

Running plenty of virtualhosts without problems many years started with wamp 2.0 aroud 8years ago.
Now a weird thing happened. I set new virtualhost where I want to run php robot with several functions (robot not written by me).

After robot installation done properly incl. mysql connection here comes the trouble. The robot needs to input full path to php.exe into his config.php file as it is using exec function later while working.

When I try to start robot via its installed small webinterface with Start/Stop button (vhost path_to_robot/index.php) it simply do nothing except webpage writes "trying to start robot" and also logs empty = so hard to say where is problem.

BUT when I run manually using cmd prompt and input php.exe full_path_to_robot_php I can see in robot log it is started.

The problem seems to be maybe with access rights as cmd started either under local admin user or with elevated privileges - both working.
Therefore I changed account name to run apache and mysql system services to local admin account instead of Local System account as was by default - not sure if I should avoid this, however after this change still no luck. The difference is only I am getting e.g. proper computer name\username instead of nt system\user while using echo exec whoami...

Based on this I am not sure if I should change apache and mysql back to run under Local System? Or is it better to run using Local System for some reason? I read Local System is not good if e.g. there are network drives included in some paths etc. Still I have whole wamp under C:\wamp while all virtualhosts are set on E:\vhost1, E:\vhost2 etc... These are separate physical discs but inside same machine.

Unfortunately there is nothing in error logs related to my problem. And I also dont know which user is used to access the virtualhost while using webinterface instead of direct run using cli. I didnt set any wamp users during wamp install and I believe not necessary.

I also verified exec is fully working and all bots requirements too. But really dont know where to find error for the response (if any) after I click Start button on robots webinterface.

Or maybe it could be a virtualhost problem to set permissions properly? Because virtualhost root folder is E:\vhost but root folder for robot is E:\vhost\robot. And I set only vhost root folder? But subfolder with robot is included as I believe.


Thanks for your suggestions and sorry for length of my message. In case of additional info needed I am here.



Edited 2 time(s). Last edit at 03/20/2020 05:32AM by meror.

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 20, 2020 03:44PM

Hi,

> Based on this I am not sure if I should change apache and mysql back to run under Local System?
> Or is it better to run using Local System for some reason?

The reason why Apache, MySQL and MariaDB services are created with LocalSystem as the login account is that it can't be otherwise.
The services are created by Apache, MySQL or MariaDB with instructions like :
E:/wamp64/bin/apache/apache2.4.41/bin/httpd.exe -n wampapache64 -k install
E:/wamp64/bin/mysql/mysql8.0.19/bin/mysqld.exe --install-manual wampmysqld64
E:/wamp64/bin/mariadb/mariadb10.4.12/bin/mysqld.exe --install-manual wampmariadb64
It is totally impossible for Wampserver, Apache, MySQL or Mariadb to know the user/password couple of the local admin account - and fortunately this is the case. This means that changing the services login account can only be done manually by the administrator user himself.

For Apache to be able to take into account VirtualHost located on a network disk, it is necessary to modify the LocalSystem connection account of the wampapache64 service by replacing it with the local administrator account, otherwise errors such as :
DocumentRoot must be a directory     .
AH00526: Syntax error on line 122 of E:/wamp64/bin/apache/apache2.4.41/conf/extra/httpd-vhosts.conf:
For a VirtualHost like this:
<VirtualHost *:80>
   ServerName photos-famille
   DocumentRoot "//DS218/home/sites/photos-ottello"
  <Directory "//DS218/home/sites/photos-ottello/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride all
    Require local
  </Directory>
</VirtualHost>

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 20, 2020 04:41PM

Thank you for your comment. I am happy to learn something new. With the example I provided, I will stay with local admin acount to run services to not fall into problems if anytime I need vhost with remote/network path.

Now back to the problem:

vhost is having documentroot as E:\web - for this directory I have settings like -Indexes, Require all granted etc. inside vhost definition.


bot is installed in E:\web\bot so I believe this folder is normally included in above definition and no record for this path in vhost definition.

bot.php located in E:\web\bot wanted from me during the installation full path to php.exe to be able to exec commands later - I set the full path properly to C:\wamp\....\php.exe

Still it looks like the Start button in webinterface do nothing and no log anywhere - nothing in windows log, nothing in apache and in php global log, nothing in vhost log, nothing in bot log. Although I know there is definitely no problem in the button itself.

From windows command line, when I issue php.exe E:\web\bot\bot.php I can see the Bot starts to run perfectly from Bot log.

Based on above, I believe there is some bad config maybe in vhost or somewhere else in wamp? But really out of ideas.

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 20, 2020 05:12PM

Hi,

You should look at the PHP global variables and mainly at $_SERVER['DOCUMENT_ROOT']
[www.php.net]

You will have some information on how to use it and why you should use VirtualHost by looking at The need for Virtual Host

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 20, 2020 05:36PM

Thank you for answer but why php variables like Server Document Root?

In vhost and also in botconfig.php I set strictly full paths - in vhost for Document root incl Options, require all granted etc, in botconfig.php full path to php.exe located under C:\wamp\...

I am sorry but I am trying to understand the situation properly.

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 20, 2020 06:08PM

Hi,

It is totally impossible for any PHP script to "know" the path of the executable by which it was launched either in CLI mode or in WEB mode, otherwise it would mean that via PHP scripts one can access the system.

The only way you can do this is to write "hard" the full path of the php.exe you want to use in a variable in your scripts, a variable that will have to be modified if you change your PHP version.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 20, 2020 08:00PM

Thank you.

Yes it makes sense to me and I put the full path to php.exe into the script.

While having this, I was confused why should I concentrate on $_SERVER['DOCUMENT_ROOT']

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 20, 2020 09:07PM

Hi,

It is true that in this very paritular case, $_SERVER['DOCUMENT_ROOT'] give no help!

$_SERVER['DOCUMENT_ROOT'] gives the root of the VirtualHost wherever a PHP script is.
Whether you are in a script located at the root, in the first level folder, the second level folder, whatever the level, $_SERVER['DOCUMENT_ROOT'] will ALWAYS give the root.

echo "<a href='".$_SERVER['DOCUMENT_ROOT'].'/folder1/folder2/folder3/myscript.php">Link</a>';

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 20, 2020 09:51PM

Thank you for your answers.

After couple of more hours trying to isolate root cause it looks like

1, COM not loaded properly although no error in wamp or apache or php during startup and icon green.

2, COM loaded properly but not found by script.

phpinfo says:

COM support enabled
DCOM support disabled
.Net support enabled

But I found many cases with COM extension where users tried to edit php.ini to include

[COM_DOT_NET]
extension=php_com_dotnet.dll

(because of some php change since 5.4.x version)

instead of existing

extension=php_com_dotnet.dll

However, this didnt work for me and also phpinfo says enabled in both cases.

So I tried to debug a script a bit and I got:

PHP Fatal error: Uncaught Error: Class 'COM' not found in E:\bot\bot.php:90
Stack trace:
#0 E:\bot\bot.php(215): start()
#1 {main}
thrown in E:\bot\bot.php on line 90

With this statement and statement COM extension is running, I believe there is a problem in path where the bot is trying to find COM.
This is line 90:

$WshShell = new COM("WScript.Shell"winking smiley;

and I dont know if I can tell somehow where to look for the COM?

I tried:

$WshShell = new \COM("WScript.Shell"winking smiley;

But no luck. Any ideas?

By the way during last hours I found I need to switch wampapache64 service back to be run as Local Service and tick "Enable interact with desktop" and I believed this was the main problem in my case. However still no luck after interaction enabled and wamp restarted.

EDIT:

In addition I tried a simple test.php like this:

<?php
if (extension_loaded('com')) {
echo "ok";
} else {
echo "ko";
}
?>

and the result is "ko".

So COM extension is not loaded although uncommented in php.ini and although checkbox in wamp gui... Not loaded and wamp nor apache nor php not screaming anything during startup and I have to discover such basic thing after so many hours spent on problem focusing on completely different things?

Why? And how to load it properly?



Edited 6 time(s). Last edit at 03/21/2020 01:20AM by meror.

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 21, 2020 08:43AM

Hi,

Note: Modify the given paths according to your own installation of versions used

All the information displayed in the submenus PHP -> PHP settings and -> PHP extensions concerns PHP used as an Apache module, thus web PHP uses, via http pages.

These informations correspond to the directives of :
e:\wamp64\bin\apache\apache2.4.41\bin\php.ini
which is a symbolic link to:
e:\wamp64\bin\php\php7.4.4\phpForApache.ini

The above information does not apply if you use PHP in CLI mode, i.e. by direct calls to php.exe or php-win.exe. In this case, php will use the directives declared in e:\wamp64\bin\php\php7.4.4\php.ini
It is up to you to manually modify this ini file so that it corresponds to your expectations.

The ini of the two modes are separated to avoid disastrous interactions.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 21, 2020 02:59PM

Thanks a lot for your answer.

This was exactly what helped to me. But how should I know there are several php.ini and one is used in such case while other in different case... Isnt it way too complicated? Just asking, no offense. Nothing like this in unix.

Anyway, thanks a lot for your help. As a feedback - I didnt know php.ini inside php folder has some weight in config as I was thinking the main php is php in apache (presented when opening php.ini using wamp tray icon) and I did all changes there.

Once I enabled php_dotnet dll in php.ini located in php folder a miracle happened and finally I am able to start the bot. Thanks a lot once again...

One thing to think about:

<?php
if (extension_loaded('COM')) {
echo "ok";
} else {
echo "ko";
}
?>

is still displaying "ko" although php_dotnet dll enabled in apache's php.ini and now also in php directory's ini.

I dont know why but happy the bot is working. I tried com and COM and still KO. When I replaced com with e.g. cURL, curl, curl, mbstring, opensll and many others I always get "OK" - properly loaded.

Weird I cant get "OK" for "COM" as now it is loaded properly and working the way I need.


EDIT:

used now

print_r(get_loaded_extensions());

and found out this ext is not reported to system as COM but

com_dotnet

and this report OK in extension_loaded.

Lesson learned. Would never think there are multiple php.ini and each stating significant role based on how php.exe is used.
Thanks again and my problem is solved.


The only last thing I have to sort out is the webinterface is throwing warning for deprecated salt usage.
Most probably the best way would be to use .htaccess in vhost root folder where I specify somehow to hide deprecated warnings...



Edited 2 time(s). Last edit at 03/21/2020 03:30PM by meror.

Re: php.exe loading
Posted by: RiggsFolly (Moderator)
Date: March 21, 2020 03:28PM

Not strictly true, that comment about nothing like this in unix....unless I misunderstood this question and answer

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 21, 2020 04:25PM

Hi,

> Isnt it way too complicated? Just asking, no offense. Nothing like this in unix.

When you use PHP in web pages, by the http protocol, i.e. as an Apache module, the configuration of the PHP version used obeys what is declared in httpd.conf by the PHPinidir directive, in this case
PHPIniDir "${APACHE_DIR}/bin"
which corresponds to e:/wamp64/bin/apache/apache2.4.41/bin/ i.e. the bin directory of the Apache version used.
This means that all PHP configuration files (php.ini) and the necessary libraries (*.dll) must be in this folder.

When you use PHP in CLI mode, i.e. by direct calls to the php.exe or php-win.exe executables, by default php will look for its configuration file in the folder from which it is executed so in e:/wamp64/bin/php/php7.4.4/

These are two different locations of the php.ini file depending on the PHP modes used WEB or CLI and it can still be different with the CGI mode.

I don't think it's different under Unix.

Since the dawn of time, this has always been the case for Wampserver. This allows to separate the PHP WEB configuration which is used by everyone - except some geeks - from the PHP CLI configuration which is used by Wampmanager for all menu operations which allows to run Wampmanager even if the user disables extensions or parameters essential to the operation of PHP CLI for Wampmanager.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons



Edited 1 time(s). Last edit at 03/21/2020 05:33PM by Otomatic.

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 30, 2020 03:56AM

Thank you for your answer, now I know where to look if any other problem.

One more thing if I can ask about wamp - I found out in Wamp tray icon under right click under Tools I can remove unused versions of php easily.

I really like this tool as from time to time I am trying to clean whole system. Would be a problem to add button for also adding new php versions easily?

I found some howto add new php under wamp but I am a bit scared to not ruin something and also I am not sure if manually adding new php versions is a good idea in comparison to remove wamp and install from scratch.

But in second case if I do a fresh installation I will have to set everything again from zero as I dont like the idea of overwriting newly created cfg files from installation with old backup cfg files + I am already using newest Wamp 3.2.0 and no newer version available as I can see - so I am a bit lost how to safely add newest php versions as I selected all versions during wamp installation but still newest php is only 7.4.0 in Wamp tray - checking now php changelog and I am a bit scared of how many things are fixed in latest 7.4.4 and therefore I am not sure if I want to switch to 7.4.0 included in wamp installation.

Is my thinking correct or it needs different point of view? I am currently running 7.1.33 from Wamp installation. I was planning to switch to 7.4.0 as php webpage says 7.1.33 is old and not supported anymore. Now I saw there is "much better" 7.4.4 available but not part of Wamp so I am thinking how to tell wamp easily - "please download it for me and install same way as you installed all php versions during installation. Thank you."

What do you think?

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 30, 2020 09:03AM

Hi,

By looking at the http://wampserver.aviatechno.net/ page, you can see everything that exists for Wampserver, various updates, applications like PhpMyAdmin, all versions of Apache, PHP, MySQL, MariaDB and even VC++ packages.

All these "things" are downloaded and then installed in three clicks automatically(*) in the right version of Wampserver.

To be kept up to date with all the new features, just follow the messages in the thread WAMPserver 3 - All you need to know

(*) The only thing you have to do is right-click on the downloaded file and validate Run as administrator.

Then it's very easy to change Apache, PHP, MySQL or MariaDB used version:
Left-Click -> PHP -> Version -> Choose version you want.

Do the same thing for Apache, MySQL or MariaDB remembering that the parameters you could have modified are not taken over for the new version and that for MySQL or MariaDB, your databases will not be transferred, it is up to you to make the exports in SQL before changing version and then the imports after changing version.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons



Edited 1 time(s). Last edit at 03/30/2020 09:34AM by Otomatic.

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 30, 2020 02:03PM

Thank you for the link, pitty I didnt find it somewhere in Wamp "gui" under tray icon - I wouldnt bother so much then.

I will try 7.4.4 from there. Only one - maybe dumb question - if I can: I am using Wamp 3.2.0 64bit version. I should install only 64bit version of php 7.4.4 or both 32+64?

Just asking as I know for VC redist I need to install both 32+64bit although running 64bit version of Wamp.

EDIT:
one more thing - I just run check_vcredist now and I got this message:

VC_2019_REDIST_X86 ID={2E72FA1F-BADB-4337-B8AE-F7C17EC57D1D}
Visual C++ 2015-2019 x86 Minimum Runtime - 14.24.28127
**** NOT INSTALLED ****
Installation file is on: [wampserver.aviatechno.net]
VC 2015-2019 (VC16 x86) 14.24.28127
----------------------------------------
VC_2019_REDIST_X64 ID={7DC387B8-E6A2-480C-8EF9-A6E51AE81C19}
Visual C++ 2015-2019 x64 Minimum Runtime - 14.24.28127
**** NOT INSTALLED ****
Installation file is on: [wampserver.aviatechno.net]
VC 2015-2019 (VC16 x64) 14.24.28127
----------------------------------------

I am about to install it 32+64bit, however on webpage I can see available version 14.25.28508 - hopefully this is compatible? Or I should explicitly search for 14.24.28127 as check_redist want from me?

Note: I have installed all vcredist versions 32+64 as requested when I was installing wamp 3.2.0 couple of months ago. Most probably this is some newest version not required/not existing at time I was installing wamp?

Thank you.



Edited 3 time(s). Last edit at 03/30/2020 02:15PM by meror.

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 30, 2020 02:19PM

Hi,

> Thank you for the link, pitty I didnt find it somewhere in Wamp "gui" under tray icon.
This will be done with the Wampserver 3.2.1 update, there will be an additional item in the Tools :
- Add an Apache/PHP/MySQL/MariaDB version

> I am using Wamp 3.2.0 64bit version. I should install only 64bit version of php 7.4.4 or both 32+64?
No, only Apache/PHP/MySQL/MariaDB 64 bit versions or 64bit applications.
Anyway, installers of 32 bit versions will refuse to install on a 64 bit Wampserver.

> Just asking as I know for VC redist I need to install both 32+64bit although running 64bit version of Wamp.
This is a little different. On a 64 bit Windows, you may have to install and use 32 bit software that needs the VC redist and that's why it is required to install both 32 and 64 bit versions of the VC redist

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 30, 2020 02:30PM

Thank you again, now I am pretty sure what to install.

Just when you have a second if you can comment the compatibility of vc redist as I mentioned under Edit in previous message.
I am about to install 14.25.28508 available on webpage, however not sure if check_vcredist or my Wamp doesnt want explicitly 14.24.28127 as stated in check output file.
Dont want to screw something, so asking before regret my maybe faulty steps.

Re: php.exe loading
Posted by: Otomatic (Moderator)
Date: March 30, 2020 02:58PM

Hi,

> I just run check_vcredist now and I got this message:
Because you are using a version of check_vcredist that you already had on your machine.

What does http://wampserver.aviatechno.net/ say about the Checks VC++ packages tool :
Quote

Tool to check if the VC++ packages needed to Wampserver 3 are installed correctly.
Do not use a previously loaded tool. Always make a new download to make sure you are using the correct version.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: php.exe loading
Posted by: meror (---.client.rionet.cz)
Date: March 30, 2020 03:40PM

Thank you.

My fault - although downloaded from web today, then mixed together with older one in same folder and run older instead of new one.

Strange thing the new one now says All OK although I didnt install 14.24.28127 nor 14.25.28508 yet.

Maybe Windows Update did the job. I was expecting newest checktool will tell me I am missing 14.25.28508 I was about to download and install.

Never mind, 7.4.4 x64 now installed like a charm and already able to select under Tray icon. I will switch to it later, need to read documentation for other stuff running here first. I am really happy and thank you for all your answers :-)

Now need to fix that weird win-acme tool to generate certificates automatically as I am running vhosts on 443 port. But that is a Q for different team, I hope to get it sorted out soon.

But maybe if I am not bothering you much you can tell me if I am doing correctly with apache ssl:
1, Apache listen port only 80 as I am not sure if 2 values (80+443) are ok.
2, vhost for web.site:80 with permanent redirect to https:// web.site
3, vhost for web.site:443 where among others paths to certificates are set

Working great and while accessing the web.site I receive the "version with certificate" and green lock in browser.
Only asking if this is the correct approach or not so good although working and I should do much better.

I uncommented all needed for ssl.
I am also including httpd-ssl in httpd but in httpd-ssl only couple of lines not commented as I am not using default wamp www folder.
Default vhost is set to Require local so no ssl needed here and also not having any cert for this vhost.
All my vhosts have their root dirs elsewhere in system on different drives to not make a mess inside C:\wamp folder.
Inside httpd-ssl Listen 443 is not commented, however when I click tray icon and Virtualhosts, I can see vhost web.site:443 with yellow warning telling me 443 is not an apache listen port.

As said previously, web is working. So asking if the "technical solution" I described is ok or I should change something to avoid possible problems. Thank you.


By the way, you mentioned wamp 3.2.1 will come - this will be about some user friendly update, or 3.2.0 to be completely removed and 3.2.1 installed from zero (and to configure everything again)?



Edited 2 time(s). Last edit at 03/30/2020 03:42PM by meror.

Sorry, only registered users may post in this forum.