PHP files downloading - php

I have an AWS EC2 instance running the Bitnami Tomcat stack. When I try to run php from the server, they download. When I try to run it from my computer to test it, the code shows in the browser. In both scenarios, what could the problem be?

Related

How to use Supervisor to run Websocket server on AWS Lightsail instance

I'm using this library to add websockets to my codeigniter app. I got everything to work, but I need the websocket server to always run in the background, regardless of the CLI being open or not.
To run the server in the CLI, I run this command:
php index.php welcome index
Which gives me:
Running server on host 0.0.0.0:8282
Authentication activated
Websockets works on my app, but if I close the CLI, the server closes as well. How do I keep this running? I have Supervisor (as suggested for Ratchet), but I have no idea where to go from here. I'm just running a simple PHP server (Ubuntu on AWS Lightsail), not a node one, bytheway.

Edit php file on AWS Elastic Beanstalk

When I did run my web site on my old server, I launched Transmit on my Mac (OS X 10.11.6), connected to my server, Control-Click-Open the remote php file, made the fix and save. The file got updated on the server in a second. That was great to run some php/mysql/google_service test that I can't run locally.
Now I have just moved my project on an Amazon server, AWS. Every time I need to run a test (for example on the S3_Bucket, that I can't run locally), or modify a variable, change a flag... I have to do it on my local php/html/java/css/apis project, zip it, upload it via the Elastic Beanstalk panel, wait about half a minute, then run it. I have found no way to edit a single file in an easy way (Open, Write, Save) as I did before through Transmit. I can't go ahead this way. It's wasting my time.
Do you know any better way to develop/test/run my project on AWS?
Have you considered using Docker?
https://aws.amazon.com/about-aws/whats-new/2015/04/aws-elastic-beanstalk-cli-supports-local-development-and-testing-for-docker-containers/
Or use MAMP?
https://www.mamp.info/en/

PDFTK with PHP exec() fails using Amazon EC2 Windows Server IIS7

I'm using PDFTK to merge some PDFs on my Amazon EC2 instance running Windows Server and IIS7.
When I try running PDFTK using PHP exec(), it does not work. For example:
<?php
$e = exec("pdftk");
var_dump($e); //output is: string(0) ""
?>
I can get other commands to work using exec such as exec("ping 192.168.2.1") but I can't get PDFTK working.
I can also run pdftk from DOS command line, so I know it's installed properly.
I also set the permissions to pdftk.exe to full access for all users (thinking this was a permissions issue).
I remember having a similar problem when I installed PDFTK on another Windows Server Amazon EC2 instance, but I forgot exactly what I needed to change. I thought it had something to do with IIS_USR Permissions but it was a while back and I don't remember the specifics.
Thank you.
The application either needs to be in the same directory as the script, or within the $PATH environment variable for the user executing the PHP script. With IIS, this is not the user you are logged in with.

Is it possible to execute a php file in Amazon EC2(Elastic Compute Cloud)?

Can you share code snippets to execute a PHP file in Amazon EC2.
there's nothing special about PHP in EC2. you need to have a instance with PHP installed and configured for your particular use case (CLI, apache module, FastCGI), just as with physical machines.
How do you mean execute a php file?
Within Amazon EC2, just create a Ubuntu instance, install apache + php, upload your php file to the instance and place it in apache (the same as if it were any other web server).
Browse to the file location from your browser and it will run, just as any other php file would.
Amazone instance is nothing but a hosting space. You should have PHP/Mysql enabled (If you purchase a server space for PHP.). Just push the file to server and run it.
If it is not enabled by default, install LAMP.

IIS7 - giving php access to command-line

I am running a cookie-cutter r-script from the command-line using the php5.3 exec function. The idea being that the user selects data, php runs the script, and the user is able to download the high resolution graphic. I've run this on my local testbed with apache and everything worked fine, however, the production server is Windows Server 2003 with IIS7 (something I cannot control). It seems with IIS7, by default, php does not have access to cmd.exe. We've tried changing permission to cmd.exe with the "calcs" command with no success.
How do I give php permission to access the command-line through the use of the exec function?
P.S. I know, I know, I know. No user input is being executed with the exec function. We just want to take advantage of R's high resolution graphics and data processing capabilities.
Relevant Details:
OS is windows server 2003 64-bit
IIS7
The server is an Amazon EC2 instance
(I don't believe this to be an issue with Amazon as I've heard of people do similar things with a LAMP stack Amazon instance)
EDIT: the problem ended up being that for some reason IUSR did not have permission to use the "start" command in command-line.
REM commands below did not work
start "Path to .exe" "File to process"
start "" "Path to .exe" "File to process"
REM this one did however
"Path to .exe" "File to process"
It's an IIS issue i think (You could install one locally to test it) but if you run with anonymous authentication you need to change the anonymous user to a regular user (which will have privileges to launch cmd.exe). Also check the identity of the application pool user, since sometime it runs with a limited account too.

Categories