A way to remotely run my PHP file - php

I have created a .php file, which I can run from my Mac and it works great.
This .php file needs an SSL connection,and it also has another file it uses (certificates .mem for APNS) .
I would like to be able to remotely run this file from any browser, in my Mac, so i will get some IP address, that when opened in a browser, the .php will be executed.
I was trying port forwarding, without any success, and I am looking for other services that do that.

Related

Access remote Windows server FILES from Linux Apache Webserver via Browser Hyperlink

I have installed an apache webserver on Linux Debian and created an intranet on it. The intranet basically shows tables with entries from sql queries via php and mysql.
In one of these tables I would like to add a hyperlink that leads to/opens files and folders on a remote windows server.
I can access these files on the windows server from my linux webserver via cifs protocol.
How do I tell apache and/or linux where they need to go when a user clicks on a hyperlink in my intranet?
The path for the windows server is: \10.0.10.100\data\moredata\file.xls
I can access the windows server folders on my linux webserver via the following path: /media/data/moredata/file.xls
However, if I place this path inside html tag like this:
open my file please , it won't work.
If I try it like this: open my file please , it also won't work.
I believe that I need to insert the path inside apache.conf ? Is this correct? And if so, how is it done exactly?
You have to create Alias for that. Like 10.0.10.100/media can be pointing to your root /media folder. You can do it in your config file. Hope this link can help.

how to have R opencpu interact with php

I am new to php and have some experience with R opencpu.
Suppose I use localhost (127.0.0.1) to host my opencpu with the (default) port of 8004. Then, I cannot run the Apache using the same port. Instead, I have to run it in another port, say 8080. Then all my .php will be held on a server of the port 8080.
So how can I connect my .php files when running a opencpu app?
I thought that I could put my .php files in inst/www, where my index.html is. However, when I do so and open the page of http://localhost/ocpu/library/.../www/xxx.php, my browser automatically downloads the .php file but not executing it.
You'll need to ensure your web server is configured to properly serve PHP, which is a whole other thing. However, if you're only accessing files on localhost then you can just execute the PHP files directly using the system2() command.
output <- system2('php', c('/path/to/script.php', 'arg1', 'arg2'), stdout=TRUE)
Setting stdout=TRUE ensures the output from the script is returned for later use.

PHP can't download files from another server locally when accessed with browser

I'm trying to download a file locally from a remote server but every time i access the file that contains the PHP code using the browser file_get_contents() fails because it doesn't have the permission to write to /var/www/html (Apache2). I tried using cURL but that didn't work either, checked to see if allow_url_fopen is on (it is) and added the php file to sudoers. I can't seem to find any solution online.
i think this is permission issue, see this maybe will solve your problem, pick that suit to your enviroment.

Run a .php script on my website from command line

I have been searching for an answer to this for a couple of hours with no clear answer.
I normally write .php scripts which do helpful administrative tasks on my website. I upload them to an ftp folder, and run them from my browser when I need them.
Unlike what I a used to, I am trying to run a script (someone else wrote it) to and have been told that I cannot do so from the browser and I need to do it from the command line. Basically everything is set up, but I cannot push to go button and run the script.
Any ideas? I have php installed on my local computer and can run scripts locally from browser and command line, but I do not know how to do the same for the scripts on my website.
I don't know if this helps, but my server is apache and runs off php version 5.3.3
Download Putty, from http://www.putty.org/
Run it
In "host" write your domain, and click on Open
When the black window open, it will ask you for your credentials:
Write your ssh credentials, if you have. If you dont, try with the ftp user and password.
If it doesn't work...get into your host control panel, and find out how to create an SFTP, or SSH user. If you can't find anything, contact support asking how to create that kind of user. When you have it
After you login, your are inside your server, and you can move around, as you would in linux. If you dont know the basics, find a good tutorial. Or just relay in:
ls : list the files and directories
pwd : know in what directory you are
cd DIRNAME : change to other directory inside de current one
cd .. : change to the parent directory
When you are in the directory where your script lives, just execute:
php yourscrip.php
if its a php script
php path_to_script.php
else
/path/to/script
If its the second option you will need to chmod +x /path/to/script first
These should all be run from a ssh session (or any other way of accessing a command line on the machine running the website)
to ssh to a sever use putty if on windows. Your host will be able to give extra details on how to access

how to give command line to run browser which in turn runs php script

question is how to give command line (in .cmd script) to execute browser to then in turn have browser execute .php script.
Presently if from a command window I execute like ...
"c:\Program Files\Internet Explorer\iexplore.exe" file:\c:\users\win7ultsdtest\findroot.php
....OR....
C:\Program Files\Internet Explorer\iexplore c:\users\win7ultsdtest\findroot.php
This will run the Explorer browser, but then the browser the browser will download the contents of findroot.php instead of executing the php code as I need. Does anyone know how I can get the browser to instead execute the php code and not just download it as data?
Let me explain my need ... The findroot.php file contains php code to access the $_SERVER['DOCUMENT_ROOT'] variable. This variable is ONLY non-null when the localhost is running a http server and then it contains the localhost document server root path where loadable browser .html, .php etc may be stored to loaded from http:\ lines.
The findroot.php outputs the $_SERVER['DOCUMENT_ROOT'] contents to a file as rootpath.txt so that my .cmd script can then can automatically install PHP code into the active PHP servers document root area.
So understand I must find the $_SERVER['DOCUMENT_ROOT'] from a .cmd script.
Now I might search ALL the computers drives for httpd.conf and then scan that file for the value but this wouldn't work for two reasons; 1. there can be multiple httpd.conf files and I can't know which server is active and using what httpd.conf. 2. it would take a long time to search a given computers entire drive(s) on all httpd.conf files.
The browser won't execute PHP code. You either need a server to run PHP and to access it via HTTP such as C:\Program Files\Internet Explorer\iexplore http://localhost/url/for/findroot.php or you can run PHP via the command line c:\path\to\php.exe c:\users\win7ultsdtest\findroot.php. However running it via the command line won't give you $_SERVER['DOCUMENT_ROOT'] as that is only populated when running PHP within a server.
It's not possible to execute PHP by the HTTP server without the server knowing about the PHP before hand - for example, by being in the document root. Of course if you don't know the document root, your script won't be there. If you're trying to install a script into a web server for a user, it's much better to give instructions on how to do so as their server environment will likely vary from what you expect.
There are light browsers like lynx if you are in a linux machine
lynx http://whateverurl/php.php

Categories