AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[mod-wsgi](server)

Martin Hope
Standard
Asked: 2021-10-14 07:21:36 +0800 CST

Apache 的虚拟主机配置突然不再工作了;如何调试?

  • 0

出乎意料的是,我的虚拟主机配置不再起作用。所以我的设置很简单:在端口 80 上,我想提供两个 WSGI 应用程序,这就是我正在使用的 .conf 文件:

<VirtualHost *:80>
        ServerName mogli.secret.de

        #########
        # RESTAPI
        #########

        WSGIScriptAlias /mogli/api /opt/mogli/restapi/app.wsgi
        <Directory /opt/mogli/restapi/>
                Options FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>

        #########
        # WEBAPP
        #########

        WSGIScriptAlias /mogli/webapp /opt/mogli/webapp/app.wsgi
        <Directory /opt/mogli/webapp/>
                Options FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel debug
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

所以就像我说的那样,我让它工作了,所以我不知道到底发生了什么变化。Apache 服务器启动没有问题。我也跑a2ensite MogliFlask成功了。但是当我打开我的网络应用程序时,它只是说 404 Not found。(/工作中的默认索引页面,顺便说一句)

访问日志只是说同样的:

"GET /mogli/api/doc HTTP/1.1" 404 507 "-" "Mozilla/5.0 [...]"

当我打开网页时,错误日志什么也没说,只有一些注意事项:

[Thu Oct 14 07:29:36.906477 2021] [core:notice] [pid 159:tid 140444421547136] AH00094: Command line: '/usr/sbin/apache2'
[Thu Oct 14 07:30:11.780214 2021] [mpm_event:notice] [pid 159:tid 140444421547136] AH00491: caught SIGTERM, shutting down
[Thu Oct 14 07:52:09.914051 2021] [mpm_event:notice] [pid 165:tid 140689596499072] AH00489: Apache/2.4.38 (Debian) mod_wsgi/4.6.5 Python/3.7 configured -- resuming normal operations

运行时apachectl -t -D DUMP_VHOSTS我得到这个状态:

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server mogli.secret.de (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost mogli.secret.de (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost mogli.secret.de (/etc/apache2/sites-enabled/MogliFlask.conf:1)

我正在运行 Debian 10。

到目前为止我尝试过的事情:

  • 重新启动服务器
  • 重新安装 Apache2 和 WSGI mod
  • 谷歌搜索如何在没有成功的情况下实际调试这种错误

所以我的问题是 - 我如何跟踪我的错误?VirtualHost 配置有什么问题?任何类型的提示都会有所帮助,我对此非常迷茫。谢谢!

mod-wsgi apache2
  • 1 个回答
  • 215 Views
Martin Hope
ThatCoolCoder
Asked: 2021-07-25 23:29:22 +0800 CST

为什么 Apache2 找不到我的 WSGI 应用程序?

  • 2

在我之前的问题中,我询问了如何让 mod_wsgi 使用特定的 Python 版本。根据该问题的答案,我创建了一个 Python 3.9 虚拟环境并让 WSGI 使用它。但是,现在我的 Flask 应用程序根本没有运行——我只是为我的站点的其余部分配置了 404 页面。重新启动 Apache2 时我没有收到任何错误,当我访问该站点时 Apache 错误日志为空。我认为错误一定是由于我的虚拟环境造成的,因为我在使用相同的配置样式之前已经创建了以前的测试 Flask 应用程序。

我的虚拟环境位于path/to/my/app/venv/.

path/to/my/app/runner.wsgi:

import sys

# Make something appear in error log if the WSGI is run at all
raise ValueError()

PROJECT_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, PROJECT_DIR)

from my_app import app as application

部分/etc/apache2/sites-available/000-default-le-ssl.conf:

WSGIDaemonProcess myapp user=www-data group=www-data threads=4 python-home=/path/to/my/app/venv/
WSGIScriptAlias /my-app/ path/to/my/app/runner.wsgi

/etc/apache2/mods-available/wsgi.load

LoadModule wsgi_module "/path/to/my/app/venv/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-x86_64-linux-gnu.so"
WSGIPythonHome "path/to/my/app/venv"

操作系统:Ubuntu 18.04.5 LTS

mod-wsgi python http-status-code-404 apache2 flask
  • 2 个回答
  • 447 Views
Martin Hope
Manav Sengupta
Asked: 2020-10-03 19:34:20 +0800 CST

如何在 centos 8 VPS 的 apache 服务器中启用/加载 mod_wsgi

  • 1

我无法在 cent os 8 VPS 的 apache 网络服务器中启用/加载模块 mod_wgsi。通过运行命令,它在 ubuntu 中非常容易工作sudo apt install libapache2-mod-wsgi-py3请帮助我在 centos 8 中为 django 设置 apache,让我知道如何为 apache 启用 mod_wsgi。非常感谢您的帮助。

我最初运行的命令:

sudo yum update
sudo yum install python3-pip python3-devel httpd httpd-devel
pip3 install mod_wsgi
centos django mod-wsgi httpd apache-2.4
  • 2 个回答
  • 3636 Views
Martin Hope
Codejoy
Asked: 2016-05-24 07:17:20 +0800 CST

使用 mod_wsgi 在 centos 上的 apache 下部署 django 时遇到问题

  • -1

编辑2:我大部分时间都在运行!这确实是一个 SELinux 问题。所以大多数事情都有效,我得到一个无法写入只读数据库的错误。而且我的一些看起来像静态的东西没有找到,主要是 /admin 在任何东西上都看不到。我不确定是 mysite.settings 问题还是什么。

编辑:感谢下面的评论者,我仔细检查了所有内容并得到了一个新错误。这也许是一个进步,但看起来我确实启用了一些 SELinux 策略,并且不是一个系统管理员,我不确定从哪里开始寻找这告诉我什么。这是 apache error_log

[Wed May 25 10:08:16.399785 2016] [core:notice] [pid 14935] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Wed May 25 10:08:16.401177 2016] [suexec:notice] [pid 14935] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed May 25 10:08:16.432549 2016] [so:warn] [pid 14935] AH01574: module wsgi_module is already loaded, skipping
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.20.0.33. Set the 'ServerName' directive globally to suppress this message
[Wed May 25 10:08:16.438588 2016] [auth_digest:notice] [pid 14935] AH01757: generating secret for digest authentication ...
[Wed May 25 10:08:16.439945 2016] [lbmethod_heartbeat:notice] [pid 14935] AH02282: No slotmem from mod_heartmonitor
[Wed May 25 10:08:16.448393 2016] [mpm_prefork:notice] [pid 14935] AH00163: Apache/2.4.6 (CentOS) mod_wsgi/3.4 Python/2.7.5 OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 configured -- resuming normal operations
[Wed May 25 10:08:16.448434 2016] [core:notice] [pid 14935] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed May 25 10:08:20.102783 2016] [mime_magic:error] [pid 14937] [client 172.20.0.33:59454] AH01512: mod_mime_magic: can't read `/home/sthomas/django_nga_site/mysite/wsgi.py'
[Wed May 25 10:08:20.117380 2016] [:error] [pid 14937] (13)Permission denied: [client 172.20.0.33:59454] mod_wsgi (pid=14937, process='', application='172.20.0.33|/nga_sw'): Call to fopen() failed for '/home/sthomas/django_nga_site/mysite/wsgi.py'.

如果我尝试点击 url,它会给我一个 500 错误。

我应该在 wsgi.py 文件上添加权限是:

-rw-r--r-x 并且对 wsgi.py 文件所在的 home 文件夹的权限是:

drwxr-xr-x

阅读可能已经有我答案的问题,看起来不像是那些问题,所以我在这里发布希望得到引导。

我试图使用这个网址:

https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/

我的版本:

服务器版本:Apache/2.4.6 (CentOS) 服务器搭建时间:2015 年 11 月 19 日 21:43:13

CentOs 版本:CentOS Linux release 7.2.1511 (Core)

Python 版本:Python 2.7.5

Django 版本:(1, 9, 6, 'final', 0)

在我不管理的 centos 盒子上,但我有 sudo 访问权限,所以我能够安装让我的 django 应用程序运行所需的一切python manage.py runserver。看起来不错,所以我想解决下一个让它在 apache 下运行的问题。

Apache 已经在 /var/www/html 下提供了我网站的静态版本并且它运行良好,尽管我将我自己的 WSGI 东西添加到 httpd.conf 文件并加载了我认为的 mod_wsgi。虽然我现在在点击 url 的 ip 地址时得到的只是:

You don't have permission to access / on this server.

所以我回顾了 httpd.conf 并没有尝试设置(别名?)任何东西只是 / 所以我不确定它在做什么。

我的应用程序位于文件夹 /home/sthomas 的值下,我认为我设置了正确的 chwon 和 chmod。

为了做到这一点,我花了一段时间才意识到我必须移动/删除/重命名 apache 设置的welcome.conf 文件,以便每次点击我的 URL 时都看不到默认的欢迎屏幕(我的 linux kung-fu 是基本的)

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
LoadModule wsgi_module modules/mod_wsgi.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User apache
Group apache

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin root@localhost

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "/var/www/html"
DocumentRoot "/var/www"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ".ht*">
    Require all denied
</Files>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to 
    # exist in your server's namespace, but do not anymore. The client 
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts. 
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default.  To use the 
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    #
    # The mod_mime_magic module allows the server to use various hints from the
    # contents of the file itself to determine its type.  The MIMEMagicFile
    # directive tells the module where the hint definitions are located.
    #
    MIMEMagicFile conf/magic
</IfModule>

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it, 
# memory-mapping or the sendfile syscall may be used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted 
# filesystems or if support for these functions is otherwise
# broken on your system.
# Defaults if commented: EnableMMAP On, EnableSendfile Off
#
#EnableMMAP off
EnableSendfile on

# Supplemental configuration
#
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

WSGIScriptAlias /nga_sw /home/sthomas/django_nga_site/mysite/wsgi.py
WSGIPythonPath /home/sthomas/django_nga_site

<Directory /home/sthomas/django_nga_site/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
centos django mod-wsgi python apache-2.4
  • 1 个回答
  • 6760 Views
Martin Hope
xGlorify
Asked: 2016-05-05 20:52:56 +0800 CST

在 Sonicwall 后面服务 Flask + Apache + WSGI

  • 1

这里奇怪的问题。我已经阅读了有关为 Flask 应用程序设置部署环境的教程。

当我导航到服务器本地 IP 地址时,它一切正常。但是,我认为在外部为 Flask/Python 逻辑提供服务存在问题。

端口 80 已打开并成功转发,如其当前页面(索引 / Apache 等)所示,但它没有像在本地子网中那样显示“你好,我爱 DigitalOcean”。在我在启用站点中启用我的 Flask 应用程序之前,它还显示了默认的 Apache HTML 模板。

在我的 Apache .conf 文件中,我目前将 ServerName 设置为本地 IP 地址。我的理解是,无论如何,进出端口 80 的所有流量都将路由到该地址,并且它仅在外部提供静态 Apache HTML 文件时才起作用。

我在这里超级困惑,就好像 python / flask 逻辑在不同的端口上传输并且它没有出去!?

apache-2.2 mod-wsgi sonicwall flask
  • 1 个回答
  • 93 Views
Martin Hope
gyin
Asked: 2012-07-11 03:02:59 +0800 CST

Apache / mod_wsgi / Django 找不到 MySQL 共享库

  • 1

我遇到了这样一种情况,即在 Apache/mod_wsgi/Django 部署的服务器上找不到 MySQL 库,尽管仅 Python 就可以正确导入该库。

这是我的 Apache 日志错误:

[Tue Jul 10 12:52:02 2012] [error] [client 127.0.0.1]   File "/remote/projects1/pdrtke/python/lib/python2.6/site-packages/Django-1.3-py2.6.egg/django/utils/importlib.py", line 35, in import_module
[Tue Jul 10 12:52:02 2012] [error] [client 127.0.0.1]     __import__(name)
[Tue Jul 10 12:52:02 2012] [error] [client 127.0.0.1]   File "/remote/projects1/pdrtke/python/lib/python2.6/site-packages/Django-1.3-py2.6.egg/django/db/backends/mysql/base.py", line 14, in <module>
[Tue Jul 10 12:52:02 2012] [error] [client 127.0.0.1]     raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
[Tue Jul 10 12:52:02 2012] [error] [client 127.0.0.1] ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory

我已经尝试过以下方法:

  • 检查 Python 解释器是否可以做import MySQLdb:好的
  • 检查python manage.py ...需要数据库支持的操作是否有效:好的
  • 检查LD_LIBRARY_PATH指向 libmysqlclient_r.so.16 可用的目录:好的
  • 附上httpd过程gdb,并做一个show env:LD_LIBRARY_PATH要点libmysqlclient_r.so.16
  • 修改envvarsbin/http目录下的文件添加一个export LD_LIBRARY_PATH=...(以防万一):Ok
  • 通过 a 检查ldd libmysqlclient_r.so.16库本身不包含未解决的依赖项
  • 检查httpd可执行文件没有设置 setuid 位;这是忽略的有据可查的理由LD_LIBRARY_PATH:好的

这些操作似乎都无法解决我的问题。有什么明显的事情我忘了考虑吗?

mysql apache-2.2 django mod-wsgi
  • 1 个回答
  • 963 Views
Martin Hope
gyin
Asked: 2012-06-27 01:46:14 +0800 CST

知道为什么 mod_wsgi 在 Apache httpd 中创建核心转储吗?

  • 1

我完成了 mod_wsgi 的故障排除,但找不到针对我的分段错误案例的答案。mod_wsgi当模块集成到我的 Apache httpd 服务器中时,我得到以下 coredump 。服务器没有mod_wsgi运行良好。

  • 阿帕奇 httpd: 2.2.22
  • mod_wsgi:3.3
  • 蟒蛇:2.6.7

知道是什么导致了核心转储吗?有没有我可以尝试的事情或解决方法?

核心转储:

Program terminated with signal 11, Segmentation fault.
#0  0x00007fe06c39d206 in wsgi_python_init () from /remote/projects1/pdrtke/install/httpd-2.2.22/modules/mod_wsgi.so
#1  0x00007fe06c3aadb5 in wsgi_hook_child_init () from /remote/projects1/pdrtke/install/httpd-2.2.22/modules/mod_wsgi.so
#2  0x00000000004424db in ap_run_child_init ()
#3  0x000000000047ea35 in child_main ()
#4  0x000000000047ef26 in make_child ()
#5  0x000000000047f198 in perform_idle_server_maintenance ()
#6  0x000000000047f67b in ap_mpm_run ()
#7  0x0000000000429361 in main ()

httpd从源代码编译的二进制文件。(我跑了configure --prefix=...,仅此而已)

> file httpd                                                                                                                                                                                
    httpd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), not stripped
> ldd httpd
    linux-vdso.so.1 =>  (0x00007fffdc5ff000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f33ef7fe000)
    libaprutil-1.so.0 => /remote/projects1/pdrtke/install/httpd-2.2.22/lib/libaprutil-1.so.0 (0x00007f33ef5d4000)
    libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f33ef3aa000)
    libapr-1.so.0 => /remote/projects1/pdrtke/install/httpd-2.2.22/lib/libapr-1.so.0 (0x00007f33ef172000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f33eef69000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f33eed2e000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f33eeb11000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f33ee90d000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f33ee5af000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f33efa54000)

模块 WSGI:

> file mod_wsgi.so       
    mod_wsgi.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
> ldd mod_wsgi.so
    linux-vdso.so.1 =>  (0x00007fffb8f0e000)
    libpython2.6.so.1.0 => /usr/lib64/libpython2.6.so.1.0 (0x00007f4c6dd87000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4c6db69000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f4c6d965000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007f4c6d762000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f4c6d50b000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f4c6d1ad000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f4c6e37b000)

Python 可执行文件:

> file python
    python: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), not stripped
> ldd python
    linux-vdso.so.1 =>  (0x00007fff6a1ff000)
    libpython2.6.so.1.0 => /softntools/opt/Python-2.6/bin/../lib/libpython2.6.so.1.0 (0x00007f14730fc000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1472edf000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f1472cdb000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007f1472ad8000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f1472882000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f1472524000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f14733b0000)
apache-2.2 mod-wsgi python httpd
  • 2 个回答
  • 752 Views
Martin Hope
mgibsonbr
Asked: 2012-06-23 10:32:08 +0800 CST

mod_wsgi 仅在用户登录时工作

  • 0

我已经使用 Apache (mod_wsgi) 和 PostgreSQL (psycopg2) 在 Linux 服务器(Ubuntu 服务器 12.4)上设置了一个 Django 应用程序。我遇到了Postgres 的 unix 身份验证问题,所以我选择了一个普通用户作为数据库所有者和 apache 用户。它工作正常,但现在我必须使用该用户登录才能使 mod_wsgi 工作。如果我没有登录,apache 会正常提供静态文件,但是当尝试访问 mod_wsgi 时会出现以下错误:

[...] [error] [...] Target WSGI script not found or unable to stat: /parent/folder

我尝试检查文件的权限(包括将其设置为 777),但仍然出现相同的错误(每个人都可以读取父文件夹)。该文件(以及静态文件和 Django 文件)存储在同一用户的主目录中。我现在卡住了,有什么想法吗?

PS 我对 *nix 机器非常缺乏经验,我将其设置为 hack 来启动和运行系统。但我宁愿为 Apache 和 PostgreSQL 使用不同的用户,或者至少为两者使用相同的用户但不是普通用户(即也将用于登录和执行操作的用户)。一个我可以立即使用的快速解决方案会很棒,但是一个合适的解决方案——即使我不能立即申请——也会非常受欢迎。


更新:我的apache2.conf文件大部分没有修改(从默认设置),只改变了用户和组:

#User ${APACHE_RUN_USER}
#Group ${APACHE_RUN_GROUP}
User myuser
Group myuser

(用户名和组名相同)

带有虚拟主机的文件几乎包含标准的 Django 安装,但每个文件都存储在该用户的主文件夹中(设置为 755,确认可由 Apache 访问):

<VirtualHost *:80>

    DocumentRoot /home/myuser/myproject
    <Directory />
        Options All
        AllowOverride None
    </Directory>
    <Directory /home/myuser/myproject>
        Options All
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    WSGIDaemonProcess myproject processes=6 threads=1
    WSGIProcessGroup myproject

    Alias /media/ "/home/myuser/myproject/media/"
    Alias /static/ "/home/myuser/myproject/static/"
    WSGIScriptAlias / "/home/myuser/myproject/myproject.wsgi"

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined
</VirtualHost>

我已经离开了客户的站点,但我会尝试尽快在我的开发机器上复制设置(所以我最感兴趣的是正确的解决方案而不是快速修复)。欢迎任何提示或指示。

linux apache-2.2 mod-wsgi
  • 1 个回答
  • 209 Views
Martin Hope
Esa Varemo
Asked: 2012-06-12 04:45:22 +0800 CST

以不同用户身份运行 apache + mod_wsgi

  • 2

我有一个 django 项目,我正在从开发服务器转移到 apache。我已经设法通过 mod_wsgi 获得它的服务器,但它作为 apache 运行。Mod_wsgi 文档说,如果 apache 以 root 身份运行,则可以以不同的用户身份运行 mod_wsgi 进程。

Q1:是否可以在不以 root 身份运行 apache 的情况下以不同的用户身份运行 mod_wsgi?

Q2:如果以上问题的答案是否定的,我如何让 apache 以 root 身份运行。我在 CentOS 6 机器上使用提供的存储库提供的 httpd 包。

apache-2.2 mod-wsgi python users uid
  • 1 个回答
  • 4388 Views
Martin Hope
gozzilli
Asked: 2012-05-18 01:51:15 +0800 CST

mod_wsgi 无法访问 apache 配置

  • 1

前提是我在服务器上有:

  • mod_wsgi加载并启用
  • 无所不能htaccess,

我可以mod_wsgi在不需要编辑全局 apache 配置文件的情况下使用吗?我没有服务器的管理权限。

使用modpython它可以从根文件夹的htaccess.

如果答案是否定的,正如QuickConfigurationGuide似乎建议的那样,我可以要求我的系统管理员做的最好的事情是什么,这样他们就可以编辑配置一次而不再与我交谈?考虑一个多用户系统,例如您在共享主机或大学的用户页面中找到的系统。

我正在尝试部署像 django、cherry py 或 web.py 这样的框架,但我认为这不会有什么不同。

apache-2.2 mod-wsgi .htaccess python shared-hosting
  • 1 个回答
  • 1454 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve