java - Permissions and jar file locations for php exec on apache -
i'm setting little experiment on linux machine running mariadb, apache, java , php... , after playing around day , searching on topic - need farther clarification on permissions , locations. allow me first frame this:
in web directory: /var/www/html have little test program: test.php. this:
<?php exec("java -jar myapp.jar", $output); print_r($output); ?>
the myapp.jar simple java application connects local mariadb , returns useful info retrieved db.
my main question is: should .jar files , how create sure execute right jar php (how reference it? total path?) , how/where/what else need modify....
edit: @ moment i'm going set files in:
/usr/share/httpd/
in php code i'm going refer total path: i.e.
exec("java -jar /usr/share/httpd/myapp.jar", $output);
in involvement of helping others - stumbled permission denied issue , needed following:
setsebool -p httpd_can_network_connect_db=1
i'd interested in comments/answers on security implications of having jar files in /usr/share/httpd directory. there improve location? need ensure these .jar files cannot reached externally. using same directory jar libraries.
install jdk
assume illustration wish develop java programs in add-on installing jdk. assume farther current version of jdk v1.7.0, , want automatically reply "yes" questions installation programme asks. come in next command @ centos command line: $ sudo yum install java-1.7.0-openjdk-devel -y
set java_home environment variable
set java_home location of jdk, /usr/lib/jvm/java-1.7.0-openjdk default. $ sudo sh -c 'echo export java_home=/usr/lib/jvm/java-1.7.0-openjdk > /etc/profile.d/java.sh' $ source /etc/profile.d/java.sh
download apache tomcat
download tomcat binary. next command assumes current version of tomcat v7.0.56: $ wget http://apache.mirrors.tds.net/tomcat/tomcat-7/v7.0.56/bin/apache-tomcat-7.0.56.tar.gz
note: check ensure downloading latest version. version 7.0.56 current @ time of writing.
unpack , configure
unpack binary file tar command: $ sudo tar xvzf apache-tomcat-7.0.56.tar.gz -c /opt
make unpacked files read-only; $ sudo chmod +r /opt/apache-tomcat-7.0.56/conf/*
set catalina_home directory tomcat files $ sudo sh -c 'echo export catalina_home=/opt/apache-tomcat-7.0.56 > /etc/profile.d/tomcat.sh' $ source /etc/profile.d/tomcat.sh
start tomcat
run tomcat's startup script. $ sudo $catalina_home/bin/startup.sh
java apache lamp
No comments:
Post a Comment