我正在尝试在 AWS 上发布销售或商店并使用 Apache

I am trying to publish a saleor store on AWS and using Apache

我已经 运行 发布了默认的 django 项目,它工作正常,我能够使用域名访问它,然后我只是替换了 saleor 的详细信息,现在我收到 404 not found。这是我的配置文件:

<VirtualHost *:80>

    ServerAdmin admin@example.com
    DocumentRoot /home/ubuntu/ecom

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    Alias /static /home/ubuntu/ecom/saleor/saleor/static
    <Directory /home/ubuntu/ecom/saleor/saleor/static>
        Require all granted
    </Directory>

    <Directory /home/ubuntu/ecom/saleor/saleor/wsgi>
        <Files __init__.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess myproject2 python-home=/home/ubuntu/ecom/ecom python-path=/home/ubuntu/ecom
    WSGIProcessGroup myproject2
    WSGIScriptAlias / /home/ubuntu/ecom/saleor/saleor/wsgi/__init__.py
</VirtualHost>

这里 /home/ubuntu/ecom 是我的项目主目录,它包含 ecom(虚拟环境)和 saleor 文件夹。 我在销售或项目

的settings.py文件中添加了glintwear.com我的域名

编辑 这是来自 error.log 文件的错误:

[Wed Aug 15 01:09:17.240064 2018] [wsgi:error] [pid 14328:tid 140275526600448] [remote 39.53.22.238:27753] mod_wsgi (pid=14328): Target WSGI script '/home/ubuntu/ecom/$
[Wed Aug 15 01:09:17.240110 2018] [wsgi:error] [pid 14328:tid 140275526600448] [remote 39.53.22.238:27753] mod_wsgi (pid=14328): Exception occurred processing WSGI scr$
[Wed Aug 15 01:09:17.240269 2018] [wsgi:error] [pid 14328:tid 140275526600448] [remote 39.53.22.238:27753] Traceback (most recent call last):
[Wed Aug 15 01:09:17.240291 2018] [wsgi:error] [pid 14328:tid 140275526600448] [remote 39.53.22.238:27753]   File "/home/ubuntu/ecom/saleor/saleor/wsgi/__init__.py", l$
[Wed Aug 15 01:09:17.240296 2018] [wsgi:error] [pid 14328:tid 140275526600448] [remote 39.53.22.238:27753]     from django.core.wsgi import get_wsgi_application  # noqa
[Wed Aug 15 01:09:17.240310 2018] [wsgi:error] [pid 14328:tid 140275526600448] [remote 39.53.22.238:27753] ImportError: No module named 'django'

编辑:

正如@Graham Dumpleton 所指出的,您必须更改

python-home=/home/ubuntu/ecom/ecom

这不是您的虚拟环境的路径。

Check that directory given to python-home is the same as sys.prefix for the virtual environment.

所以你应该有这样的东西:

python-home=/home/ubuntu/ecom/venv

所以如果其他人有问题,我会回答这个问题。这个项目被搁置了,这就是为什么我这么晚才更新它。无论如何,问题是 python-home 应该指向 manage.py 所在的根目录。 python-path 应该指向您的 virtualenv 文件夹。就是这样。

<VirtualHost *:80>

    ServerAdmin admin@example.com
    DocumentRoot /home/ubuntu/ecom

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    Alias /static /home/ubuntu/ecom/saleor/saleor/static
    <Directory /home/ubuntu/ecom/saleor/saleor/static>
        Require all granted
    </Directory>

    <Directory /home/ubuntu/ecom/saleor/saleor/wsgi>
        <Files __init__.py>
            Require all granted
        </Files>
    </Directory>

    WSGIDaemonProcess myproject2 python-home=/home/ubuntu/ecom/ecom/saleor python-path=/home/ubuntu/ecom/env
    WSGIProcessGroup myproject2
    WSGIScriptAlias / /home/ubuntu/ecom/saleor/saleor/wsgi/__init__.py
</VirtualHost>