I'm getting 401.1 errors when trying to run a .php file on windows 2003/IIS6
I've been all over the web, given Everyone Full perms on the folder containing the file as well as the file... Nothing.
What am I missing?
Here's a step-by-step guide for getting PHP running on IIS 6.
can you serve HTML in the folder trying to serve PHP?
If yes, what are the permissions on the PHP directory and PHP DLL (e.g. php5isapi.dll)? The IUSR will need execute.
Take a look at the logs produced by IIS (found somwhere in C:\WINDOWS\system32\LogFiles\W3SVC1)
this might give you some additional info.
Related
I have a code on PHP that was working in a server but we migrate that code to another server and now that code is not working, specifically we want to run an .exe file using PHP with the instruction exec
I debug the script and it looks be working properly and the IUSR user and IIS_IUSR have the correct permissions and actually the exe file is running, but, when it run it need generate some files that is the part that cause the issues, the program are trying to create files on the AppPool directory for example like this:
C:\MyPath\somewebsite.com\8áª\MyProgram\
Where C:\MyPath\somewebsite.com\ is the AppPool root directory and MyProgram\ is the directory that the app is creating
Where \8᪠is generated randomly and changes all the time that we try to run the program, debugging with Process Monitor I can get an error: PATH NOT FOUND and/or NAME INVALID, on the previous server we modify the user on the IIS to run the script (that was on IIS 6 now we are on IIS 8.5) and that files was created on the home directory of the user AND without the random directory, for example:
C:\Users\MyUser\MyProgram\
where MyUser is the user that we assigned, but on that new server we get the files on the AppPool directory no matter if we change the user
I think that we can solve that if we was able to define a path for the IUSR user and set it as "home" path but I cannot found where to modify the IUSR user, I know that is a build-in user that IIS create but I'm not sure if I can edit that settings for that user.
I already mention that we used IIS but just as an extra data, we are running that over Windows Server 2012 R2
Any suggestion?
You topic / question is:
IIS does not allow run .exe file using excec command on PHP
which is the correct behavior! You don't want to run .exe files through PHP, really. You have to give the IUSR execute permissions on cmd.exe first, meany you might as well give all your virtual users administrator permissions.
lot of time after but, PHP side was ok, the problem was on the .exe file, the exe file create some files that was used for the same exe program, but it uses relative paths so when the process run makes that did not found the files generated and this caused the errors
How to run a php file from ubuntu platform in the localhost?
I have also installed LAMP in my system.
When I try to run the php file, in the browser, it says "The requested URL is not found-404 ERROR found".
I do not know how to proceed with this.
My php files are in the directory as shown here "/usr/var/html/a.php".
There are two options.
Access the php file through a local webserver(ie thru a local website). The web-server will deal with the requested php file. It will use either,
Inbuilt PHP module to interpret the php file, or
PHP through CGI (eg.CGI, FastCGI)
If your apache(check if apache is running using service apache2 status!!) is set to the default configuration, this could be as simple as
http://localhost/path/to/your.php
Remember by default, the base directory for apache is /var/www/html/, so you need not include this in the url.
Use the php binary directly from a terminal.
php /path/to/your/file.php
After installation of Lamp system in Ubuntu. Please follow the below two steps to run your php file.
Place your php file (.php) in /var/www/html/ (default path)
Please run url as localhost/withfilename.php
Example : I have placed welcome.php file in the /var/www/html/welcome.php
then url will be http://localhost/welcome.php
My setup is as follows: Windows 7, XAMPP with Apache and PHP enabled I have a PHP script in which I call an external program to do run a conversion. This external program is an EXE file, which requires 3 attributes:
The source file
The destination file
Additional flags (conversion type etc)
When I use the command line tool built into XAMPP to execute my script, everything works fine. But when I use the exec() function in my PHP script, no output file is created. I'm pretty sure the conversion is actually happening (it takes about 5 seconds, about the same time it takes to run the PHP script).
I think it's a permissions thing, so I already moved the EXE file to the same folder as my PHP file and adjusted the permissions of the entire folder (I granted all permissions to all users). I also disabled the Windows UAC and tried to put the command in a BAT file. The file just is not created.
Any help or tips would be greatly appreciated!
My PHP code is as follows:
exec('c:\converter.exe c:\src.txt c:\dst.txt -f', $output);
print_r($output);
When I print out $output, the array turns out to be empty. When I put the exact same command in Command Prompt, the code works like a charm (no syntax errors). I use absolute paths as well.
Try to copy your executable file in same folder as your application.
try
exec("script.exe src.txt dst.txt", &$output);
echo $output;
also, do not forget to use escapeshellcmd() to add some security to your application.
Thank you very much for your input! As it turns out, it was Windows issue caused by the 'Interactive Services Detection' feature. Apache was running as a system service, which prevented calls to external programs (with a GUI). I disabled the run-as-service feature in XAMPP, which solved the problem. A more thorough explanation can be found here: http://php.net/manual/en/book.exec.php
Right, I'll try and explain this the best I can.
I'm using PHP COM with a DLL which has a separate config file. Looking at the code of the COM DLL, no path is specified for the config file, only a filename.
Running through command line with the config file in the same directory is successful, however when running through a webpage, it can't find the config file.
Any ideas?
I would try changing the current working directory:
chdir('somepath/');
http://php.net/manual/en/function.chdir.php
Edit: Failing that, try to see if it is relative to the host process executing your script. For CGI, that's be php-cgi.exe. For a module, it would be whatever your web server is. If that is the case, you can make a link in NTFS to some config within your script if necessary. You might also consider using Process Explorer to try to figure out what file that DLL is trying to open. Although, since you have the source code, you should be able to figure that out by looking at it.
I just installed Apache and PHP on my computer to be able to run PHP files locally.
I can run a PHP file if it is located in Apache2.2\htdocs directory.
Is that possible to run PHP files outside this directory ?
I'm looking to a simple solution, because all I need is to write a small PHP code and try it locally.
I would like to be able to run the PHP file by right clicking it -> Open with Firefox
You can run a PHP script from anywhere using the command line:
php yourscript.php
There is some ways to do it, but the simplest way is using 'include' or 'required' php command:
<?
include ('/somewhere/outside/of/your/htdocs/file.php');
?>
Please note you may need to turn off 'open_basedir' php directive.
Newer versions of php come with php-cli: a command line interface. So to run php code, you just need to type:
php some_code.php
Or you can change paths in apache config to another dir
you cannot open it with firefox.
Because firefox has nothing to do win PHP.
So, you need to request this URL from a web-server
Create a windows shortcut with http://127.0.0.1/file.php
or whatever way you prefer to click web links
Yes. You don't say if you want to run it from the web server, or from the command line, but you can use include past the web root.
You can either run it from the command line,
or you can create a "wrapper" script within your htdocs that "includes" the file from outside of the htdocs directory
I had always wondered about it the same manner, say you have a folder in a drive either than the apache/htdocs folder in drive C, and you would like to develop directly in this folder. But think about it this way, would you put your folders else where and expect it to be running on the web? Now Way. Why would you do that?
Goto conf folder and open httpd file change
DocumentRoot "C:/your/path" and
Directory "C:/your/path"
This should work
if it says forbidden access go to this link
Error message "Forbidden You don't have permission to access / on this server"