Apache 服务器错误“ImportError:没有名为 site 的模块”

Apache 服务器错误“ImportError:没有名为 site 的模块”

我正在尝试使用基于 squashfs 的 rootfs 运行 apache 服务器。我在 /var/log/apache2_error_logs 中看到以下内容

$ cat /var/log/apache2_error_log
[Mon Apr 29 18:40:28.705047 2013] [mpm_worker:notice] [pid 0:tid 1073880416] AH00292: Apache/2.4.3 (Unix) mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations
[Mon Apr 29 18:40:28.706298 2013] [core:notice] [pid 2235447778748764:tid 1073880416] AH00094: Command line: '/usr/local/apache2/bin/httpd'
ImportError: No module named site
ImportError: No module named site
ImportError: No module named site
$ ps -aef | grep httpd
root      8085     1  0 18:40 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    8086  8085  0 18:40 ?        00:00:00 /usr/local/apache2/bin/httpd -k start
daemon    9563  8085  3 18:43 ?        00:00:00 [httpd] <defunct>
daemon    9564  8085  3 18:43 ?        00:00:00 [httpd] <defunct>
manu      9573   448  0 18:43 ttyO2    00:00:00 grep httpd

httpd.conf 中的一些重要配置设置包括

ServerRoot "/usr/local/apache2"

Listen 80

LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgid_module modules/mod_cgid.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule wsgi_module modules/mod_wsgi.so

<Directory /platform/www/html/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all
</Directory>

ServerName FX750072AFAE:80
<Directory />
    AllowOverride none
    Require all denied
</Directory>

ErrorLog "/var/log/apache2_error_log"
ScriptSock /var/run/cgisock
<Directory "/platform/www/cgi-bin/">
                AddHandler cgi-script .cgi .pl .py
                Options +ExecCGI
                AllowOverride AuthConfig FileInfo
                Order allow,deny
                Allow from all
                Require all granted
</Directory>

<Directory "/platform/www/wsgi-bin/">
        AddHandler wsgi-script .wsgi .pl .py
        Options +ExecCGI
        AllowOverride AuthConfig FileInfo
        Order allow,deny
        Allow from all
        Require all granted
</Directory>
Alias /control "/platform/www/wsgi-bin/rm.wsgi"
Alias /Control "/platform/www/wsgi-bin/rm.wsgi"
PidFile /var/run/httpd.pid

与基于JFFS2的根文件系统相同的配置可以正常工作。

在我启动 apache 服务之前,

export PYTHONHOME=/
sudo /usr/local/apache2/bin/restart.sh

答案1

export PYTHONHOME=/ 
sudo /usr/local/apache2/bin/restart.sh

Apache 不会看到此变量(除非您对 sudo 配置做了一些修改)。尝试将导出放入 restart.sh 并查看它的作用。

相关内容