dimanche 26 octobre 2014

Permissions and jar file locations for php exec on apache


Vote count:

0




I'm setting up a small experiment on a Linux machine running MariaDB, Apache, Java and PHP... and after playing around all day with this and searching on this topic - I need some further clarification on some permissions and locations. But let me first frame this:


In my web directory: /var/www/html I have a small test program: test.php. It basically does this:



<?php
exec("java -jar MyApp.jar", $output);
print_r($output);
?>


the MyApp.jar is a simple java application that connects to the local MariaDB and returns some useful information retrieved from the DB.


My main question is: where should my .jar files be and how do I make sure I execute the correct jar from php (how to reference it? full path?) and how/where/what else do I need to modify....


To try and expand this some more: 1) where should I put the MyApp.jar? Currently I have it in the /var/www/html dir with the test.php - however, I don't want it there. I'd rather put it somewhere safe so it cannot be accessed externally. I've seen mention of putting it down a level from the http root, etc. but I'd like more clarity as to what else needs to happen.


Should I simply put it outside wherever I want it - say in my home directory? If so do i need to modify the exec path location? Edits to httpd.conf? other files, etc. Ownerships, etc.? I'm a bit confused.


2) Ideally I also want to link the mariaDB java jar library (for the driver connector). Again, I want to put that in a safe place. Currently, httpd I don't believe can access this via the .jar manifest CLASSPATH as it doesn't have permission to grab the jar library from its current location. So again, I think I have a permission/location issue with this file as well. I think the answer to 2 will be the same as 1?


My jar manifest is:



Mainfest-version: 1.0
Main-Class: MyApp
Class-Path: /home/ramjet/MyApp/lib/mariadb-java-client-1.1.7.jar . MyApp.jar


httpd can't get to the connector here. And I don't think it should be here anyway.


Thanks in advance



asked 57 secs ago







Permissions and jar file locations for php exec on apache

Aucun commentaire:

Enregistrer un commentaire