0

Есть сервер ubuntu, на котором развернут django проект. Есть доменное имя, по которому открывается сайт. Связка apache+mod_sgi. Проблема в том, что мне нужно попасть в корневую папку апача с локальной машины, но что бы я не вбивал в браузере, localhost, или локальный айпишник, все равно открывается сайт. Как разделить сайт с каталогом апача?

apache2.conf:

<Directory /web>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

000-default.conf:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port t$
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /web

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

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

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

wsgy.conf:

WSGIScriptAlias / /web/site/site.com/site/wsgi.py
WSGIDaemonProcess penguintours.ru python-home=/web/venvs/siteenv python-path=/web/site/site.com
WSGIProcessGroup site/site.com
<Directory /web/site/site.com/site>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

site.com.conf:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName site.com
    ServerAlias www.site.com
    DocumentRoot /web/site/site.com
    ErrorLog /web/site/logs/error.log
    CustomLog /web/site/logs/access.log combined

2
  • 000-default.conf содержит только директиву DocumentRoot /web ?
    – de_frag
    16 фев 2019 в 18:27
  • По сути да. Так апач реализован в убунте. Поправил пост, выложил полный файл.
    – lzhec
    17 фев 2019 в 3:08

1 ответ 1

0

Решил проблему следующим образом. В wsgi.conf оставил только строки, относящиеся к демону, т.к. их нельзя прописывать внутри виртуального хоста (в документации ошибочно написано, что можно), все остальное перенес в хост, сверху добавил NameVirtualHost с внешним ip. Теперь сайт открывается только по внешнему адресу и по домену. По localhost и локальному айпишнику открывается корневая папка сервера.

wsgi.conf:

WSGIDaemonProcess site.ru python-home=/web/venvs/siteenv python-path=/web/site/site.com
WSGIProcessGroup site.com

site.com.conf:

NameVirtualHost 10.10.10.10:80

<VirtualHost 10.10.10.10:80>
ServerAdmin [email protected]
ServerName site.com
ServerAlias www.site.com
WSGIScriptAlias / /web/site/site.com/site/wsgi.py
DocumentRoot /web/site/site.com
<Directory /web/site/site.com/site>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

<Directory /web/site/site.com>
    Require all granted
</Directory>
ErrorLog /web/site/logs/error.log
CustomLog /web/site/logs/access.log combined

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.