1

I have an amazon ec2 linux instance (ubuntu 18.04). There I installed my web site which is reacheable here.

In the website I have a Download button which triggers a PHP that generates some files in /var/www/wondermap/html/tmp/ folder and send them zipped to the client (which in turns save everything with JavaScript).

The code works from my dev machine but not on the AWS.

I tried setting the tmp folder permission so that my user (ubuntu) is the owner and both me and www-data group have rwx permissions.

I did it doing:

sudo chown -R ubuntu:www-data /var/www/wondermap/html/tmp
sudo find /var/www/wondermap/html/tmp -type d -exec chmod 775 {} \;
sudo find /var/www/wondermap/html/tmp -type f -exec chmod 664 {} \;

and controlled that everything matched my dev machine with ls -ld tmp/ and confirmed it:

drwxrwxr-x 2 ubuntu www-data 4096 Jan  4 23:04 tmp/

I think Unix side permissions should be fine.

However, when I try to use the download functionality, all I have is a downloadable zipped file which is invalid, and if i open it I can see the source code of the PHP.

I thought that maybe I am missing some permissions in the amazon security group, but I am stuck at this point.

I have set inbound rules for HTTP, HTTP, and SSH and left the outbound rules empty. Also, I can confirm that my apache user on the aws is www-data.

Doing:

ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1

outputs www-data.

If you want to see the code I can add it here without problems, but it is working in my dev machine so I assume it's a permission problem.

SOLUTION

Turns out PHP wasn't installed on the server...

sudo apt install php libapache2-mod-php
sudo systemctl restart apache2
3
  • 2
    Your server isn't processing the php file and is simply serving it's contents to the client (you can see that by visiting wondermap.it/php/export_wfs.php directly). Have you configured php on your ec2 instance? Jan 10, 2019 at 0:40
  • @JonathanRouleau thanks for the feedback. I'll surely check as soon as I can and come back with what I've found.
    – umbe1987
    Jan 10, 2019 at 8:51
  • I am so dumb... PHP wasn't neither installed... thank you so much.
    – umbe1987
    Jan 10, 2019 at 19:11

0

You must log in to answer this question.

Browse other questions tagged .