简体   繁体   中英

OSX and setting PATH for Apache

I have Apache running on OSX Lion and MacPorts Python and some packages installed with MacPorts.

There are some Python cgi scripts that I'd like to run. It looks like Apache uses the Python that is installed with Lion. How can I configure Apache so that the cgi scripts are run with the MacPorts Python and sites-packages (PYTHONPATH I guess)?

Edit /System/Library/LaunchDaemons/org.apache.httpd.plist. After the initial <dict> tag, add this, setting whatever path you require. Restart Apache.

<key>EnvironmentVariables</key>
 <dict>
   <key>PATH</key>
   <string>/usr/bin:/bin:/usr/sbin:/sbin</string>
 </dict>

You can use SetEnv in and .htaccess file to set other environment variables, eg PYTHONPATH, but SetEnv can't be used to set the PATH.

在CGI脚本中编辑shebang行以指向其他可执行文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM