Question

I have a website where a executable .jar file is intended to reorder the lines of a simple .txt file every time a user submits a form. I wanted to do this the easy way with PHP, using

exec('java -jar sorter.jar');

However the webhost doesn't allow this for "security reasons". I've been googling, and have found that this is a common nuisance for web host customers. However I can't find any sources where the inquirer solves the issue, i.e. finds a web host that allows this. I've also asked Customer Support at a few major sites, and none of them allow exec(). It seems to me like people just give up, but that can't be right.

Which web hosts allow the exec() command? Alternatively, how can I execute my java program upon form submission without exec()? Bonus question: why isn't there heavier advertising from web hosts that do allow exec(), considering that it's such a big issue for some customers?

Was it helpful?

Solution

exec is almost always turned off by shared hosts because it represents a security risk to both you and them. It allows you to use PHP to run shell commands, which in turn lets people take control of your server. They won't advertise a security risk.

What you want is a virtual private server (VPS, sometimes called a "cloud" server). A VPS lets you set the environment directly, without affecting other users because your machine looks like it is separate but it's really sharing resources. You can check out 1and1, Amazon Web Services, etc if you want to get one and they are roughly comparable to most shared hosting packages. The catch is you need to set it up. I would further suggest you use a control panel like Plesk or cpanel to help you if you don't know how to administrate a Linux box.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top