By Aidan
I’m currently on an Ubuntu 16.04 VPS with Apache2, trying to run a small public file host. However, I have noticed that PHP execution is enabled within the files directory, allowing people to run Shell programs from said PHP files. I have tried adding “php_flag engine off” within my .htaccess file among other fixes, but nothing seems to work. I’m not sure what to do.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello there!
Great question. I’ve actually not set out to do that before. I feel like avoiding the shell scripts should be the primary goal, as someone uploading shell scripts to your website means there is vulnerable code. With that said, I think this might be a way to approach it:
https://lxadm.com/Apache:_disabling_PHP_execution_in_selected_directories
The key here is don’t worry about the .htaccess, and instead focus on the virtual host in the Apache config. If you slip that inside of a virtual host (changing the directory in the code of course), it just might do it. I haven’t done it, but let me know if it works!
Kind Regards, Jarland
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.