Wednesday, August 7, 2019

Python3 - Ubuntu - Apache - Access Anaconda python library from apache

The apache server has its own path. To make change to the PATH variable, we need to change in the file: /etc/apache2/envvars

$ sudo vi /etc/apache2/envvars


At the end of this file. I added the path of anaconda3 library:

export PATH=/opt/anaconda3/bin:$PATH


Created a small test script to confirm if the path is correct:

$ more test1.php
<?php
$output = shell_exec('echo $PATH');
echo "<pre>$output</pre>";
?>



This gives the following output:

/opt/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin


Hence, we can ensure that our apache2 user is able to access anaconda library of python.

Reference:


No comments:

Post a Comment